File size: 1,288 Bytes
e44cbb4
1f51f06
e44cbb4
1f51f06
e44cbb4
1f51f06
 
e44cbb4
 
 
1f51f06
e44cbb4
 
1f51f06
e44cbb4
 
 
 
1f51f06
 
e44cbb4
1f51f06
 
e44cbb4
1f51f06
 
e44cbb4
1f51f06
 
 
 
e44cbb4
 
 
 
1f51f06
 
e44cbb4
 
 
 
 
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
# Import necessary libraries
import random
from smolagents import CodeAgent, InferenceClientModel

# Import our custom tools from their modules
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
from retriever import load_guest_dataset
from dotenv import load_dotenv
import os
load_dotenv()

# Load the Hugging Face API key from environment variables
api_key = os.getenv("HUGGINGFACE_API_KEY")

# Initialize the Hugging Face model
model = InferenceClientModel(token=api_key)

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

query = "I need to speak with Dr. Nikola Tesla about recent advancements in wireless energy. Can you help me prepare for this conversation?"
response = alfred.run(query)

print("🎩 Alfred's Response:")
print(response)