Spaces:
Running
Running
Commit
Β·
d247864
1
Parent(s):
59afc84
fix: address CodeRabbit Phase 5 review feedback
Browse filesCritical fixes:
- Fix invalid model names (gpt-5.1 β gpt-4o, claude-sonnet-4-5 β claude-sonnet-4-20250514)
- Add OpenAI key validation in MagenticOrchestrator with clear error message
- Document Magentic mode's OpenAI-only requirement
Nitpicks:
- Add streaming icon to AgentEvent.to_markdown()
- Use exact equality for PubMed placeholder detection
- Update app.py info text for API key requirements
- Add language identifiers to markdown code blocks in docs
- docs/architecture/overview.md +1 -1
- docs/implementation/08_phase_report.md +4 -4
- docs/implementation/roadmap.md +1 -1
- src/app.py +1 -1
- src/orchestrator_magentic.py +19 -2
- src/tools/pubmed.py +1 -1
- src/utils/config.py +2 -2
- src/utils/models.py +1 -0
docs/architecture/overview.md
CHANGED
|
@@ -65,7 +65,7 @@ Using existing approved drugs to treat NEW diseases they weren't originally desi
|
|
| 65 |
|
| 66 |
### High-Level Design (Phases 1-8)
|
| 67 |
|
| 68 |
-
```
|
| 69 |
User Query
|
| 70 |
β
|
| 71 |
Gradio UI (Phase 4)
|
|
|
|
| 65 |
|
| 66 |
### High-Level Design (Phases 1-8)
|
| 67 |
|
| 68 |
+
```text
|
| 69 |
User Query
|
| 70 |
β
|
| 71 |
Gradio UI (Phase 4)
|
docs/implementation/08_phase_report.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
| 11 |
Current limitation: **Synthesis is basic markdown, not a scientific report.**
|
| 12 |
|
| 13 |
Current output:
|
| 14 |
-
```
|
| 15 |
## Drug Repurposing Analysis
|
| 16 |
### Drug Candidates
|
| 17 |
- Metformin
|
|
@@ -22,7 +22,7 @@ Current output:
|
|
| 22 |
```
|
| 23 |
|
| 24 |
With Report Agent:
|
| 25 |
-
```
|
| 26 |
## Executive Summary
|
| 27 |
One-paragraph summary for busy readers...
|
| 28 |
|
|
@@ -59,7 +59,7 @@ Properly formatted citations...
|
|
| 59 |
## 2. Architecture
|
| 60 |
|
| 61 |
### Phase 8 Addition
|
| 62 |
-
```
|
| 63 |
Evidence + Hypotheses + Assessment
|
| 64 |
β
|
| 65 |
Report Agent
|
|
@@ -68,7 +68,7 @@ Evidence + Hypotheses + Assessment
|
|
| 68 |
```
|
| 69 |
|
| 70 |
### Report Generation Flow
|
| 71 |
-
```
|
| 72 |
1. JudgeAgent says "synthesize"
|
| 73 |
2. Magentic Manager selects ReportAgent
|
| 74 |
3. ReportAgent gathers:
|
|
|
|
| 11 |
Current limitation: **Synthesis is basic markdown, not a scientific report.**
|
| 12 |
|
| 13 |
Current output:
|
| 14 |
+
```markdown
|
| 15 |
## Drug Repurposing Analysis
|
| 16 |
### Drug Candidates
|
| 17 |
- Metformin
|
|
|
|
| 22 |
```
|
| 23 |
|
| 24 |
With Report Agent:
|
| 25 |
+
```markdown
|
| 26 |
## Executive Summary
|
| 27 |
One-paragraph summary for busy readers...
|
| 28 |
|
|
|
|
| 59 |
## 2. Architecture
|
| 60 |
|
| 61 |
### Phase 8 Addition
|
| 62 |
+
```text
|
| 63 |
Evidence + Hypotheses + Assessment
|
| 64 |
β
|
| 65 |
Report Agent
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
### Report Generation Flow
|
| 71 |
+
```text
|
| 72 |
1. JudgeAgent says "synthesize"
|
| 73 |
2. Magentic Manager selects ReportAgent
|
| 74 |
3. ReportAgent gathers:
|
docs/implementation/roadmap.md
CHANGED
|
@@ -165,7 +165,7 @@ tests/
|
|
| 165 |
|
| 166 |
## Complete Architecture (Phases 1-8)
|
| 167 |
|
| 168 |
-
```
|
| 169 |
User Query
|
| 170 |
β
|
| 171 |
Gradio UI (Phase 4)
|
|
|
|
| 165 |
|
| 166 |
## Complete Architecture (Phases 1-8)
|
| 167 |
|
| 168 |
+
```text
|
| 169 |
User Query
|
| 170 |
β
|
| 171 |
Gradio UI (Phase 4)
|
src/app.py
CHANGED
|
@@ -144,7 +144,7 @@ def create_demo() -> Any:
|
|
| 144 |
choices=["simple", "magentic"],
|
| 145 |
value="simple",
|
| 146 |
label="Orchestrator Mode",
|
| 147 |
-
info="Simple: Linear
|
| 148 |
)
|
| 149 |
],
|
| 150 |
)
|
|
|
|
| 144 |
choices=["simple", "magentic"],
|
| 145 |
value="simple",
|
| 146 |
label="Orchestrator Mode",
|
| 147 |
+
info="Simple: Linear (OpenAI/Anthropic) | Magentic: Multi-Agent (OpenAI)",
|
| 148 |
)
|
| 149 |
],
|
| 150 |
)
|
src/orchestrator_magentic.py
CHANGED
|
@@ -1,4 +1,9 @@
|
|
| 1 |
-
"""Magentic-based orchestrator for DeepCritical.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from collections.abc import AsyncGenerator
|
| 4 |
|
|
@@ -17,6 +22,7 @@ from src.agents.judge_agent import JudgeAgent
|
|
| 17 |
from src.agents.search_agent import SearchAgent
|
| 18 |
from src.orchestrator import JudgeHandlerProtocol, SearchHandlerProtocol
|
| 19 |
from src.utils.config import settings
|
|
|
|
| 20 |
from src.utils.models import AgentEvent, Evidence
|
| 21 |
|
| 22 |
logger = structlog.get_logger()
|
|
@@ -27,6 +33,11 @@ class MagenticOrchestrator:
|
|
| 27 |
Magentic-based orchestrator - same API as Orchestrator.
|
| 28 |
|
| 29 |
Uses Microsoft Agent Framework's MagenticBuilder for multi-agent coordination.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
"""
|
| 31 |
|
| 32 |
def __init__(
|
|
@@ -73,7 +84,13 @@ class MagenticOrchestrator:
|
|
| 73 |
judge_agent = JudgeAgent(self._judge_handler, self._evidence_store)
|
| 74 |
|
| 75 |
# Build Magentic workflow
|
| 76 |
-
# Note: MagenticBuilder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
workflow = (
|
| 78 |
MagenticBuilder()
|
| 79 |
.participants(
|
|
|
|
| 1 |
+
"""Magentic-based orchestrator for DeepCritical.
|
| 2 |
+
|
| 3 |
+
NOTE: Magentic mode currently requires OpenAI API keys. The MagenticBuilder's
|
| 4 |
+
standard manager uses OpenAIChatClient. Anthropic support may be added when
|
| 5 |
+
the agent_framework provides an AnthropicChatClient.
|
| 6 |
+
"""
|
| 7 |
|
| 8 |
from collections.abc import AsyncGenerator
|
| 9 |
|
|
|
|
| 22 |
from src.agents.search_agent import SearchAgent
|
| 23 |
from src.orchestrator import JudgeHandlerProtocol, SearchHandlerProtocol
|
| 24 |
from src.utils.config import settings
|
| 25 |
+
from src.utils.exceptions import ConfigurationError
|
| 26 |
from src.utils.models import AgentEvent, Evidence
|
| 27 |
|
| 28 |
logger = structlog.get_logger()
|
|
|
|
| 33 |
Magentic-based orchestrator - same API as Orchestrator.
|
| 34 |
|
| 35 |
Uses Microsoft Agent Framework's MagenticBuilder for multi-agent coordination.
|
| 36 |
+
|
| 37 |
+
Note:
|
| 38 |
+
Magentic mode requires OPENAI_API_KEY. The MagenticBuilder's standard
|
| 39 |
+
manager currently only supports OpenAI. If you have only an Anthropic
|
| 40 |
+
key, use the "simple" orchestrator mode instead.
|
| 41 |
"""
|
| 42 |
|
| 43 |
def __init__(
|
|
|
|
| 84 |
judge_agent = JudgeAgent(self._judge_handler, self._evidence_store)
|
| 85 |
|
| 86 |
# Build Magentic workflow
|
| 87 |
+
# Note: MagenticBuilder requires OpenAI - validate key exists
|
| 88 |
+
if not settings.openai_api_key:
|
| 89 |
+
raise ConfigurationError(
|
| 90 |
+
"Magentic mode requires OPENAI_API_KEY. "
|
| 91 |
+
"Set the key or use mode='simple' with Anthropic."
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
workflow = (
|
| 95 |
MagenticBuilder()
|
| 96 |
.participants(
|
src/tools/pubmed.py
CHANGED
|
@@ -22,7 +22,7 @@ class PubMedTool:
|
|
| 22 |
def __init__(self, api_key: str | None = None) -> None:
|
| 23 |
self.api_key = api_key or settings.ncbi_api_key
|
| 24 |
# Ignore placeholder values from .env.example
|
| 25 |
-
if self.api_key
|
| 26 |
self.api_key = None
|
| 27 |
self._last_request_time = 0.0
|
| 28 |
|
|
|
|
| 22 |
def __init__(self, api_key: str | None = None) -> None:
|
| 23 |
self.api_key = api_key or settings.ncbi_api_key
|
| 24 |
# Ignore placeholder values from .env.example
|
| 25 |
+
if self.api_key == "your-ncbi-key-here":
|
| 26 |
self.api_key = None
|
| 27 |
self._last_request_time = 0.0
|
| 28 |
|
src/utils/config.py
CHANGED
|
@@ -26,8 +26,8 @@ class Settings(BaseSettings):
|
|
| 26 |
llm_provider: Literal["openai", "anthropic"] = Field(
|
| 27 |
default="openai", description="Which LLM provider to use"
|
| 28 |
)
|
| 29 |
-
openai_model: str = Field(default="gpt-
|
| 30 |
-
anthropic_model: str = Field(default="claude-sonnet-4-
|
| 31 |
|
| 32 |
# PubMed Configuration
|
| 33 |
ncbi_api_key: str | None = Field(
|
|
|
|
| 26 |
llm_provider: Literal["openai", "anthropic"] = Field(
|
| 27 |
default="openai", description="Which LLM provider to use"
|
| 28 |
)
|
| 29 |
+
openai_model: str = Field(default="gpt-4o", description="OpenAI model name")
|
| 30 |
+
anthropic_model: str = Field(default="claude-sonnet-4-20250514", description="Anthropic model")
|
| 31 |
|
| 32 |
# PubMed Configuration
|
| 33 |
ncbi_api_key: str | None = Field(
|
src/utils/models.py
CHANGED
|
@@ -125,6 +125,7 @@ class AgentEvent(BaseModel):
|
|
| 125 |
"synthesizing": "π",
|
| 126 |
"complete": "π",
|
| 127 |
"error": "β",
|
|
|
|
| 128 |
}
|
| 129 |
icon = icons.get(self.type, "β’")
|
| 130 |
return f"{icon} **{self.type.upper()}**: {self.message}"
|
|
|
|
| 125 |
"synthesizing": "π",
|
| 126 |
"complete": "π",
|
| 127 |
"error": "β",
|
| 128 |
+
"streaming": "π‘",
|
| 129 |
}
|
| 130 |
icon = icons.get(self.type, "β’")
|
| 131 |
return f"{icon} **{self.type.upper()}**: {self.message}"
|