Ventahana commited on
Commit
8db72d0
·
verified ·
1 Parent(s): abb91c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -11
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
- # Simple function that uses your tool
6
- def get_guest_info(guest_name):
7
- return guest_info_tool.forward(guest_name)
8
 
9
- # Create Gradio interface (keeps app running)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  demo = gr.Interface(
11
- fn=get_guest_info,
12
- inputs=gr.Textbox(label="Guest Name", value="Lady Ada Lovelace"),
13
- outputs=gr.Textbox(label="Guest Information"),
14
- title="🎩 Gala Guest Information",
15
- description="Enter a guest name to get their information"
 
 
 
 
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)