| import gradio as gr |
| import random |
| import os |
| import getpass |
| from smolagents import GradioUI, CodeAgent, HfApiModel |
|
|
| |
| from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool, CrashInfoRetrieverTool |
| from retriever import load_guest_dataset, load_crash_data |
|
|
| |
| |
|
|
| |
| hf_token = os.getenv("HF_TOKEN") |
| if not hf_token: |
| raise ValueError("HF_TOKEN environment variable is not set.") |
|
|
| |
| model = HfApiModel() |
|
|
| |
| search_tool = DuckDuckGoSearchTool() |
|
|
| |
| weather_info_tool = WeatherInfoTool() |
|
|
| |
| hub_stats_tool = HubStatsTool() |
|
|
| |
| guest_info_tool = load_guest_dataset() |
|
|
| crash_info_tool = load_crash_data() |
|
|
| |
| alfred = CodeAgent( |
| tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool, crash_info_tool], |
| model=model, |
| add_base_tools=True, |
| planning_interval=3 |
| |
| ) |
|
|
| if __name__ == "__main__": |
| GradioUI(alfred).launch() |