Use agent framework to debate everything.
This project explores a simple multi-agent debate workflow. A user gives a topic or task, then several agents respond in sequence:
- Agent 1 gives an initial analysis or draft answer.
- Agent 2 critiques Agent 1's response.
- Agent 1 responds to the critique and improves the answer.
- Agent 2 gives further feedback.
- Agent 3 summarizes the whole discussion.
The goal is to use debate-style prompting to improve reasoning, critique, and final answers.
debate_250416.pynow usesollama_api.pyfor the local Ollama/api/chatrequest format.ollama_api.pykeeps Ollama as the default API and can also call an OpenAI-compatible/chat/completionsAPI.- Keep
debate_dspy_250416.pyas the currently smooth-running DSPy reference version. - Previous code snapshots are stored in
previous/before the rewrite. - Next: optimize the UI, either by creating a new version file or by using a more popular chat-style interface.
Previous versions of the main Python files are stored in previous/.
These files are preserved before rewriting so old code is not deleted.
debate_dspy_250416.pyis for debating claims with DSPy.debate_code_250417.pyis for debating code generation tasks.debate_250416.pyis the rewritten Ollama/OpenAI-compatible API version.ollama_api.pycontains the API helper used bydebate_250416.py.
debate_250416.py— Streamlit UI for the rewritten debate workflow.ollama_api.py— API helper. Uses Ollama by default and can use an OpenAI-compatible API.debate_dspy_250416.py— DSPy + Ollama version. This has been the smooth-running reference version.debate_code_250417.py— code-generation debate workflow.previous/— archived snapshots of earlier Python files.src/— image assets used by the README.
The project was checked with the Python environment recorded in the Claude/session environment:
D:\Users\niwakoki\miniconda3\envs\myenv\python.exe
Relevant packages found in that environment:
streamlitrequests
The rewritten Ollama version uses requests, so it does not require LangChain.
The DSPy reference version requires dspy to be installed in the Python environment before running it.
This is the main rewritten version:
streamlit run debate_250416.pyOr run it with the recorded Python environment:
"D:\Users\niwakoki\miniconda3\envs\myenv\python.exe" -m streamlit run debate_250416.pyBy default, this version opens with a clean sidebar. Detailed API settings are folded by default, and the default backend is local Ollama at:
http://localhost:11434/api/chat
Default model:
deepseek-r1:7b
You can change the API link, model name, Ollama format, API key/token, and temperature in the sidebar for the current session only. The sidebar also includes a Test API panel so you can send a short connection test before running a debate.
You can also override the startup defaults with environment variables:
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=deepseek-r1:7bBefore running, make sure Ollama is open and the model exists locally. For example:
ollama list
ollama pull deepseek-r1:7bollama_api.py can also call an OpenAI-compatible /chat/completions API.
Use this mode when connecting to a compatible local server or third-party endpoint.
The easiest way is to choose openai-compatible in the API settings panel after the app opens. Fill in the API link, model name, and optional API key/token there.
You can also set these environment variables before running the app if you want startup defaults:
DEBATE_API_MODE=openai
OPENAI_BASE_URL=http://localhost:1234/v1
OPENAI_MODEL=deepseek-r1:7b
OPENAI_API_KEY=your-key-if-neededThen run:
streamlit run debate_250416.pyNotes:
OPENAI_API_KEYcan be empty if the local compatible server does not require a key.OPENAI_BASE_URLshould point to the API root that contains/chat/completions.
streamlit run debate_dspy_250416.pyThis version uses DSPy and Ollama. Install DSPy first if your environment does not have it.
streamlit run debate_code_250417.pyThis version asks agents to generate, critique, revise, and summarize code.
After a debate finishes, the sidebar export panel provides download buttons for:
- Markdown (
debate_session.md) - HTML (
debate_session.html)
The export includes the prompt, visible API mode/model information, temperature, and agent outputs. It does not include the API key/token.
debate_250416.py shows API controls in the sidebar. Detailed API settings are collapsed by default. The user can choose:
- API mode: Ollama or OpenAI-compatible
- API link / base URL
- model name
- Ollama format:
chatfor/api/chatorgeneratefor/api/generate - API key / token for OpenAI-compatible APIs
- temperature
These UI settings are current-session only. They are stored in Streamlit session state, not written to files, and not committed to git. The API key/token field is a password field. A separate sidebar panel can test the selected API before starting a debate.
debate_250416.py calls:
get_ollama_response(prompt, role, temperature=0.7, api_settings=api_settings)from ollama_api.py.
ollama_api.py then chooses the backend:
- default: Ollama native
/api/chat - optional: Ollama native
/api/generate - optional: OpenAI-compatible
/chat/completions
Environment variables remain useful as startup defaults, but users can override them from the UI for the current session.
The active app keeps the debate workflow separate from API details.
The current UI is branded as Debate Everything and uses a cleaner Streamlit layout:
- API settings are in the sidebar and folded/collapsed by default.
- A separate
Test API connectionpanel can check the selected backend before debate. - The main page uses chat-style transcript messages for the user prompt and each agent response.
- Results are stored in
st.session_stateduring the browser session. - Completed debate results can be downloaded as Markdown or HTML.
Recommended next UI improvements:
-
Improve debate controls
- Add a setting for the number of debate rounds.
- Add a setting for custom agent names or roles.
- Add optional streaming/progressive output if the backend supports it.
-
Possible popular UI directions
- Short term: continue improving the current Streamlit app.
- Later: Gradio ChatInterface for a simple public demo.
- Later: React/Next.js chat frontend if the project needs a more polished web app.
Credit to o3 Mini
AI-coding assist: gpt-4o, o3 Mini
Tech stacks: streamlit, DSpy
