earlzero commited on
Commit
7ad1074
·
1 Parent(s): 81917a3

smolagents

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +12 -3
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
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,17 @@ 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 CodeAgent, DuckDuckGoSearchTool,VisitWebpageTool, InferenceClientModel
8
+ # For reading files - https://docs.llamaindex.ai/en/stable/examples/data_connectors/DoclingReaderDemo/
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 = InferenceClientModel()
20
+ self.agent = CodeAgent(
21
+ model=model,
22
+ tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
23
+ )
24
  def __call__(self, question: str) -> str:
25
  print(f"Agent received question (first 50 chars): {question[:50]}...")
26
+ answer = self.agent.run(question)
27
+ # fixed_answer = "This is a default answer."
28
+ print(f"Agent returning fixed answer: {answer}")
29
+ return answer
30
 
31
  def run_and_submit_all( profile: gr.OAuthProfile | None):
32
  """