lodist commited on
Commit
51f28fb
·
verified ·
1 Parent(s): c0d8b62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -3,22 +3,31 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, PythonInterpreterTool, OpenAIServerModel
 
 
 
 
7
 
8
- # (Keep Constants as is)
9
- # --- Constants ---
10
- DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
 
12
  def get_hf_model():
 
13
  return HfApiModel(
14
- model_id="HuggingFaceH4/zephyr-7b-beta",
15
  api_key=HF_TOKEN,
16
  max_new_tokens=1024,
17
  temperature=0.2,
18
  timeout=120,
19
  )
20
 
21
- MODEL = get_hf_model()
 
 
 
 
 
22
 
23
  class BasicAgent:
24
  def __init__(self):
@@ -26,11 +35,14 @@ class BasicAgent:
26
  tools=[
27
  DuckDuckGoSearchTool(),
28
  PythonInterpreterTool(),
 
 
 
29
  ],
30
  model=MODEL,
31
- max_steps=10
32
  )
33
- print("BasicAgent initialized (smolagents).")
34
 
35
  def __call__(self, question: str, taskid: str) -> str:
36
  prompt = f"""
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, PythonInterpreterTool, OpenAIServerModel, HfApiModel
7
+ from agentsTools.toolVisitWebpage import visit_webpage
8
+ from agentsTools.tool_fetch_task_file import fetch_task_file
9
+ from agentsTools.tool_read_excel_as_json import read_excel_as_json
10
+ import os
11
 
12
+ # Get Hugging Face API token from environment
13
+ HF_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
 
14
 
15
  def get_hf_model():
16
+ """Return a Hugging Face Inference API model."""
17
  return HfApiModel(
18
+ model_id="HuggingFaceH4/zephyr-7b-beta", # or mistralai/Mistral-7B-Instruct-v0.2
19
  api_key=HF_TOKEN,
20
  max_new_tokens=1024,
21
  temperature=0.2,
22
  timeout=120,
23
  )
24
 
25
+ MODEL = get_hf_model()
26
+
27
+ # (Keep Constants as is)
28
+ # --- Constants ---
29
+ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
30
+
31
 
32
  class BasicAgent:
33
  def __init__(self):
 
35
  tools=[
36
  DuckDuckGoSearchTool(),
37
  PythonInterpreterTool(),
38
+ visit_webpage,
39
+ fetch_task_file,
40
+ read_excel_as_json,
41
  ],
42
  model=MODEL,
43
+ max_steps=10,
44
  )
45
+ print("BasicAgent initialized (Hugging Face model).")
46
 
47
  def __call__(self, question: str, taskid: str) -> str:
48
  prompt = f"""