kschuette commited on
Commit
82a9656
·
verified ·
1 Parent(s): 8d36d0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -3,8 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
7
- from llama_index.core.agent.workflow import AgentWorkflow, ToolCallResult, AgentStream
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
@@ -12,8 +11,13 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
  # --- Basic Agent Definition ---
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
 
 
15
  class BasicAgent:
16
  def __init__(self):
 
17
  print("BasicAgent initialized.")
18
  def __call__(self, question: str) -> str:
19
  print(f"Agent received question (first 50 chars): {question[:50]}...")
@@ -61,17 +65,19 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
61
 
62
  # 1. Instantiate Agent ( modify this part to create your agent)
63
  try:
64
- llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")
65
 
66
- agent = AgentWorkflow.from_tools_or_functions(
67
- tools_or_functions=[subtract, multiply, divide, add],
68
- llm=llm,
69
- system_prompt="You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: \
70
- FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. \
71
- If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. \
72
- If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. \
73
- If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.",
74
- )
 
 
75
  except Exception as e:
76
  print(f"Error instantiating agent: {e}")
77
  return f"Error initializing agent: {e}", None
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, FinalAnswerTool, HfApiModel
 
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
11
 
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
+ model = HfApiModel(
15
+ model_id="Qwen/Qwen3-235B-A22B"
16
+ )
17
+
18
  class BasicAgent:
19
  def __init__(self):
20
+ self.agent = CodeAgent(tools=[DuckDuckGoSearchTool(),subtract, multiply, divide, add], model=model)
21
  print("BasicAgent initialized.")
22
  def __call__(self, question: str) -> str:
23
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
65
 
66
  # 1. Instantiate Agent ( modify this part to create your agent)
67
  try:
68
+ agent = BasicAgent()
69
 
70
+ #llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")
71
+ #
72
+ # agent = AgentWorkflow.from_tools_or_functions(
73
+ # tools_or_functions=[subtract, multiply, divide, add],
74
+ # llm=llm,
75
+ # system_prompt="You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: \
76
+ # FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. \
77
+ # If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. \
78
+ # If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. \
79
+ # If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.",
80
+ # )
81
  except Exception as e:
82
  print(f"Error instantiating agent: {e}")
83
  return f"Error initializing agent: {e}", None