Update agent.py
Browse files
agent.py
CHANGED
|
@@ -180,7 +180,7 @@ class GaiaAgent:
|
|
| 180 |
]
|
| 181 |
|
| 182 |
system_prompt = (
|
| 183 |
-
"You are a general AI assistant that uses the tools available. I will ask you a question. You must output only the exact answer to the question, so your final answer must be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. In comma separated lists, do not use blank spaces. If you are asked for a code number, give the code number nothing else. Do not add a dot at the end of the answer."
|
| 184 |
)
|
| 185 |
|
| 186 |
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": question}]
|
|
@@ -235,7 +235,7 @@ class GaiaAgent:
|
|
| 235 |
return final_answer
|
| 236 |
else:
|
| 237 |
print("L'LLM non ha chiamato strumenti e non ha fornito contenuto. Tento di forzare una risposta.")
|
| 238 |
-
messages.append({"role": "user", "content": "
|
| 239 |
final_attempt_response = self._call_openai_api(messages)
|
| 240 |
if isinstance(final_attempt_response, str): return final_attempt_response
|
| 241 |
if final_attempt_response and final_attempt_response.choices[0].message.content:
|
|
@@ -243,7 +243,7 @@ class GaiaAgent:
|
|
| 243 |
return "L'agente ha ricevuto una risposta finale vuota e non è riuscito a generarne una alternativa."
|
| 244 |
|
| 245 |
print("L'agente ha raggiunto il numero massimo di iterazioni degli strumenti.")
|
| 246 |
-
messages.append({"role": "user", "content": "
|
| 247 |
final_summary_response = self._call_openai_api(messages)
|
| 248 |
if isinstance(final_summary_response, str): return final_summary_response
|
| 249 |
if final_summary_response and final_summary_response.choices[0].message.content:
|
|
|
|
| 180 |
]
|
| 181 |
|
| 182 |
system_prompt = (
|
| 183 |
+
"You are a general AI assistant that uses the tools available. I will ask you a question. You must output only the exact answer to the question with no comments, so your final answer must be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. In comma separated lists, do not use blank spaces. If you are asked for a code number, give the code number nothing else. Do not add a dot at the end of the answer. If you are asked for 'the number of', answer with the count number."
|
| 184 |
)
|
| 185 |
|
| 186 |
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": question}]
|
|
|
|
| 235 |
return final_answer
|
| 236 |
else:
|
| 237 |
print("L'LLM non ha chiamato strumenti e non ha fornito contenuto. Tento di forzare una risposta.")
|
| 238 |
+
messages.append({"role": "user", "content": "Please provide the best possible answer based on the information you have gathered so far, without using any other tools."})
|
| 239 |
final_attempt_response = self._call_openai_api(messages)
|
| 240 |
if isinstance(final_attempt_response, str): return final_attempt_response
|
| 241 |
if final_attempt_response and final_attempt_response.choices[0].message.content:
|
|
|
|
| 243 |
return "L'agente ha ricevuto una risposta finale vuota e non è riuscito a generarne una alternativa."
|
| 244 |
|
| 245 |
print("L'agente ha raggiunto il numero massimo di iterazioni degli strumenti.")
|
| 246 |
+
messages.append({"role": "user", "content": "You have reached your tool usage limit. Please provide the best possible answer based on the information you have gathered so far."})
|
| 247 |
final_summary_response = self._call_openai_api(messages)
|
| 248 |
if isinstance(final_summary_response, str): return final_summary_response
|
| 249 |
if final_summary_response and final_summary_response.choices[0].message.content:
|