Albannach58 commited on
Commit
747412c
·
verified ·
1 Parent(s): 07fd17d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import gradio as gr
3
  import requests
@@ -10,17 +11,25 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
  # --- Basic Agent Definition ---
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
- n = 50
18
- if (question.startswith("How many studio albums were published by Mercedes")):
19
- n = len(question)
20
- print(f"Agent received question (first 50 chars): {question[:n]}...")
21
- fixed_answer = "This is a default answer."
22
- print(f"Agent returning fixed answer: {fixed_answer}")
23
- return fixed_answer
 
 
 
 
24
 
25
  def run_and_submit_all( profile: gr.OAuthProfile | None):
26
  """
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
2
  import os
3
  import gradio as gr
4
  import requests
 
11
 
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
+ model = HfApiModel()
15
+ tools = [DuckDuckGoSearchTool()]
16
+
17
  class BasicAgent:
18
  def __init__(self):
19
+ self = CodeAgent(tools=tools, model=model, additional_authorized_imports=["requests", "bs4"])
20
+ print("BasicAgent initialized as CodeAgent.")
21
  def __call__(self, question: str) -> str:
22
+ # Run the agent with the query
23
+ print(question)
24
+ result = self.run(question)
25
+ return result
26
+ # n = 50
27
+ # if (question.startswith("How many studio albums were published by Mercedes")):
28
+ # n = len(question)
29
+ # print(f"Agent received question (first 50 chars): {question[:n]}...")
30
+ # fixed_answer = "This is a default answer."
31
+ # print(f"Agent returning fixed answer: {fixed_answer}")
32
+ # return fixed_answer
33
 
34
  def run_and_submit_all( profile: gr.OAuthProfile | None):
35
  """