Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -351,8 +351,14 @@ class MagAgent:
|
|
351 |
SpeechToTextTool(),
|
352 |
]
|
353 |
|
354 |
-
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
self.agent = CodeAgent(
|
358 |
model=self.model,
|
@@ -381,6 +387,16 @@ class MagAgent:
|
|
381 |
"validation_checks": []
|
382 |
}
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
async def _execute_agent(self, question: str, task_id: str) -> str:
|
385 |
return await asyncio.to_thread(
|
386 |
self.agent.run,
|
|
|
351 |
SpeechToTextTool(),
|
352 |
]
|
353 |
|
354 |
+
try:
|
355 |
+
with open("prompts.yaml") as f:
|
356 |
+
self.prompt_templates = yaml.safe_load(f)
|
357 |
+
except Exception as e:
|
358 |
+
self.prompt_templates = {
|
359 |
+
"base_prompt": "Default base prompt...",
|
360 |
+
"task_prompt": "Default task template: {question}"
|
361 |
+
}
|
362 |
|
363 |
self.agent = CodeAgent(
|
364 |
model=self.model,
|
|
|
387 |
"validation_checks": []
|
388 |
}
|
389 |
|
390 |
+
def _build_task_prompt(self, question: str, task_id: str) -> str:
|
391 |
+
"""Constructs task-specific prompts using templates"""
|
392 |
+
base_template = self.prompt_templates.get("base_prompt", "")
|
393 |
+
task_template = self.prompt_templates.get("task_prompt", "").format(
|
394 |
+
question=question,
|
395 |
+
task_id=task_id,
|
396 |
+
current_date=datetime.now().strftime("%Y-%m-%d")
|
397 |
+
)
|
398 |
+
return f"{base_template}\n\n{task_template}"
|
399 |
+
|
400 |
async def _execute_agent(self, question: str, task_id: str) -> str:
|
401 |
return await asyncio.to_thread(
|
402 |
self.agent.run,
|