jerry1979 commited on
Commit
efa26b2
·
verified ·
1 Parent(s): 5dcb2d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -33
app.py CHANGED
@@ -1,33 +1,19 @@
1
- import gradio as gr
2
- import random
3
- from smolagents import GradioUI, CodeAgent, HfApiModel
4
-
5
- # Import our custom tools from their modules
6
- from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
7
- from retriever import load_guest_dataset
8
-
9
- # Initialize the Hugging Face model
10
- model = HfApiModel()
11
-
12
- # Initialize the web search tool
13
- search_tool = DuckDuckGoSearchTool()
14
-
15
- # Initialize the weather tool
16
- weather_info_tool = WeatherInfoTool()
17
-
18
- # Initialize the Hub stats tool
19
- hub_stats_tool = HubStatsTool()
20
-
21
- # Load the guest dataset and initialize the guest info tool
22
- guest_info_tool = load_guest_dataset()
23
-
24
- # Create Alfred with all the tools
25
- alfred = CodeAgent(
26
- tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool],
27
- model=model,
28
- add_base_tools=True, # Add any additional base tools
29
- planning_interval=3 # Enable planning every 3 steps
30
- )
31
-
32
- if __name__ == "__main__":
33
- GradioUI(alfred).launch()
 
1
+ import datasets
2
+ from langchain_core.documents import Document
3
+
4
+ # Load the dataset
5
+ guest_dataset = datasets.load_dataset("agents-course/unit3-invitees", split="train")
6
+
7
+ # Convert dataset entries into Document objects
8
+ docs = [
9
+ Document(
10
+ page_content="\n".join([
11
+ f"Name: {guest['name']}",
12
+ f"Relation: {guest['relation']}",
13
+ f"Description: {guest['description']}",
14
+ f"Email: {guest['email']}"
15
+ ]),
16
+ metadata={"name": guest["name"]}
17
+ )
18
+ for guest in guest_dataset
19
+ ]