zcfrank1st commited on
Commit
35efc3a
·
1 Parent(s): 81917a3

change code

Browse files
Files changed (2) hide show
  1. app.py +13 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -4,6 +4,9 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
 
 
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -13,11 +16,18 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
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
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from smolagents import OpenAIServerModel, CodeAgent
8
+ from smolagents.tools import DuckDuckGoSearchTool
9
+
10
  # (Keep Constants as is)
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
16
  class BasicAgent:
17
  def __init__(self):
18
  print("BasicAgent initialized.")
19
+ model = OpenAIServerModel(
20
+ model="gpt-4o-mini",
21
+ api_key="sk-proj-1234567890",
22
+ base_url="https://api.openai.com/v1",
23
+ )
24
+ self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
25
+
26
  def __call__(self, question: str) -> str:
27
  print(f"Agent received question (first 50 chars): {question[:50]}...")
28
+ answer = self.agent(question)
29
+ print(f"Agent returning answer: {answer}")
30
+ return answer
31
 
32
  def run_and_submit_all( profile: gr.OAuthProfile | None):
33
  """
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio
2
- requests
 
 
1
  gradio
2
+ requests
3
+ smolagents