GilbertoEwaldFilho commited on
Commit
353a546
·
verified ·
1 Parent(s): f1fba65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -26
app.py CHANGED
@@ -68,43 +68,29 @@ SYSTEM_PROMPT = (
68
  # =========================================================
69
  # Basic Agent Definition – usando smolagents
70
  # =========================================================
71
- class BasicAgent:
72
- """
73
- GAIA Agent powered by Mixtral + DuckDuckGo Search
74
- """
75
 
 
76
  def __init__(self):
77
- print("Initializing improved GAIA agent...")
78
 
79
  HF_TOKEN = os.getenv("HF_TOKEN")
 
 
80
  if not HF_TOKEN:
81
- print("❌ ERROR: HF_TOKEN secret not found!")
82
- raise ValueError("HF_TOKEN missing")
83
 
84
- # search tool
85
  self.search_tool = DuckDuckGoSearchTool()
86
 
87
- # LLM client (Mixtral)
88
- client = InferenceClient(
89
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
90
  token=HF_TOKEN,
91
  )
92
 
93
- # Model wrapper
94
  self.model = InferenceClientModel(
95
- client=client,
96
- system_prompt="""
97
- You are a GAIA evaluation agent.
98
-
99
- Rules:
100
- - Use web search when needed.
101
- - Output ONLY the final answer.
102
- - No explanations, no reasoning, no URLs, no extra words.
103
- - EXACT MATCH evaluation.
104
- """,
105
  )
106
 
107
- # The real agent
108
  self.agent = CodeAgent(
109
  model=self.model,
110
  tools=[self.search_tool],
@@ -112,13 +98,22 @@ Rules:
112
  )
113
 
114
  def __call__(self, question: str) -> str:
 
 
115
  try:
116
- result = self.agent.run(
117
- f"Answer this GAIA question. Return ONLY the final answer:\n{question}"
118
  )
119
- return clean_answer(result)
 
 
 
 
 
 
 
120
  except Exception as e:
121
- print(f"Agent error: {e}")
122
  return ""
123
 
124
 
 
68
  # =========================================================
69
  # Basic Agent Definition – usando smolagents
70
  # =========================================================
 
 
 
 
71
 
72
+ class BasicAgent:
73
  def __init__(self):
74
+ print("Initializing GAIA Agent...")
75
 
76
  HF_TOKEN = os.getenv("HF_TOKEN")
77
+ print("HF_TOKEN exists?", HF_TOKEN is not None)
78
+
79
  if not HF_TOKEN:
80
+ raise ValueError("❌ HF_TOKEN not found — create a Secret in your Space!")
 
81
 
 
82
  self.search_tool = DuckDuckGoSearchTool()
83
 
84
+ self.client = InferenceClient(
 
85
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
86
  token=HF_TOKEN,
87
  )
88
 
 
89
  self.model = InferenceClientModel(
90
+ client=self.client,
91
+ system_prompt="Answer ONLY with the final answer. No steps, no explanation."
 
 
 
 
 
 
 
 
92
  )
93
 
 
94
  self.agent = CodeAgent(
95
  model=self.model,
96
  tools=[self.search_tool],
 
98
  )
99
 
100
  def __call__(self, question: str) -> str:
101
+ print(f"\n=== NEW QUESTION ===\n{question}\n")
102
+
103
  try:
104
+ raw = self.agent.run(
105
+ f"Answer this question exactly. Only answer:\n{question}"
106
  )
107
+ print("RAW MODEL RESPONSE:", raw)
108
+
109
+ if not raw or raw.strip() == "":
110
+ print("⚠️ MODEL RETURNED EMPTY STRING ⚠️")
111
+ return ""
112
+
113
+ return clean_answer(raw)
114
+
115
  except Exception as e:
116
+ print("ERROR:", e)
117
  return ""
118
 
119