Update multiagents.py
Browse files- multiagents.py +9 -10
multiagents.py
CHANGED
|
@@ -104,26 +104,25 @@ class MultiAgent:
|
|
| 104 |
mylog(self.__class__.__name__, question)
|
| 105 |
|
| 106 |
try:
|
|
|
|
| 107 |
prefix = (
|
| 108 |
-
"You are the top agent of a multi-agent system that can answer questions "
|
| 109 |
-
"
|
| 110 |
-
"- Use `
|
| 111 |
-
"-
|
| 112 |
-
"
|
| 113 |
-
"Find the correct answer step by step, then format your output properly."
|
| 114 |
)
|
| 115 |
|
| 116 |
-
#
|
| 117 |
full_prompt = f"{prefix.strip()}\n\nTHE QUESTION:\n{question.strip()}\n\n{myprompts.output_format.strip()}"
|
| 118 |
|
| 119 |
-
# ✅
|
| 120 |
if not isinstance(full_prompt, str):
|
| 121 |
full_prompt = str(full_prompt)
|
| 122 |
|
| 123 |
-
# ✅
|
| 124 |
result = manager_agent.run(full_prompt)
|
| 125 |
|
| 126 |
-
# Optionally truncate very long answers to avoid submission rejection
|
| 127 |
return result if isinstance(result, str) else str(result)
|
| 128 |
|
| 129 |
except Exception as e:
|
|
|
|
| 104 |
mylog(self.__class__.__name__, question)
|
| 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.\n"
|
| 110 |
+
"- Use `web_agent` to search or fetch web page content.\n"
|
| 111 |
+
"- Use `audiovideo_agent` to process YouTube, images, or audio files.\n"
|
| 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 |
+
# Combine into a single plain string
|
| 117 |
full_prompt = f"{prefix.strip()}\n\nTHE QUESTION:\n{question.strip()}\n\n{myprompts.output_format.strip()}"
|
| 118 |
|
| 119 |
+
# ✅ Absolutely ensure it's a string
|
| 120 |
if not isinstance(full_prompt, str):
|
| 121 |
full_prompt = str(full_prompt)
|
| 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:
|