uuidenny's picture
Update app.py
a2eca9e verified
raw
history blame
1.21 kB
import gradio as gr
import random
from smolagents import GradioUI, CodeAgent, HfApiModel, LiteLLMModel
# Import our custom tools from their modules
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
from retriever import load_guest_dataset
#model = HfApiModel(
# max_tokens=2096,
# temperature=0,
# model_id='mistralai/Mistral-7B-Instruct-v0.3',
# custom_role_conversions=None,
#)
hf_api = HfApi()
secrets = hf_api.get_secrets()
model = LiteLLMModel(
model_id="gemini/gemini-2.0-flash-lite",
api_key=secrets.get("GEMINI_API_TOKEN")
)
# Initialize the web search tool
search_tool = DuckDuckGoSearchTool()
# Initialize the weather tool
weather_info_tool = WeatherInfoTool()
# Initialize the Hub stats tool
hub_stats_tool = HubStatsTool()
# Load the guest dataset and initialize the guest info tool
guest_info_tool = load_guest_dataset()
# Create Alfred with all the tools
alfred = CodeAgent(
tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool],
model=model,
add_base_tools=True, # Add any additional base tools
planning_interval=3 # Enable planning every 3 steps
)
if __name__ == "__main__":
GradioUI(alfred).launch()