jc7k commited on
Commit
bd7c34c
·
verified ·
1 Parent(s): 295fd52

Switched to OpenAI model

Browse files
Files changed (1) hide show
  1. app.py +9 -2
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
- agent = ToolCallingAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
 
 
 
 
 
 
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: