keynes42 commited on
Commit
c32b2ea
·
verified ·
1 Parent(s): d165818

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from smolagents import CodeAgent, HfApiModel
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
@@ -14,11 +14,25 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
  class BasicAgent:
15
  def __init__(self):
16
  print("BasicAgent initialized.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  def __call__(self, question: str) -> str:
18
  print(f"Agent received question (first 50 chars): {question[:50]}...")
19
- fixed_answer = "This is a default answer."
20
- print(f"Agent returning fixed answer: {fixed_answer}")
21
- return fixed_answer
22
 
23
  def run_and_submit_all( profile: gr.OAuthProfile | None):
24
  """
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, HfApiModel
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
14
  class BasicAgent:
15
  def __init__(self):
16
  print("BasicAgent initialized.")
17
+
18
+ # Initialize the model
19
+ model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct")
20
+
21
+ # Initialize the tools other than the base tools
22
+ # See list of base tools in https://github.com/huggingface/smolagents/blob/main/src/smolagents/default_tools.py
23
+
24
+ # Initialize the agent
25
+ self.agent = CodeAgent(
26
+ model=model,
27
+ tool=[],
28
+ add_base_tools=True
29
+ )
30
+
31
  def __call__(self, question: str) -> str:
32
  print(f"Agent received question (first 50 chars): {question[:50]}...")
33
+ response = self.agent.run(question)
34
+ print(f"Agent returning its generated answer: {response}")
35
+ return response
36
 
37
  def run_and_submit_all( profile: gr.OAuthProfile | None):
38
  """