Add Gradio UI for Airbnb Booking Assistant#434
Conversation
- 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.
|
Caution Review failedThe pull request is closed. WalkthroughThe changes add a new Airbnb search feature using Gradio. Both the documentation and a new source module now define a Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant G as Gradio Interface
participant F as search_airbnb Function
participant A as Agent
U->>G: Enter search query
G->>F: Call search_airbnb(query)
F->>A: Initialize Agent with Airbnb instructions
A-->>F: Return formatted results
F->>G: Provide output (Markdown format)
G->>U: Display Airbnb search results
Poem
π Recent review detailsConfiguration used: CodeRabbit UI π Files selected for processing (2)
β¨ Finishing Touches
πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hello @MervinPraison, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces a Gradio UI for an Airbnb booking assistant. It adds a new interface in airbnb.mdx and ui.py that allows users to search and book apartments on Airbnb using a natural language query. The search_airbnb function is implemented to handle user input and display the search results in a markdown format.
Highlights
- New UI: Introduces a Gradio UI for searching and booking apartments on Airbnb.
- Function Implementation: Implements the
search_airbnbfunction to process user queries and display results. - Enhanced UX: Enhances user experience with a clear input prompt and structured output format.
Changelog
- docs/mcp/airbnb.mdx
- Added a Gradio UI section with a Python code snippet to demonstrate the Airbnb booking assistant.
- The UI includes a text input for user queries and a markdown output to display search results.
- The code uses the
praisonaiagentslibrary for agent and MCP functionalities andgradiofor the UI.
- src/praisonai-agents/ui.py
- Created a new file
ui.pycontaining the Gradio UI implementation for the Airbnb booking assistant. - The file includes the
search_airbnbfunction and the Gradio interface setup. - It uses the
AgentandMCPclasses from thepraisonaiagentslibrary and thegradiolibrary for the UI.
- Created a new file
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with π and π on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A user's wish, a booking's quest,
Gradio's UI, puts code to the test.
With agents smart, and queries clear,
Airbnb results, banish all fear.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. β©
There was a problem hiding this comment.
Code Review
This pull request introduces a Gradio UI for an Airbnb booking assistant, which is a great addition to the project. The code is well-structured and easy to understand. However, there are a few areas that could be improved to enhance maintainability and user experience.
Summary of Findings
- Error Handling: The code lacks explicit error handling. Consider adding error handling to gracefully manage potential issues during agent initialization or API calls.
- Configuration: The LLM and tool configurations are hardcoded. Consider making these configurable via environment variables or a configuration file.
- Code Duplication: The Gradio UI code is duplicated in
airbnb.mdxandui.py. Consider creating a reusable function or module to avoid duplication.
Merge Readiness
The pull request introduces a valuable feature, but it's not quite ready for merging. Addressing the error handling, configuration, and code duplication issues would significantly improve the code's quality and maintainability. I am unable to approve this pull request, and recommend that the author address the above points before merging.
| from praisonaiagents import Agent, MCP | ||
| import gradio as gr | ||
|
|
||
| def search_airbnb(query): | ||
| agent = Agent( | ||
| instructions="You help book apartments on Airbnb.", | ||
| llm="gpt-4o-mini", | ||
| tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt") | ||
| ) | ||
| result = agent.start(query) | ||
| return f"## Airbnb Search Results\n\n{result}" | ||
|
|
||
| demo = gr.Interface( | ||
| fn=search_airbnb, | ||
| inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."), | ||
| outputs=gr.Markdown(), | ||
| title="Airbnb Booking Assistant", | ||
| description="Enter your booking requirements below:" | ||
| ) | ||
|
|
||
| if __name__ == "__main__": | ||
| demo.launch() No newline at end of file |
There was a problem hiding this comment.
The Gradio UI code is duplicated in airbnb.mdx and ui.py. Consider creating a reusable function or module to avoid duplication and improve maintainability. You can define the search_airbnb function and Gradio interface in a separate module and import it into both files.
# In a new file, e.g., gradio_app.py:
# def create_gradio_app():
# from praisonaiagents import Agent, MCP
# import gradio as gr
#
# def search_airbnb(query):
# agent = Agent(
# instructions="You help book apartments on Airbnb.",
# llm="gpt-4o-mini",
# tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
# )
# result = agent.start(query)
# return f"## Airbnb Search Results\n\n{result}"
#
# demo = gr.Interface(
# fn=search_airbnb,
# inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
# outputs=gr.Markdown(),
# title="Airbnb Booking Assistant",
# description="Enter your booking requirements below:"
# )
# return demo
# if __name__ == "__main__":
# demo = create_gradio_app()
# demo.launch()
# Then, in both airbnb.mdx and ui.py:
# from gradio_app import create_gradio_app
# demo = create_gradio_app()
# if __name__ == "__main__":
# demo.launch()| def search_airbnb(query): | ||
| agent = Agent( | ||
| instructions="You help book apartments on Airbnb.", | ||
| llm="gpt-4o-mini", | ||
| tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt") | ||
| ) | ||
| result = agent.start(query) | ||
| return f"## Airbnb Search Results\n\n{result}" |
There was a problem hiding this comment.
Consider adding error handling to gracefully manage potential issues during agent initialization or API calls. For example, wrap the agent.start(query) call in a try...except block to catch exceptions and display an error message to the user.
try:
result = agent.start(query)
except Exception as e:
return f"## Airbnb Search Results\n\nError: {str(e)}"
return f"## Airbnb Search Results\n\n{result}"
| agent = Agent( | ||
| instructions="You help book apartments on Airbnb.", | ||
| llm="gpt-4o-mini", | ||
| tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt") |
There was a problem hiding this comment.
The LLM and tool configurations are hardcoded. Consider making these configurable via environment variables or a configuration file to allow users to easily change the settings without modifying the code.
llm = os.getenv("LLM_MODEL", "gpt-4o-mini")
tools_command = os.getenv("AIRBNB_MCP_COMMAND", "npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
agent = Agent(
instructions="You help book apartments on Airbnb.",
llm=llm,
tools=MCP(tools_command)
)
| def search_airbnb(query): | ||
| agent = Agent( | ||
| instructions="You help book apartments on Airbnb.", | ||
| llm="gpt-4o-mini", | ||
| tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt") | ||
| ) | ||
| result = agent.start(query) | ||
| return f"## Airbnb Search Results\n\n{result}" |
There was a problem hiding this comment.
Consider adding error handling to gracefully manage potential issues during agent initialization or API calls. For example, wrap the agent.start(query) call in a try...except block to catch exceptions and display an error message to the user.
try:
result = agent.start(query)
except Exception as e:
return f"## Airbnb Search Results\n\nError: {str(e)}"
return f"## Airbnb Search Results\n\n{result}"| agent = Agent( | ||
| instructions="You help book apartments on Airbnb.", | ||
| llm="gpt-4o-mini", | ||
| tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt") |
There was a problem hiding this comment.
The LLM and tool configurations are hardcoded. Consider making these configurable via environment variables or a configuration file to allow users to easily change the settings without modifying the code.
llm = os.getenv("LLM_MODEL", "gpt-4o-mini")
tools_command = os.getenv("AIRBNB_MCP_COMMAND", "npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
agent = Agent(
instructions="You help book apartments on Airbnb.",
llm=llm,
tools=MCP(tools_command)
)
β Deploy Preview for praisonai ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Add Gradio UI for Airbnb Booking Assistant
airbnb.mdxandui.pyfor searching and booking apartments on Airbnb.search_airbnbfunction to handle user queries and display results.Summary by CodeRabbit