Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
def greet(name):
|
|
@@ -11,16 +18,46 @@ demo.launch()
|
|
| 11 |
# Step 3: Integrate the Tool with Alfred
|
| 12 |
# Finally, let’s bring everything together by creating our agent and equipping it with our custom tool:
|
| 13 |
|
| 14 |
-
from smolagents import CodeAgent, InferenceClientModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Initialize the Hugging Face model
|
| 17 |
model = InferenceClientModel()
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
print("🎩 Alfred's Response:")
|
| 26 |
-
print(response)
|
|
|
|
|
|
| 1 |
+
# Import necessary libraries
|
| 2 |
+
import random
|
| 3 |
+
from smolagents import CodeAgent, InferenceClientModel
|
| 4 |
+
|
| 5 |
+
# Import our custom tools from their modules
|
| 6 |
+
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
|
| 7 |
+
|
| 8 |
import gradio as gr
|
| 9 |
|
| 10 |
def greet(name):
|
|
|
|
| 18 |
# Step 3: Integrate the Tool with Alfred
|
| 19 |
# Finally, let’s bring everything together by creating our agent and equipping it with our custom tool:
|
| 20 |
|
| 21 |
+
# from smolagents import CodeAgent, InferenceClientModel
|
| 22 |
+
|
| 23 |
+
# # Initialize the Hugging Face model
|
| 24 |
+
# model = InferenceClientModel()
|
| 25 |
+
|
| 26 |
+
# # Create Alfred, our gala agent, with the guest info tool
|
| 27 |
+
# alfred = CodeAgent(tools=[guest_info_tool, search_tool, weather_info_tool, hub_stats_tool, latest_news_tool], model=model)
|
| 28 |
+
|
| 29 |
+
# # Example query Alfred might receive during the gala
|
| 30 |
+
# response = alfred.run("What's the latest news about quantum computing?.")
|
| 31 |
+
|
| 32 |
+
# print("🎩 Alfred's Response:")
|
| 33 |
+
# print(response)
|
| 34 |
+
|
| 35 |
|
| 36 |
# Initialize the Hugging Face model
|
| 37 |
model = InferenceClientModel()
|
| 38 |
|
| 39 |
+
# Initialize the web search tool
|
| 40 |
+
search_tool = DuckDuckGoSearchTool()
|
| 41 |
+
|
| 42 |
+
# Initialize the weather tool
|
| 43 |
+
weather_info_tool = WeatherInfoTool()
|
| 44 |
|
| 45 |
+
# Initialize the Hub stats tool
|
| 46 |
+
hub_stats_tool = HubStatsTool()
|
| 47 |
+
|
| 48 |
+
# Load the guest dataset and initialize the guest info tool
|
| 49 |
+
guest_info_tool = load_guest_dataset()
|
| 50 |
+
|
| 51 |
+
# Create Alfred with all the tools
|
| 52 |
+
alfred = CodeAgent(
|
| 53 |
+
tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool],
|
| 54 |
+
model=model,
|
| 55 |
+
add_base_tools=True, # Add any additional base tools
|
| 56 |
+
planning_interval=3 # Enable planning every 3 steps
|
| 57 |
+
)
|
| 58 |
+
query = "I need to speak with Dr. Nikola Tesla about recent advancements in wireless energy. Can you help me prepare for this conversation?"
|
| 59 |
+
response = alfred.run(query)
|
| 60 |
|
| 61 |
print("🎩 Alfred's Response:")
|
| 62 |
+
print(response)
|
| 63 |
+
|