chezhian commited on
Commit
7428e94
·
verified ·
1 Parent(s): 96c374c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -3,12 +3,30 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from agent import BasicAgent
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  def run_and_submit_all( profile: gr.OAuthProfile | None):
14
  """
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import OpenAIServerModel, DuckDuckGoSearchTool, PythonInterpreterTool, WikipediaSearchTool, CodeAgent
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
 
12
+ # --- Basic Agent Definition ---
13
+ # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
+ class BasicAgent:
15
+ def __init__(self):
16
+ print("BasicAgent initialized.")
17
+ def __call__(self, question: str) -> str:
18
+ self.agent = CodeAgent(
19
+ model=OpenAIServerModel(
20
+ model_id="anthropic/claude-3.7-sonnet",
21
+ api_key=os.environ["OPENROUTER_API_KEY"],
22
+ api_base="https://openrouter.ai/api/v1"
23
+ ),
24
+ tools=[DuckDuckGoSearchTool(), PythonInterpreterTool(), WikipediaSearchTool()]
25
+ )
26
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
27
+ fixed_answer = self.agent.run(question)
28
+ print(f"Agent returning answer: {fixed_answer}")
29
+ return fixed_answer
30
 
31
  def run_and_submit_all( profile: gr.OAuthProfile | None):
32
  """