Update multiagents.py
Browse files- multiagents.py +16 -16
multiagents.py
CHANGED
|
@@ -101,34 +101,34 @@ class MultiAgent:
|
|
| 101 |
print("BasicAgent initialized.")
|
| 102 |
|
| 103 |
def __call__(self, question: str) -> str:
|
| 104 |
-
|
| 105 |
|
| 106 |
try:
|
| 107 |
-
# Ensure prefix and formatting rules are plain strings
|
| 108 |
prefix = (
|
| 109 |
-
"You are the top agent of a multi-agent system that can answer questions by coordinating the work of other agents
|
| 110 |
-
"
|
| 111 |
-
"
|
| 112 |
-
"- You may also use your own reasoning if no tool is needed.\n\n"
|
| 113 |
-
"Be thorough, think step by step, and ensure your final answer follows the required output format."
|
| 114 |
)
|
| 115 |
|
| 116 |
-
|
| 117 |
-
full_prompt = f"{prefix.strip()}\n\nTHE QUESTION:\n{question.strip()}\n\n{myprompts.output_format.strip()}"
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
# ✅ Call the CodeAgent with a plain string
|
| 124 |
result = manager_agent.run(full_prompt)
|
| 125 |
|
| 126 |
return result if isinstance(result, str) else str(result)
|
| 127 |
|
| 128 |
except Exception as e:
|
| 129 |
-
|
| 130 |
-
print(error)
|
| 131 |
-
return error
|
| 132 |
|
| 133 |
|
| 134 |
if __name__ == "__main__":
|
|
|
|
| 101 |
print("BasicAgent initialized.")
|
| 102 |
|
| 103 |
def __call__(self, question: str) -> str:
|
| 104 |
+
from myprompts import output_format
|
| 105 |
|
| 106 |
try:
|
|
|
|
| 107 |
prefix = (
|
| 108 |
+
"You are the top agent of a multi-agent system that can answer questions by coordinating the work of other agents. "
|
| 109 |
+
"Use the `web_agent` to search the web and retrieve content. Use the `audiovideo_agent` for extracting transcripts and analyzing media. "
|
| 110 |
+
"Use your own knowledge when no tool is needed. Always follow the required output format."
|
|
|
|
|
|
|
| 111 |
)
|
| 112 |
|
| 113 |
+
full_prompt = f"""{prefix.strip()}
|
|
|
|
| 114 |
|
| 115 |
+
THE QUESTION:
|
| 116 |
+
{question.strip()}
|
| 117 |
+
|
| 118 |
+
{output_format.strip()}"""
|
| 119 |
+
|
| 120 |
+
# ✅ Validate before sending to model
|
| 121 |
+
assert isinstance(full_prompt, str), "Prompt must be a string."
|
| 122 |
+
|
| 123 |
+
print("Sending prompt to manager_agent:")
|
| 124 |
+
print(full_prompt)
|
| 125 |
|
|
|
|
| 126 |
result = manager_agent.run(full_prompt)
|
| 127 |
|
| 128 |
return result if isinstance(result, str) else str(result)
|
| 129 |
|
| 130 |
except Exception as e:
|
| 131 |
+
return f"❌ Agent Error: {str(e)}"
|
|
|
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
if __name__ == "__main__":
|