Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,45 @@
|
|
| 1 |
-
# app.py - KEEPS APP ALIVE
|
| 2 |
import gradio as gr
|
| 3 |
from retriever import guest_info_tool
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
demo = gr.Interface(
|
| 11 |
-
fn=
|
| 12 |
-
inputs=gr.Textbox(label="
|
| 13 |
-
outputs=gr.Textbox(label="
|
| 14 |
-
title="🎩 Gala
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
-
# Launch and keep running
|
| 19 |
if __name__ == "__main__":
|
| 20 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from retriever import guest_info_tool
|
| 3 |
+
from tools import all_tools
|
| 4 |
|
| 5 |
+
# Combine all tools
|
| 6 |
+
all_agent_tools = [guest_info_tool] + all_tools
|
| 7 |
+
print(f"✅ Loaded {len(all_agent_tools)} tools")
|
| 8 |
|
| 9 |
+
def ask_alfred(query):
|
| 10 |
+
"""Try each tool until one works"""
|
| 11 |
+
# Try RAG tool first
|
| 12 |
+
if any(word in query.lower() for word in ['ada', 'lovelace', 'tesla', 'guest', 'gala']):
|
| 13 |
+
result = guest_info_tool.forward(query)
|
| 14 |
+
return f"🎩 Guest Info:\n{result}"
|
| 15 |
+
|
| 16 |
+
# Try other tools
|
| 17 |
+
for tool in all_tools:
|
| 18 |
+
try:
|
| 19 |
+
if tool.name == "weather_info_tool" and "weather" in query.lower():
|
| 20 |
+
location = query.split()[-1] if len(query.split()) > 1 else "Paris"
|
| 21 |
+
return tool.forward(location)
|
| 22 |
+
elif tool.name == "hub_stats_tool" and any(word in query.lower() for word in ['facebook', 'model', 'huggingface']):
|
| 23 |
+
return tool.forward("facebook")
|
| 24 |
+
elif tool.name == "search_tool":
|
| 25 |
+
return tool.forward(query)
|
| 26 |
+
except:
|
| 27 |
+
continue
|
| 28 |
+
|
| 29 |
+
return "I can help with guest info, weather, or HuggingFace models!"
|
| 30 |
+
|
| 31 |
+
# Gradio interface
|
| 32 |
demo = gr.Interface(
|
| 33 |
+
fn=ask_alfred,
|
| 34 |
+
inputs=gr.Textbox(label="Ask Alfred about gala guests"),
|
| 35 |
+
outputs=gr.Textbox(label="Alfred's Response", lines=10),
|
| 36 |
+
title="🎩 Alfred's Gala Assistant",
|
| 37 |
+
examples=[
|
| 38 |
+
["Tell me about Lady Ada Lovelace"],
|
| 39 |
+
["What's the weather in Tokyo?"],
|
| 40 |
+
["What is Facebook's most popular model?"]
|
| 41 |
+
]
|
| 42 |
)
|
| 43 |
|
|
|
|
| 44 |
if __name__ == "__main__":
|
| 45 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|