v1nybarreto commited on
Commit
1d900e7
·
verified ·
1 Parent(s): 81917a3

Atualizando agente com smolagent

Browse files

Substituí o agente padrão por um baseado no smolagent com a ferramenta PythonInterpreterTool.

Agora o agente consegue interpretar e executar instruções computacionais usando um interpretador Python. O objetivo é obter melhores respostas durante a avaliação do benchmark GAIA no curso de agentes da Hugging Face.

Inclui:
- Integração com smolagent
- Extração da resposta final via "FINAL ANSWER:"
- Prints informativos para debugging

Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -12,12 +14,21 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  class BasicAgent:
14
  def __init__(self):
15
- print("BasicAgent initialized.")
 
 
 
16
  def __call__(self, question: str) -> str:
17
- print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
 
 
 
 
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagent import CodeAgent
7
+ from smolagent.tools.python import PythonInterpreterTool
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
 
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
  class BasicAgent:
16
  def __init__(self):
17
+ print("🔧 Inicializando CodeAgent com ferramenta Python.")
18
+ tools = [PythonInterpreterTool()]
19
+ self.agent = CodeAgent(tools=tools)
20
+
21
  def __call__(self, question: str) -> str:
22
+ print(f"🤖 Pergunta recebida: {question[:100]}")
23
+ response = self.agent.run(question)
24
+
25
+ if "FINAL ANSWER:" in response:
26
+ answer = response.split("FINAL ANSWER:")[-1].strip()
27
+ else:
28
+ answer = response.strip()
29
+
30
+ print(f"✅ Resposta final: {answer}")
31
+ return answer
32
 
33
  def run_and_submit_all( profile: gr.OAuthProfile | None):
34
  """