Elias-CIC commited on
Commit
8cce0ca
·
verified ·
1 Parent(s): ba9b910

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -3
app.py CHANGED
@@ -3,6 +3,17 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -12,12 +23,28 @@ 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
 
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 (
7
+ WebSearchTool,
8
+ ToolCallingAgent,
9
+ LiteLLMModel,
10
+ DuckDuckGoSearchTool,
11
+ GoogleSearchTool,
12
+ InferenceClientModel,
13
+ VisitWebpageTool,
14
+ WikipediaSearchTool,
15
+ FinalAnswerTool
16
+ )
17
 
18
  # (Keep Constants as is)
19
  # --- Constants ---
 
23
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
24
  class BasicAgent:
25
  def __init__(self):
26
+
27
+ webTool = DuckDuckGoSearchTool()
28
+ model = InferenceClientModel("Qwen/Qwen2.5-72B-Instruct")
29
+
30
+ agent = ToolCallingAgent(
31
+ tools=[webTool], model=model, max_steps=3
32
+ )
33
+
34
+ self.agent = agent
35
+
36
  print("BasicAgent initialized.")
37
+
38
  def __call__(self, question: str) -> str:
39
  print(f"Agent received question (first 50 chars): {question[:50]}...")
40
+
41
+ answer = agent.run(
42
+ "You must answer the question exactly, with a single word. For example: '4' or 'Paris'. The question is: "
43
+ + question
44
+ )
45
+
46
+ print(f"Agent returning fixed answer: {answer}")
47
+ return answer
48
 
49
  def run_and_submit_all( profile: gr.OAuthProfile | None):
50
  """