lukmanaj commited on
Commit
3c81963
·
verified ·
1 Parent(s): 76f58af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -15
app.py CHANGED
@@ -178,32 +178,24 @@ class BasicAgent:
178
 
179
  self.search_tool = DuckDuckGoSearchTool()
180
 
181
- # Dummy model placeholder, not used
182
  self.agent = CodeAgent(
183
  tools=[self.search_tool],
184
- model=self, # Pass self as the model
185
  planning_interval=3
186
  )
187
 
188
- def __call__(self, prompt: str, **kwargs) -> object:
189
- """Directly call Gemini API for each prompt."""
190
  try:
191
  response = client.generate_content(
192
  model=model_id,
193
  contents=[{"role": "user", "parts": [{"text": prompt}]}],
194
  generation_config=generation_config
195
  )
196
- answer = response.candidates[0].content.parts[0].text.strip()
197
- # Wrap in a simple object with .content attribute
198
- class Output:
199
- def __init__(self, content):
200
- self.content = content
201
- return Output(content=answer)
202
  except Exception as e:
203
- class Output:
204
- def __init__(self, content):
205
- self.content = content
206
- return Output(content=f"Error: {str(e)}")
207
 
208
  def run_agent(self, question: str) -> str:
209
  """Run the agent on a question."""
@@ -214,7 +206,7 @@ class BasicAgent:
214
  return result
215
  except Exception as e:
216
  return f"Error running agent: {str(e)}"
217
-
218
  def run_and_submit_all( profile: gr.OAuthProfile | None):
219
  """
220
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
178
 
179
  self.search_tool = DuckDuckGoSearchTool()
180
 
 
181
  self.agent = CodeAgent(
182
  tools=[self.search_tool],
183
+ model=self, # Pass self as model
184
  planning_interval=3
185
  )
186
 
187
+ def __call__(self, prompt: str, **kwargs) -> str:
188
+ """Directly call Gemini API for each prompt, returning a string."""
189
  try:
190
  response = client.generate_content(
191
  model=model_id,
192
  contents=[{"role": "user", "parts": [{"text": prompt}]}],
193
  generation_config=generation_config
194
  )
195
+ answer = response.text
196
+ return answer
 
 
 
 
197
  except Exception as e:
198
+ return f"Error during Gemini call: {str(e)}"
 
 
 
199
 
200
  def run_agent(self, question: str) -> str:
201
  """Run the agent on a question."""
 
206
  return result
207
  except Exception as e:
208
  return f"Error running agent: {str(e)}"
209
+
210
  def run_and_submit_all( profile: gr.OAuthProfile | None):
211
  """
212
  Fetches all questions, runs the BasicAgent on them, submits all answers,