henryk commited on
Commit
69b55af
·
verified ·
1 Parent(s): 81917a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -10,14 +10,30 @@ 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
  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
  """
 
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
+ from smolagents import CodeAgent, HfApiModel
14
+ from tools.wikipedia_tool import WikipediaTool
15
+ from tools.text_transformer_tool import TextTransformerTool
16
+
17
  class BasicAgent:
18
  def __init__(self):
19
+ print("Initializing BasicAgent with tools...")
20
+
21
+ model = HfApiModel()
22
+ wiki_tool = WikipediaTool()
23
+ text_tool = TextTransformerTool()
24
+
25
+ self.agent = CodeAgent(
26
+ model=model,
27
+ tools=[wiki_tool, text_tool],
28
+ add_base_tools=True,
29
+ planning_interval=2
30
+ )
31
+
32
  def __call__(self, question: str) -> str:
33
  print(f"Agent received question (first 50 chars): {question[:50]}...")
34
+ answer = self.agent(question)
35
+ print(f"Agent returning answer: {answer}")
36
+ return answer
37
 
38
  def run_and_submit_all( profile: gr.OAuthProfile | None):
39
  """