sirine1712 commited on
Commit
612fa38
·
verified ·
1 Parent(s): 6de3904

Update multiagents.py

Browse files
Files changed (1) hide show
  1. 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
- 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:
129
- error = f"An error occurred while processing the question: {e}"
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__":