Skip to content

Commit 29dfe4b

Browse files
committed
Add Gradio UI for Airbnb Booking Assistant
- Introduced a new Gradio interface in `airbnb.mdx` and `ui.py` for searching and booking apartments on Airbnb. - Implemented the `search_airbnb` function to handle user queries and display results. - Enhanced user experience with a clear input prompt and structured output format.
1 parent b4cc3d7 commit 29dfe4b

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

docs/mcp/airbnb.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,33 @@ flowchart LR
6767
- OpenAI API key (for the agent's LLM)
6868
</Note>
6969

70+
## Gradio UI
71+
72+
```python
73+
from praisonaiagents import Agent, MCP
74+
import gradio as gr
75+
76+
def search_airbnb(query):
77+
agent = Agent(
78+
instructions="You help book apartments on Airbnb.",
79+
llm="gpt-4o-mini",
80+
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
81+
)
82+
result = agent.start(query)
83+
return f"## Airbnb Search Results\n\n{result}"
84+
85+
demo = gr.Interface(
86+
fn=search_airbnb,
87+
inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
88+
outputs=gr.Markdown(),
89+
title="Airbnb Booking Assistant",
90+
description="Enter your booking requirements below:"
91+
)
92+
93+
if __name__ == "__main__":
94+
demo.launch()
95+
```
96+
7097
## Features
7198

7299
<CardGroup cols={2}>

src/praisonai-agents/ui.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from praisonaiagents import Agent, MCP
2+
import gradio as gr
3+
4+
def search_airbnb(query):
5+
agent = Agent(
6+
instructions="You help book apartments on Airbnb.",
7+
llm="gpt-4o-mini",
8+
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
9+
)
10+
result = agent.start(query)
11+
return f"## Airbnb Search Results\n\n{result}"
12+
13+
demo = gr.Interface(
14+
fn=search_airbnb,
15+
inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
16+
outputs=gr.Markdown(),
17+
title="Airbnb Booking Assistant",
18+
description="Enter your booking requirements below:"
19+
)
20+
21+
if __name__ == "__main__":
22+
demo.launch()

0 commit comments

Comments
 (0)