Update agent.py
Browse files
agent.py
CHANGED
|
@@ -26,12 +26,12 @@ if not TAVILY_API_KEY:
|
|
| 26 |
|
| 27 |
|
| 28 |
MAX_WIKIPEDIA_RESULTS = 3
|
| 29 |
-
MAX_TAVILY_RESULTS =
|
| 30 |
-
MAX_ARXIV_RESULTS =
|
| 31 |
-
MAX_TOOL_ITERATIONS =
|
| 32 |
|
| 33 |
class GaiaAgent:
|
| 34 |
-
def __init__(self, model_name="gpt-
|
| 35 |
self.model_name = model_name
|
| 36 |
self.openai_client = openai.OpenAI() # Inizializza il client OpenAI
|
| 37 |
if TAVILY_API_KEY:
|
|
@@ -180,20 +180,8 @@ class GaiaAgent:
|
|
| 180 |
]
|
| 181 |
|
| 182 |
system_prompt = (
|
| 183 |
-
"
|
| 184 |
-
|
| 185 |
-
"Segui questi passaggi per rispondere alla domanda dell'utente:\n"
|
| 186 |
-
"1. **Analizza la Domanda**: Comprendi a fondo cosa viene chiesto. Se la domanda è complessa, scomponila in sotto-problemi.\n"
|
| 187 |
-
"2. **Pianifica l'Uso degli Strumenti**: Decidi quali strumenti sono più appropriati e in quale ordine. Puoi usare più strumenti in sequenza.\n"
|
| 188 |
-
" - `search_wikipedia`: per conoscenza generale consolidata.\n"
|
| 189 |
-
" - `search_tavily`: per informazioni recenti, argomenti di nicchia, o per confermare/trovare URL specifici. Può fornire risposte dirette.\n" # Aggiornato
|
| 190 |
-
" - `search_arxiv`: per ricerca scientifica e tecnica.\n"
|
| 191 |
-
" - `execute_python_code`: per calcoli, elaborazione di dati testuali/numerici, o simulazioni. Il codice deve stampare esplicitamente i risultati.\n"
|
| 192 |
-
"3. **Esegui e Itera**: Usa gli strumenti. Se uno strumento non fornisce l'informazione necessaria, valuta se riformulare la query, provare un altro strumento, o concludere che l'informazione non è reperibile con gli strumenti attuali.\n"
|
| 193 |
-
"4. **Sintetizza e Rispondi**: Combina le informazioni raccolte e la tua conoscenza interna per formulare una risposta finale chiara, concisa e che risponda direttamente alla domanda originale. Se non riesci a trovare una risposta definitiva, indicalo chiaramente.\n"
|
| 194 |
-
"Limita il numero di chiamate agli strumenti a un massimo di {} iterazioni per domanda. ".format(MAX_TOOL_ITERATIONS) +
|
| 195 |
-
"Fornisci solo la risposta finale senza commentare il processo di ragionamento o l'uso degli strumenti, a meno che non sia esplicitamente richiesto o necessario per chiarire la provenienza di un'informazione cruciale."
|
| 196 |
-
)
|
| 197 |
|
| 198 |
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": question}]
|
| 199 |
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
MAX_WIKIPEDIA_RESULTS = 3
|
| 29 |
+
MAX_TAVILY_RESULTS = 3 # Tavily può restituire risultati più ricchi
|
| 30 |
+
MAX_ARXIV_RESULTS = 2
|
| 31 |
+
MAX_TOOL_ITERATIONS = 5
|
| 32 |
|
| 33 |
class GaiaAgent:
|
| 34 |
+
def __init__(self, model_name="gpt-4.1"):
|
| 35 |
self.model_name = model_name
|
| 36 |
self.openai_client = openai.OpenAI() # Inizializza il client OpenAI
|
| 37 |
if TAVILY_API_KEY:
|
|
|
|
| 180 |
]
|
| 181 |
|
| 182 |
system_prompt = (
|
| 183 |
+
"You are a general AI assistant. I will ask you a question. Your output needs to be checked versus an exact match test, 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."
|
| 184 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": question}]
|
| 187 |
|