ORromu commited on
Commit
1281519
·
verified ·
1 Parent(s): 88f8400

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -3,6 +3,13 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
 
 
 
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -12,10 +19,15 @@ 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
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent, OpenAIServerModel, DuckDuckGoSearchTool, WikipediaSearchTool, CodeAgent
7
+
8
+ model = OpenAIServerModel(
9
+ model_id="gemini-2.0-flash",
10
+ api_key=GEMINI_API_KEY,
11
+ api_base="https://generativelanguage.googleapis.com/v1beta/openai/"
12
+ )
13
 
14
  # (Keep Constants as is)
15
  # --- Constants ---
 
19
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
20
  class BasicAgent:
21
  def __init__(self):
22
+ self.agent = CodeAgent(
23
+ tools = [DuckDuckGoSearchTool(), WikipediaSearchTool()],
24
+ model = model,
25
+ add_base_tools=True
26
+ )
27
  print("BasicAgent initialized.")
28
  def __call__(self, question: str) -> str:
29
  print(f"Agent received question (first 50 chars): {question[:50]}...")
30
+ fixed_answer = self.agent.run(question)
31
  print(f"Agent returning fixed answer: {fixed_answer}")
32
  return fixed_answer
33