File size: 1,475 Bytes
46e545b
03a35f8
ef6bb1a
 
9364285
ef6bb1a
 
 
46e545b
9364285
 
 
ef6bb1a
 
46e545b
ef6bb1a
 
46e545b
ef6bb1a
 
46e545b
ef6bb1a
 
46e545b
ef6bb1a
 
46e545b
ef6bb1a
 
46e545b
ef6bb1a
 
 
 
 
 
46e545b
 
ef6bb1a
 
 
 
 
 
 
 
46e545b
 
ef6bb1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gradio as gr
import os
import random
from smolagents import GradioUI, CodeAgent, HfApiModel
from dotenv import load_dotenv
# Import our custom tools from their modules
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool, GetLatestNewsTool
from retriever import load_guest_dataset

load_dotenv()
hf_token = os.getenv("HF_TOKEN")

# Initialize the Hugging Face model
model = HfApiModel()

# 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()

# Initialize the News tool
get_latest_news_tool = GetLatestNewsTool()

# 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, get_latest_news_tool], 
    model=model,
    add_base_tools=True,  # Add any additional base tools
    planning_interval=3   # Enable planning every 3 steps
)

alfred_with_memory = CodeAgent(
    tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool, get_latest_news_tool], 
    model=model,
    add_base_tools=True,  # Add any additional base tools
    planning_interval=3,   # Enable planning every 3 steps
    #memory=True            # Enable memory
)
# Initialize the Gradio UI

if __name__ == "__main__":
    GradioUI(alfred).launch()