A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.
audit: fix ai_debate_agent - replace em dashes, add missing docstrings
Tiioluwanibc8e027e19b8
diff --git a/ai_agents/ai_debate_agent/app.py b/ai_agents/ai_debate_agent/app.pyindex 5024c14..69fb398 100644--- a/ai_agents/ai_debate_agent/app.py+++ b/ai_agents/ai_debate_agent/app.py@@ -32,7 +32,7 @@ def _render_transcript(transcript: list[dict]) -> str:else:badge = f"π₯ **{DEBATER_B} Β· {AGAINST}**"blocks.append(- f"### Round {arg['round']} β {badge}\n\n{arg['content']}"+ f"### Round {arg['round']} - {badge}\n\n{arg['content']}")return "\n\n---\n\n".join(blocks)@@ -59,7 +59,7 @@ def _render_verdict(verdict: dict) -> str:"",headline,"",- f"**Total scores** β {DEBATER_A} (For): `{a_total}` Β· {DEBATER_B} (Against): `{b_total}`",+ f"**Total scores** - {DEBATER_A} (For): `{a_total}` Β· {DEBATER_B} (Against): `{b_total}`","",]@@ -99,7 +99,7 @@ def debate_handler(topic: str, rounds: int):verdict = state.get("verdict", {})if verdict:- status = "β Debate complete β verdict delivered."+ status = "β Debate complete - verdict delivered."elif transcript:latest = transcript[-1]status = (@@ -114,11 +114,12 @@ def debate_handler(topic: str, rounds: int):detail = str(exc).strip() or type(exc).__name__cause = exc.__cause__if cause and str(cause) not in detail:- detail = f"{detail} β {cause}"+ detail = f"{detail} - {cause}"yield f"β Error: {detail}", "", ""def build_ui() -> gr.Blocks:+ """Build and return the Gradio Blocks interface for the debate app."""with gr.Blocks(title="AI Debate Agent") as demo:gr.Markdown(f"""@@ -126,8 +127,8 @@ def build_ui() -> gr.Blocks:Two LLM agents argue opposing sides of your topic; a judge scores everyargument and declares a winner.- - π¦ **Debater A β For** Β· `{DEBATER_A_MODEL}`- - π₯ **Debater B β Against** Β· `{DEBATER_B_MODEL}`+ - π¦ **Debater A - For** Β· `{DEBATER_A_MODEL}`+ - π₯ **Debater B - Against** Β· `{DEBATER_B_MODEL}`- βοΈ **Judge** Β· `{JUDGE_MODEL}`All three agents are routed through [Orq.ai](https://orq.ai/).diff --git a/ai_agents/ai_debate_agent/debate.py b/ai_agents/ai_debate_agent/debate.pyindex 4b373fc..82118ad 100644--- a/ai_agents/ai_debate_agent/debate.py+++ b/ai_agents/ai_debate_agent/debate.py@@ -2,9 +2,9 @@Three agents collaborate on a single graph:-* **Debater A** β argues the "for" position (gemini-3.0-flash via Orq.ai).-* **Debater B** β argues the "against" position (mistral-small-latest via Orq.ai).-* **Judge** β scores every argument and declares a winner (kimi-k2.6 via Orq.ai).+* **Debater A** - argues the "for" position (gemini-3.0-flash via Orq.ai).+* **Debater B** - argues the "against" position (mistral-small-latest via Orq.ai).+* **Judge** - scores every argument and declares a winner (kimi-k2.6 via Orq.ai).All three agents are routed through the Orq.ai OpenAI-compatible router.@@ -86,7 +86,7 @@ def _orq_client():def _history_block(transcript: List[Argument]) -> str:"""Render the debate so far as plain text for the next debater."""if not transcript:- return "(No arguments yet β you are opening the debate.)"+ return "(No arguments yet - you are opening the debate.)"lines = []for arg in transcript:lines.append(f"[Round {arg['round']}] {arg['speaker']} ({arg['position']}):\n{arg['content']}")@@ -94,6 +94,7 @@ def _history_block(transcript: List[Argument]) -> str:def _debater_system_prompt(position: str, topic: str) -> str:+ """Return the system prompt assigning a debater to its position on the given topic."""return (f"You are a sharp, persuasive debater arguing the **{position.upper()}** position "f'on the topic: "{topic}".\n'@@ -105,6 +106,7 @@ def _debater_system_prompt(position: str, topic: str) -> str:def _debater_user_prompt(position: str, round_num: int, transcript: List[Argument]) -> str:+ """Return the user-turn prompt instructing the debater to deliver their argument for this round."""return (f"Debate so far:\n\n{_history_block(transcript)}\n\n"f"It is now round {round_num}. Deliver your {position} argument."@@ -115,6 +117,7 @@ def _debater_user_prompt(position: str, round_num: int, transcript: List[Argumen# Graph nodes# --------------------------------------------------------------------------- #def _debater_a_node(state: DebateState) -> DebateState:+ """Call Debater A's model and append its For-side argument to the transcript."""client = _orq_client()round_num = state["round_num"]messages = [@@ -136,6 +139,7 @@ def _debater_a_node(state: DebateState) -> DebateState:def _debater_b_node(state: DebateState) -> DebateState:+ """Call Debater B's model, append its Against-side argument, and increment the round counter."""client = _orq_client()round_num = state["round_num"]messages = [diff --git a/ai_agents/ai_debate_agent/test_orq.py b/ai_agents/ai_debate_agent/test_orq.pyindex 609d90d..8c6cf34 100644--- a/ai_agents/ai_debate_agent/test_orq.py+++ b/ai_agents/ai_debate_agent/test_orq.py@@ -20,6 +20,7 @@ MODELS = [def main() -> int:+ """Test connectivity to the Orq.ai router for all three debate models and return an exit code."""api_key = os.getenv("ORQ_API_KEY", "").strip()if not api_key or api_key.startswith("your-orq"):print("FAIL: Set a real ORQ_API_KEY in .env (copy from .env.example if needed).")@@ -53,7 +54,7 @@ def main() -> int:failures += 1detail = str(exc).strip() or type(exc).__name__if exc.__cause__ and str(exc.__cause__) not in detail:- detail = f"{detail} β {exc.__cause__}"+ detail = f"{detail} - {exc.__cause__}"print(f"FAIL {label}: {model}")print(f" -> {type(exc).__name__}: {detail}\n")