borisyich commited on
Commit
40f3543
·
verified ·
1 Parent(s): 03ecb26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -47
app.py CHANGED
@@ -1,27 +1,13 @@
 
1
  import os
2
  import gradio as gr
3
  import requests
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://agents-course-unit4-scoring.hf.space"
13
 
14
- # --- Basic Agent Definition ---
15
- # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
16
- class BasicAgent:
17
- def __init__(self):
18
- print("BasicAgent initialized.")
19
- def __call__(self, question: str) -> str:
20
- print(f"Agent received question (first 50 chars): {question[:50]}...")
21
- fixed_answer = "This is a default answer."
22
- print(f"Agent returning fixed answer: {fixed_answer}")
23
- return fixed_answer
24
-
25
  def run_and_submit_all( profile: gr.OAuthProfile | None):
26
  """
27
  Fetches all questions, runs the BasicAgent on them, submits all answers,
@@ -41,39 +27,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
41
  questions_url = f"{api_url}/questions"
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}")
 
1
+ import agent
2
  import os
3
  import gradio as gr
4
  import requests
5
  import inspect
 
 
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  def run_and_submit_all( profile: gr.OAuthProfile | None):
12
  """
13
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
27
  questions_url = f"{api_url}/questions"
28
  submit_url = f"{api_url}/submit"
29
 
 
 
 
 
30
  try:
31
+ agent = agent.BasicAgent()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  except Exception as e:
34
  print(f"Error instantiating agent: {e}")