jc7k commited on
Commit
c0e050f
·
1 Parent(s): 81917a3

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +19 -3
  2. requirements.txt +2 -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 ---
@@ -13,11 +15,25 @@ 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
  """
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import ToolCallingAgent, HfapiModel, DuckDuckGoSearchTool
7
+
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
 
15
  class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
+ model =- HfapiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
19
+ agent = ToolCallingAgent(tools=[DuckDuckGoSearchTool()], model=model)
20
+ self.agent = agent
21
+ print(f"Agent initialized with model: {model.model_id}")
22
+ print(f"Agent initialized with tools: {self.agent.tools}")
23
+
24
  def __call__(self, question: str) -> str:
25
  print(f"Agent received question (first 50 chars): {question[:50]}...")
26
+
27
+ answer = self.agent.run(question)
28
+ if answer:
29
+ print(f"Agent returning answer: {answer}")
30
+ return answer
31
+ else:
32
+ print("Agent returned no answer, returning fixed answer.")
33
+ # Fallback to a fixed answer if the agent does not return anything
34
+ fixed_answer = "This is a default answer."
35
+ print(f"Agent returning fixed answer: {fixed_answer}")
36
+ return fixed_answer
37
 
38
  def run_and_submit_all( profile: gr.OAuthProfile | None):
39
  """
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio
2
- requests
 
 
1
  gradio
2
+ requests
3
+ smolagents