Update multiagents.py
Browse files- multiagents.py +16 -12
multiagents.py
CHANGED
|
@@ -99,27 +99,30 @@ manager_agent = CodeAgent(
|
|
| 99 |
|
| 100 |
class MultiAgent:
|
| 101 |
def __init__(self):
|
| 102 |
-
print("
|
| 103 |
|
| 104 |
def __call__(self, question: str) -> str:
|
|
|
|
|
|
|
| 105 |
try:
|
| 106 |
if not isinstance(question, str):
|
| 107 |
question = str(question)
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
|
| 122 |
-
|
|
|
|
| 123 |
|
| 124 |
except Exception as e:
|
| 125 |
error = f"An error occurred while processing the question: {e}"
|
|
@@ -127,6 +130,7 @@ class MultiAgent:
|
|
| 127 |
return error
|
| 128 |
|
| 129 |
|
|
|
|
| 130 |
if __name__ == "__main__":
|
| 131 |
# Example usage
|
| 132 |
|
|
|
|
| 99 |
|
| 100 |
class MultiAgent:
|
| 101 |
def __init__(self):
|
| 102 |
+
print("MultiAgent initialized.")
|
| 103 |
|
| 104 |
def __call__(self, question: str) -> str:
|
| 105 |
+
mylog(self.__class__.__name__, question)
|
| 106 |
+
|
| 107 |
try:
|
| 108 |
if not isinstance(question, str):
|
| 109 |
question = str(question)
|
| 110 |
|
| 111 |
+
full_prompt = f"""
|
| 112 |
+
You are the top agent of a multi-agent system that answers questions by coordinating web and audiovisual agents.
|
| 113 |
+
You will receive a question and decide which agent to use.
|
| 114 |
+
Use the web_agent for online info or fetching webpages.
|
| 115 |
+
Use audiovideo_agent for YouTube videos or images/audio files.
|
| 116 |
+
Return answers in the exact format required.
|
| 117 |
|
| 118 |
+
QUESTION:
|
| 119 |
+
{question.strip()}
|
| 120 |
|
| 121 |
+
{myprompts.output_format.strip()}
|
| 122 |
+
"""
|
| 123 |
|
| 124 |
+
# ✅ Ensure this is a string — not a list of messages
|
| 125 |
+
return manager_agent.run(full_prompt.strip())
|
| 126 |
|
| 127 |
except Exception as e:
|
| 128 |
error = f"An error occurred while processing the question: {e}"
|
|
|
|
| 130 |
return error
|
| 131 |
|
| 132 |
|
| 133 |
+
|
| 134 |
if __name__ == "__main__":
|
| 135 |
# Example usage
|
| 136 |
|