dlaima commited on
Commit
3ee26eb
·
verified ·
1 Parent(s): 517dc2d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ #from smolagents import GradioUI, CodeAgent, HfApiModel
4
+ from smolagents import GradioUI, CodeAgent, OpenAIServerModel
5
+
6
+
7
+ # Import our custom tools from their modules
8
+ #from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
9
+ from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool, NewsSearchTool
10
+ from retriever import load_guest_dataset
11
+
12
+ # Initialize the Hugging Face model
13
+ #model = HfApiModel()
14
+ model = OpenAIServerModel(model_id="gpt-4o")
15
+
16
+ # Initialize the web search tool
17
+ search_tool = DuckDuckGoSearchTool()
18
+
19
+ # Initialize the weather tool
20
+ weather_info_tool = WeatherInfoTool()
21
+
22
+ # Initialize the Hub stats tool
23
+ hub_stats_tool = HubStatsTool()
24
+
25
+ # Initialize the news tool
26
+ news_tool = NewsSearchTool(api_key="CONTEXTUALWEB_API_KEY")
27
+
28
+ # Load the guest dataset and initialize the guest info tool
29
+ guest_info_tool = load_guest_dataset()
30
+
31
+ # Create Alfred with all the tools
32
+ alfred = CodeAgent(
33
+ #tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool],
34
+ tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool, news_tool],
35
+ model=model,
36
+ add_base_tools=True, # Add any additional base tools
37
+ planning_interval=3 # Enable planning every 3 steps
38
+ )
39
+
40
+ if __name__ == "__main__":
41
+ GradioUI(alfred).launch()