Spaces:
Sleeping
Sleeping
Switched to OpenAI model
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
-
from smolagents import ToolCallingAgent, HfApiModel, DuckDuckGoSearchTool
|
7 |
|
8 |
|
9 |
# (Keep Constants as is)
|
@@ -16,8 +16,15 @@ class BasicAgent:
|
|
16 |
def __init__(self):
|
17 |
print("BasicAgent initialized.")
|
18 |
# Initialize the agent with a model and tools
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
self.agent = agent
|
|
|
21 |
print(f"Agent initialized with tools: {self.agent.tools}")
|
22 |
|
23 |
def __call__(self, question: str) -> str:
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import OpenAIServerModel, ToolCallingAgent, HfApiModel, DuckDuckGoSearchTool
|
7 |
|
8 |
|
9 |
# (Keep Constants as is)
|
|
|
16 |
def __init__(self):
|
17 |
print("BasicAgent initialized.")
|
18 |
# Initialize the agent with a model and tools
|
19 |
+
|
20 |
+
model = OpenAIServerModel(
|
21 |
+
model_id=os.environ["MODEL_ID"],
|
22 |
+
api_base="https://api.openai.com/v1",
|
23 |
+
api_key=os.environ["OPENAI_API_KEY"],
|
24 |
+
)
|
25 |
+
agent = ToolCallingAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
26 |
self.agent = agent
|
27 |
+
print(f"Agent initialized with model ID: {os.environ['MODEL_ID']}")
|
28 |
print(f"Agent initialized with tools: {self.agent.tools}")
|
29 |
|
30 |
def __call__(self, question: str) -> str:
|