borisyich commited on
Commit
b4c613f
·
verified ·
1 Parent(s): 52f120c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -2
app.py CHANGED
@@ -4,9 +4,12 @@ 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"
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
@@ -39,8 +42,39 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
39
  submit_url = f"{api_url}/submit"
40
 
41
  # 1. Instantiate Agent ( modify this part to create your agent)
 
 
 
42
  try:
43
- agent = BasicAgent()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  except Exception as e:
45
  print(f"Error instantiating agent: {e}")
46
  return f"Error initializing agent: {e}", None
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from smolagents import InferenceClientModel, CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool, VisitWebpageTool
8
+
9
+
10
  # (Keep Constants as is)
11
  # --- Constants ---
12
+ DEFAULT_API_URL = "https://huggingface.co/spaces/borisyich/Final_Assignment"
13
 
14
  # --- Basic Agent Definition ---
15
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
42
  submit_url = f"{api_url}/submit"
43
 
44
  # 1. Instantiate Agent ( modify this part to create your agent)
45
+ model_id = "Qwen/Qwen2.5-72B-Instruct"
46
+ model = InferenceClientModel(model_id)
47
+
48
  try:
49
+ web_agent = ToolCallingAgent(
50
+ tools=[DuckDuckGoSearchTool(), VisitWebpageTool()], model=model,
51
+ name="search_agent",
52
+ description="Runs web searches for you. Give it your query as an argument.",
53
+ )
54
+ python_agent = CodeAgent(
55
+ tools=[],
56
+ model=model,
57
+ name='python_agent',
58
+ description='Use additional_authorized_imports for you. You need to do actions and help to answer the questions with python code',
59
+ additional_authorized_imports=[
60
+ "json",
61
+ "pandas",
62
+ "numpy",
63
+ "requests",
64
+ "time",
65
+ "datetime",
66
+ ],
67
+ planning_interval=5,
68
+ verbosity_level=2,
69
+ final_answer_checks=[check_reasoning_and_plot],
70
+ max_steps=15,
71
+ )
72
+ agent = CodeAgent(tools=[],
73
+ model=model,
74
+ managed_agents=[web_agent, python_agent],
75
+ additional_authorized_imports=["requests"],
76
+ )
77
+
78
  except Exception as e:
79
  print(f"Error instantiating agent: {e}")
80
  return f"Error initializing agent: {e}", None