Update src/orchestrator.py
Browse files- src/orchestrator.py +13 -13
src/orchestrator.py
CHANGED
|
@@ -3,18 +3,14 @@ from typing import Dict, Any, Optional
|
|
| 3 |
|
| 4 |
from .config import RunConfig
|
| 5 |
from .agents import AnalyzerAgent, RefactorAgent, CriticAgent, AgentResult
|
| 6 |
-
from .tasks import
|
| 7 |
-
TaskContext,
|
| 8 |
-
build_analyzer_prompt,
|
| 9 |
-
build_refactor_prompt,
|
| 10 |
-
build_critic_prompt,
|
| 11 |
-
)
|
| 12 |
|
| 13 |
|
| 14 |
@dataclass
|
| 15 |
class RunTrace:
|
| 16 |
task: str
|
| 17 |
input_requirements: str
|
|
|
|
| 18 |
analyzer: AgentResult
|
| 19 |
refactor: AgentResult
|
| 20 |
critic: AgentResult
|
|
@@ -23,6 +19,7 @@ class RunTrace:
|
|
| 23 |
return {
|
| 24 |
"task": self.task,
|
| 25 |
"input_requirements": self.input_requirements,
|
|
|
|
| 26 |
"analyzer": asdict(self.analyzer),
|
| 27 |
"refactor": asdict(self.refactor),
|
| 28 |
"critic": asdict(self.critic),
|
|
@@ -38,19 +35,22 @@ class Orchestrator:
|
|
| 38 |
self.refactor = RefactorAgent(cfg.refactor)
|
| 39 |
self.critic = CriticAgent(cfg.critic)
|
| 40 |
|
| 41 |
-
def run(self, requirements_text: str) -> RunTrace:
|
| 42 |
-
|
| 43 |
-
r1 = self.analyzer.run(p1)
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
return RunTrace(
|
| 52 |
task=self.ctx.name,
|
| 53 |
input_requirements=requirements_text,
|
|
|
|
| 54 |
analyzer=r1,
|
| 55 |
refactor=r2,
|
| 56 |
critic=r3,
|
|
|
|
| 3 |
|
| 4 |
from .config import RunConfig
|
| 5 |
from .agents import AnalyzerAgent, RefactorAgent, CriticAgent, AgentResult
|
| 6 |
+
from .tasks import TaskContext, build_analyzer_prompt, build_refactor_prompt, build_critic_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
@dataclass
|
| 10 |
class RunTrace:
|
| 11 |
task: str
|
| 12 |
input_requirements: str
|
| 13 |
+
image_attached: bool
|
| 14 |
analyzer: AgentResult
|
| 15 |
refactor: AgentResult
|
| 16 |
critic: AgentResult
|
|
|
|
| 19 |
return {
|
| 20 |
"task": self.task,
|
| 21 |
"input_requirements": self.input_requirements,
|
| 22 |
+
"image_attached": self.image_attached,
|
| 23 |
"analyzer": asdict(self.analyzer),
|
| 24 |
"refactor": asdict(self.refactor),
|
| 25 |
"critic": asdict(self.critic),
|
|
|
|
| 35 |
self.refactor = RefactorAgent(cfg.refactor)
|
| 36 |
self.critic = CriticAgent(cfg.critic)
|
| 37 |
|
| 38 |
+
def run(self, requirements_text: str, image_path: Optional[str] = None) -> RunTrace:
|
| 39 |
+
has_image = bool(image_path)
|
|
|
|
| 40 |
|
| 41 |
+
p1 = build_analyzer_prompt(requirements_text, has_image, self.ctx)
|
| 42 |
+
r1 = self.analyzer.run(p1, image_path=image_path)
|
| 43 |
|
| 44 |
+
p2 = build_refactor_prompt(requirements_text, r1.output, has_image, self.ctx)
|
| 45 |
+
r2 = self.refactor.run(p2, image_path=image_path)
|
| 46 |
+
|
| 47 |
+
p3 = build_critic_prompt(requirements_text, r2.output, has_image, self.ctx)
|
| 48 |
+
r3 = self.critic.run(p3, image_path=image_path)
|
| 49 |
|
| 50 |
return RunTrace(
|
| 51 |
task=self.ctx.name,
|
| 52 |
input_requirements=requirements_text,
|
| 53 |
+
image_attached=has_image,
|
| 54 |
analyzer=r1,
|
| 55 |
refactor=r2,
|
| 56 |
critic=r3,
|