Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -351,26 +351,35 @@ class MagAgent:
|
|
| 351 |
SpeechToTextTool(),
|
| 352 |
]
|
| 353 |
|
| 354 |
-
#
|
| 355 |
-
|
| 356 |
-
"system_prompt": "
|
| 357 |
-
"managed_agent": "
|
| 358 |
-
"planning": "
|
| 359 |
-
"final_answer": "
|
| 360 |
}
|
| 361 |
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
#
|
| 367 |
-
|
| 368 |
-
#
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
|
| 375 |
|
| 376 |
self.agent = CodeAgent(
|
|
|
|
| 351 |
SpeechToTextTool(),
|
| 352 |
]
|
| 353 |
|
| 354 |
+
# Initialize with default prompts
|
| 355 |
+
self.prompt_templates = {
|
| 356 |
+
"system_prompt": "You are Magus...",
|
| 357 |
+
"managed_agent": "Decomposing problem...",
|
| 358 |
+
"planning": "Step-by-Step Plan...",
|
| 359 |
+
"final_answer": "Final Verified Answer..."
|
| 360 |
}
|
| 361 |
|
| 362 |
+
try:
|
| 363 |
+
with open("prompts.yaml") as f:
|
| 364 |
+
user_prompts = yaml.safe_load(f)
|
| 365 |
+
|
| 366 |
+
# Validate loaded prompts structure
|
| 367 |
+
if isinstance(user_prompts, dict):
|
| 368 |
+
# Merge with defaults, preserving missing keys
|
| 369 |
+
self.prompt_templates.update({
|
| 370 |
+
k: v for k, v in user_prompts.items()
|
| 371 |
+
if k in self.prompt_templates
|
| 372 |
+
})
|
| 373 |
+
else:
|
| 374 |
+
print(f"Invalid prompts.yaml structure. Using defaults. Got type: {type(user_prompts)}")
|
| 375 |
+
|
| 376 |
+
except Exception as e:
|
| 377 |
+
print(f"Error loading prompts.yaml: {str(e)}. Using default templates")
|
| 378 |
+
|
| 379 |
+
# Final validation
|
| 380 |
+
required_keys = {'system_prompt', 'managed_agent', 'planning', 'final_answer'}
|
| 381 |
+
if missing := required_keys - self.prompt_templates.keys():
|
| 382 |
+
raise ValueError(f"Missing required prompt templates: {missing}")
|
| 383 |
|
| 384 |
|
| 385 |
self.agent = CodeAgent(
|