Andrew Nguyen commited on
Commit
5e3ef3d
·
1 Parent(s): 81917a3

Update space

Browse files
Files changed (2) hide show
  1. app.py +22 -2
  2. requirements.txt +13 -2
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 ---
@@ -12,10 +14,25 @@ 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
 
@@ -193,4 +210,7 @@ if __name__ == "__main__":
193
  print("-"*(60 + len(" App Starting ")) + "\n")
194
 
195
  print("Launching Gradio Interface for Basic Agent Evaluation...")
196
- demo.launch(debug=True, share=False)
 
 
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent, LiteLLMModel
7
+ from smolagents import DuckDuckGoSearchTool
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
 
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
  class BasicAgent:
16
  def __init__(self):
17
+ model = LiteLLMModel(model_id="gemini/gemini-2.0-flash",
18
+ api_key="AIzaSyBMxALkrYySCViP-bDiynko92w8AAv4M2o")
19
+
20
+ # Initialize the web search tool
21
+ search_tool = DuckDuckGoSearchTool()
22
+
23
+ # Create an agent with no tools
24
+ self.agent = CodeAgent(
25
+ tools=[search_tool],
26
+ model=model,
27
+ add_base_tools=True,
28
+ planning_interval=3
29
+ )
30
+
31
  print("BasicAgent initialized.")
32
+
33
  def __call__(self, question: str) -> str:
34
  print(f"Agent received question (first 50 chars): {question[:50]}...")
35
+ fixed_answer = self.agent.run(question)
36
  print(f"Agent returning fixed answer: {fixed_answer}")
37
  return fixed_answer
38
 
 
210
  print("-"*(60 + len(" App Starting ")) + "\n")
211
 
212
  print("Launching Gradio Interface for Basic Agent Evaluation...")
213
+ demo.launch(debug=True, share=False)
214
+ print("Gradio Interface launched successfully.")
215
+ print("You can now interact with the Basic Agent Evaluation Runner.")
216
+ print("Please follow the instructions in the interface to run your agent and submit answers.")
requirements.txt CHANGED
@@ -1,2 +1,13 @@
1
- gradio
2
- requests
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Authlib==1.6.0
2
+ duckduckgo_search==8.0.4
3
+ fastapi==0.115.13
4
+ gradio==5.34.2
5
+ gradio_client==1.10.3
6
+ huggingface-hub==0.33.0
7
+ litellm==1.73.1
8
+ numpy
9
+ openai
10
+ pandas
11
+ pydantic
12
+ requests
13
+ smolagents