Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,8 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
-
from
|
7 |
-
from
|
8 |
-
from smolagents import CodeAgent, InferenceClientModel
|
9 |
|
10 |
# (Keep Constants as is)
|
11 |
# --- Constants ---
|
@@ -17,7 +16,9 @@ class BasicAgent:
|
|
17 |
def __init__(self):
|
18 |
print("BasicAgent initialized.")
|
19 |
# Initialize the Hugging Face model
|
20 |
-
|
|
|
|
|
21 |
|
22 |
# Initialize tools
|
23 |
search_tool = InternetSearchTool()
|
@@ -25,18 +26,19 @@ class BasicAgent:
|
|
25 |
excel_tool = ExcelTool()
|
26 |
media_tool = MediaTool()
|
27 |
wikipedia_tool = WikipediaTool()
|
|
|
28 |
|
29 |
# Create agent
|
30 |
self.agent= CodeAgent(
|
31 |
-
tools=[search_tool, webscraper_tool, excel_tool, media_tool, wikipedia_tool],
|
32 |
-
model=
|
33 |
add_base_tools=True, # Add any additional base tools
|
34 |
planning_interval=3, # Enable planning every 3 steps
|
35 |
max_steps=10
|
36 |
)
|
37 |
|
38 |
def summarize(self, question: str) -> str:
|
39 |
-
prompt = """You are an AI assistant for summarizing tasks. You will receive a long request message, your task is to make it shorter by removing irrelevant details. Do no attempt to find an answer to the request or any part of the request.
|
40 |
|
41 |
EXAMPLE:
|
42 |
'Hi, we've been learning about reptiles in biology and I'd like to know more about crocodiles. Can you tell me how many legs an average crocodile has? Please answer only with a number! Thanks in advance!'
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from tools import InternetSearchTool, WebscraperTool, ExcelTool, WikipediaTool, MediaTool, LiteLLMModel
|
7 |
+
from smolagents import CodeAgent, InferenceClientModel, PythonInterpreterTool
|
|
|
8 |
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
|
|
16 |
def __init__(self):
|
17 |
print("BasicAgent initialized.")
|
18 |
# Initialize the Hugging Face model
|
19 |
+
llm = LiteLLMModel(
|
20 |
+
model_id="gemini-2.0-flash", api_key=os.getenv("GEMINI_API_KEY")
|
21 |
+
)
|
22 |
|
23 |
# Initialize tools
|
24 |
search_tool = InternetSearchTool()
|
|
|
26 |
excel_tool = ExcelTool()
|
27 |
media_tool = MediaTool()
|
28 |
wikipedia_tool = WikipediaTool()
|
29 |
+
python_tool = PythonInterpreterTool()
|
30 |
|
31 |
# Create agent
|
32 |
self.agent= CodeAgent(
|
33 |
+
tools=[search_tool, webscraper_tool, excel_tool, media_tool, wikipedia_tool, python_tool],
|
34 |
+
model=llm,
|
35 |
add_base_tools=True, # Add any additional base tools
|
36 |
planning_interval=3, # Enable planning every 3 steps
|
37 |
max_steps=10
|
38 |
)
|
39 |
|
40 |
def summarize(self, question: str) -> str:
|
41 |
+
prompt = """You are an AI assistant for summarizing tasks. You will receive a long request message, your task is to make it shorter by removing irrelevant details. Do no attempt to find an answer to the request or any part of the request. Make sure to always include any requirement towards the answer's format in your summary.
|
42 |
|
43 |
EXAMPLE:
|
44 |
'Hi, we've been learning about reptiles in biology and I'd like to know more about crocodiles. Can you tell me how many legs an average crocodile has? Please answer only with a number! Thanks in advance!'
|