APRG commited on
Commit
39c6ab5
·
verified ·
1 Parent(s): c4feb4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
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 GradioUI, CodeAgent, HfApiModel
7
  from tools import DuckDuckGoSearchTool, WeatherInfoTool
8
 
9
  # (Keep Constants as is)
@@ -16,7 +16,7 @@ class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
  # Initialize the Hugging Face model
19
- model = HfApiModel()
20
 
21
  # Initialize the web search tool
22
  search_tool = DuckDuckGoSearchTool()
@@ -25,16 +25,18 @@ class BasicAgent:
25
  weather_info_tool = WeatherInfoTool()
26
 
27
  # Create agent
28
- self.agent= CodeAgent(
29
- tools=[weather_info_tool, search_tool],
30
- model=model,
31
- add_base_tools=True, # Add any additional base tools
32
- planning_interval=3 # Enable planning every 3 steps
33
- )
 
 
34
 
35
  def __call__(self, question: str) -> str:
36
  print(f"Agent received question (first 50 chars): {question[:50]}...")
37
- answer = self.agent.run(question)
38
  print(f"Agent returning fixed answer: {fixed_answer}")
39
  return answer
40
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from langchain_google_genai import ChatGoogleGenerativeAI
7
  from tools import DuckDuckGoSearchTool, WeatherInfoTool
8
 
9
  # (Keep Constants as is)
 
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
  # Initialize the Hugging Face model
19
+ model = ChatGoogleGenerativeAI(model="gemini-1.5-flash-latest")
20
 
21
  # Initialize the web search tool
22
  search_tool = DuckDuckGoSearchTool()
 
25
  weather_info_tool = WeatherInfoTool()
26
 
27
  # Create agent
28
+ tools = [search_tool, weather_info_tool]
29
+ self.agent= llm.bind_tools(tools)
30
+ #= CodeAgent(
31
+ # tools=[weather_info_tool, search_tool],
32
+ # model=model,
33
+ # add_base_tools=True, # Add any additional base tools
34
+ # planning_interval=3 # Enable planning every 3 steps
35
+ #)
36
 
37
  def __call__(self, question: str) -> str:
38
  print(f"Agent received question (first 50 chars): {question[:50]}...")
39
+ answer = self.agent.invoke(question)
40
  print(f"Agent returning fixed answer: {fixed_answer}")
41
  return answer
42