Kurama0303 commited on
Commit
93a01a7
·
verified ·
1 Parent(s): c31330a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
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,10 +14,18 @@ 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 OpenAIServerModel, DuckDuckGoSearchTool, CodeAgent, WikipediaSearchTool
7
+ from smolagents.tools import Tool
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
+ self.agent = CodeAgent(
18
+ model=OpenAIServerModel(model_id="gpt-4o-mini"),
19
+ tools=[
20
+ DuckDuckGoSearchTool(),
21
+ WikipediaSearchTool()
22
+ ],
23
+ add_base_tools=True,
24
+ )
25
  print("BasicAgent initialized.")
26
  def __call__(self, question: str) -> str:
27
  print(f"Agent received question (first 50 chars): {question[:50]}...")
28
+ fixed_answer = self.agent.run(question)
29
  print(f"Agent returning fixed answer: {fixed_answer}")
30
  return fixed_answer
31