File size: 1,802 Bytes
be6f51b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
import gradio as gr
import random
from smolagents import CodeAgent, DuckDuckGoSearchTool, LiteLLMModel
from langchain_ollama import ChatOllama

# Import our custom tools from their modules
from tools import WeatherInfoTool, HubStatsTool
from retriever import load_guest_dataset

# Initialize the Hugging Face model
model = LiteLLMModel(
    model_id="ollama_chat/qwen2.5-coder:7b", 
    api_base="http://localhost:xxxx",
    temperature=0
)

# 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, search_tool, hub_stats_tool, weather_info_tool], model=model)

if __name__ == "__main__":
    # query = "Tell me about 'Lady Ada Lovelace'"
    # query = "What's the weather like in Paris tonight? Will it be suitable for our fireworks display?"
    # query = "One of our guests is from Qwen. What can you tell me about their most popular model?"
    query = "I need to speak with Dr. Nikola Tesla about recent advancements in wireless energy. Can you help me prepare for this conversation?"

    # First interaction
    # response1 = alfred_with_memory.run("Tell me about Lady Ada Lovelace.")
    # print("🎩 Alfred's First Response:")
    # print(response1)

    # # Second interaction (referencing the first)
    # response2 = alfred_with_memory.run("What projects is she currently working on?", reset=False)
    # print("🎩 Alfred's Second Response:")
    # print(response2)

    response = alfred.run(query)
    print("🎩 Alfred's Response:")
    print(response)