Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -377,11 +377,12 @@ class MagAgent:
|
|
| 377 |
|
| 378 |
# Validate loaded prompts structure
|
| 379 |
if isinstance(user_prompts, dict):
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
|
|
|
| 385 |
else:
|
| 386 |
print(f"Invalid prompts.yaml structure. Using defaults. Got type: {type(user_prompts)}")
|
| 387 |
|
|
@@ -423,13 +424,14 @@ class MagAgent:
|
|
| 423 |
|
| 424 |
def _build_task_prompt(self, question: str, task_id: str) -> str:
|
| 425 |
"""Constructs task-specific prompts using templates"""
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
|
|
|
| 433 |
|
| 434 |
async def _execute_agent(self, question: str, task_id: str) -> str:
|
| 435 |
return await asyncio.to_thread(
|
|
|
|
| 377 |
|
| 378 |
# Validate loaded prompts structure
|
| 379 |
if isinstance(user_prompts, dict):
|
| 380 |
+
for key in self.prompt_templates.keys():
|
| 381 |
+
if key in user_prompts:
|
| 382 |
+
# Merge nested template dictionaries
|
| 383 |
+
self.prompt_templates[key].update(
|
| 384 |
+
user_prompts[key]
|
| 385 |
+
)
|
| 386 |
else:
|
| 387 |
print(f"Invalid prompts.yaml structure. Using defaults. Got type: {type(user_prompts)}")
|
| 388 |
|
|
|
|
| 424 |
|
| 425 |
def _build_task_prompt(self, question: str, task_id: str) -> str:
|
| 426 |
"""Constructs task-specific prompts using templates"""
|
| 427 |
+
system_template = self.prompt_templates["system_prompt"]["template"]
|
| 428 |
+
managed_agent_template = self.prompt_templates["managed_agent"]["template"].format(
|
| 429 |
+
question_analysis=question,
|
| 430 |
+
subtasks=self._generate_subtasks(question),
|
| 431 |
+
validation_rules=self._get_validation_rules()
|
| 432 |
+
)
|
| 433 |
+
|
| 434 |
+
return f"{system_template}\n\n{managed_agent_template}"
|
| 435 |
|
| 436 |
async def _execute_agent(self, question: str, task_id: str) -> str:
|
| 437 |
return await asyncio.to_thread(
|