sirine1712 commited on
Commit
11a3890
·
verified ·
1 Parent(s): 9b927a8

Update multiagents.py

Browse files
Files changed (1) hide show
  1. multiagents.py +20 -19
multiagents.py CHANGED
@@ -101,30 +101,31 @@ class MultiAgent:
101
  print("BasicAgent initialized.")
102
 
103
  def __call__(self, question: str) -> str:
104
- mylog(self.__class__.__name__, question)
105
 
106
  try:
107
- prefix = """You are the top agent of a multi-agent system that can answer questions by coordinating the work of other agents.
108
- You will receive a question and you will decide which agent to use to answer it.
109
- You can use the web_agent to search the web for information and for fetching the content of a web page, or the audiovideo_agent to extract information from video or audio files.
110
- You can also use your own knowledge to answer the question.
111
- You need to respect the output format that is given to you.
112
- Finding the correct answer to the question need reasoning and plannig, read the question carrefully, think step by step and do not skip any steps.
113
- """
114
-
115
- full_prompt = (
116
- prefix.strip()
117
- + "\n\nTHE QUESTION:\n"
118
- + question.strip()
119
- + "\n\n"
120
- + myprompts.output_format.strip()
121
  )
 
 
 
 
 
122
  if not isinstance(full_prompt, str):
123
  full_prompt = str(full_prompt)
124
-
125
- fixed_answer = manager_agent.run(full_prompt)
126
-
127
- return fixed_answer
 
 
 
128
  except Exception as e:
129
  error = f"An error occurred while processing the question: {e}"
130
  print(error)
 
101
  print("BasicAgent initialized.")
102
 
103
  def __call__(self, question: str) -> str:
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
+ "by coordinating the work of other agents.\n"
110
+ "- Use `web_agent` to search or fetch webpage content.\n"
111
+ "- Use `audiovideo_agent` to process YouTube videos, images, or audio files.\n"
112
+ "- You can also use your own reasoning.\n\n"
113
+ "Find the correct answer step by step, then format your output properly."
 
 
 
 
 
 
 
114
  )
115
+
116
+ # ✅ Ensure everything is plain string
117
+ full_prompt = f"{prefix.strip()}\n\nTHE QUESTION:\n{question.strip()}\n\n{myprompts.output_format.strip()}"
118
+
119
+ # ✅ Hard enforcement of string format
120
  if not isinstance(full_prompt, str):
121
  full_prompt = str(full_prompt)
122
+
123
+ # Safe model call
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:
130
  error = f"An error occurred while processing the question: {e}"
131
  print(error)