Debate
Tres agents: uno argumenta a favor de una propuesta, otro en contra, y un juez neutral elige el lado más fuerte. Los montajes adversariales sacan a la luz consideraciones que un solo agent pasa por alto — el desacuerdo es la característica.
Showcase — Debate
Tres agents: uno argumenta a favor de una propuesta, otro en contra, y un juez neutral elige el lado más fuerte. Los montajes adversariales sacan a la luz consideraciones que un solo agent pasa por alto — el desacuerdo es la característica.
Córrelo
bash bootstrap-secrets.sh # reads ../../../../.env, writes secrets/
docker compose up --build # default: PROVIDER=openai
Abre http://localhost:3000. Gemini: PROVIDER=gemini docker compose up --build.
Qué hay aquí
backend/ai_openai.py/backend/ai_gemini.py— agents a favor / en contra / juez.frontend/app/page.tsx— caja de propuesta; ambos lados + veredicto.
Detenlo
docker compose down
Ejecútalo en tu máquina
Descarga el proyecto como ZIP y córrelo con Docker. Levanta un backend FastAPI y un frontend Next.js en localhost:3000.
unzip debate.zip
cd debate
bash bootstrap-secrets.sh # one-time: pulls API keys into ./secrets
docker compose up --build # default provider: openai
# or: PROVIDER=gemini docker compose up --build
Escribe algo, elige un proveedor y ejecuta el mismo código de Código contra la API real. Requiere iniciar sesión.
Los mismos módulos que ejecuta el botón Run. El proyecto completo (frontend, Dockerfile, compose) está en el ZIP, pestaña README.
backend/ai_openai.py
"""Showcase 3 (OpenAI): a debate with a judge.
Three agents again, arranged as adversaries plus a referee: one argues for a
proposition, one against, and a neutral judge decides which side was stronger.
Adversarial multi-agent setups surface considerations a single agent glosses
over — the disagreement is the feature.
"""
from openai import OpenAI
_client = OpenAI()
_MODEL = "gpt-5.4-nano"
def _agent(system: str, user: str) -> str:
return _client.responses.create(model=_MODEL, instructions=system, input=[{"role": "user", "content": user}]).output_text
def run(proposition: str) -> str:
p = proposition.strip()
if not p:
return "Enter a proposition to debate (e.g. 'Remote work is better for productivity')."
pro = _agent("You argue FOR the proposition in 3-4 sentences. Persuasive but honest.", p)
con = _agent("You argue AGAINST the proposition in 3-4 sentences. Persuasive but honest.", p)
verdict = _agent(
"You are a neutral judge. Given a proposition and both sides, say which argument is "
"stronger and why, in 2-3 sentences. Don't just split the difference.",
f"PROPOSITION: {p}\n\nFOR:\n{pro}\n\nAGAINST:\n{con}",
)
return f"FOR:\n{pro}\n\nAGAINST:\n{con}\n\nJUDGE:\n{verdict}"
backend/ai_gemini.py
"""Showcase 3 (Gemini): a debate with a judge.
Same for/against/judge structure, on Gemini.
"""
import os
from google import genai
from google.genai import types
_client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
_MODEL = "gemini-3.1-flash-lite"
def _agent(system: str, user: str) -> str:
r = _client.models.generate_content(
model=_MODEL,
contents=[types.Content(role="user", parts=[types.Part(text=user)])],
config=types.GenerateContentConfig(system_instruction=system),
)
return r.text or ""
def run(proposition: str) -> str:
p = proposition.strip()
if not p:
return "Enter a proposition to debate (e.g. 'Remote work is better for productivity')."
pro = _agent("You argue FOR the proposition in 3-4 sentences. Persuasive but honest.", p)
con = _agent("You argue AGAINST the proposition in 3-4 sentences. Persuasive but honest.", p)
verdict = _agent(
"You are a neutral judge. Given a proposition and both sides, say which argument is "
"stronger and why, in 2-3 sentences. Don't just split the difference.",
f"PROPOSITION: {p}\n\nFOR:\n{pro}\n\nAGAINST:\n{con}",
)
return f"FOR:\n{pro}\n\nAGAINST:\n{con}\n\nJUDGE:\n{verdict}"
Archivos del proyecto
.gitignoreREADME.es.mdREADME.mdbackend/Dockerfilebackend/ai_gemini.pybackend/ai_openai.pybackend/main.pybackend/requirements.txtbootstrap-secrets.shdocker-compose.ymlfrontend/Dockerfilefrontend/app/layout.tsxfrontend/app/page.tsxfrontend/next.config.tsfrontend/package.jsonfrontend/tsconfig.json