Skip to content

Add Gradio UI for Airbnb Booking Assistant#434

Merged
MervinPraison merged 1 commit intomainfrom
develop
Mar 29, 2025
Merged

Add Gradio UI for Airbnb Booking Assistant#434
MervinPraison merged 1 commit intomainfrom
develop

Conversation

@MervinPraison
Copy link
Copy Markdown
Owner

@MervinPraison MervinPraison commented Mar 29, 2025

  • 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.

Summary by CodeRabbit

  • New Features
    • Introduced an interactive Airbnb Booking Assistant that processes booking queries and returns formatted search results.
    • Launched a user-friendly web interface with clear prompts, title, and description to guide users in searching for and booking apartments.

- 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.
@MervinPraison MervinPraison merged commit 27027ba into main Mar 29, 2025
3 of 6 checks passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes add a new Airbnb search feature using Gradio. Both the documentation and a new source module now define a search_airbnb(query) function. This function initializes an agent with specific instructions for booking apartments on Airbnb and processes a user's query to return formatted results. Additionally, a Gradio interface is set up to serve the function as a demo, with the script launching the interface when executed directly.

Changes

Files Change Summary
docs/mcp/airbnb.mdx
src/.../ui.py
Added a search_airbnb(query) function that initializes an agent for Airbnb bookings and returns formatted search results. Introduced a Gradio interface demo (with input and Markdown output) along with a conditional launch when the script is run as the main program.

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
Loading

Poem

I'm a rabbit with code so bright,
Hopping through changes day and night.
Airbnb searches now take flight,
With Gradio's charm in every byte.
My whiskers twitch at each delight! πŸ‡πŸ’»
Hip-hip, hooray for code done right!


πŸ“œ Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 57c4cf9 and 3622a8b.

πŸ“’ Files selected for processing (2)
  • docs/mcp/airbnb.mdx (1 hunks)
  • src/praisonai-agents/ui.py (1 hunks)
✨ Finishing Touches
  • πŸ“ Generate Docstrings

πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_airbnb function 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 praisonaiagents library for agent and MCP functionalities and gradio for the UI.
  • src/praisonai-agents/ui.py
    • Created a new file ui.py containing the Gradio UI implementation for the Airbnb booking assistant.
    • The file includes the search_airbnb function and the Gradio interface setup.
    • It uses the Agent and MCP classes from the praisonaiagents library and the gradio library for the UI.
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

  1. 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. ↩

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.mdx and ui.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.

Comment on lines +1 to +22
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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()

Comment thread docs/mcp/airbnb.mdx
Comment on lines +76 to +83
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}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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}"

Comment thread docs/mcp/airbnb.mdx
Comment on lines +77 to +80
agent = Agent(
instructions="You help book apartments on Airbnb.",
llm="gpt-4o-mini",
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)
    )

Comment on lines +4 to +11
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}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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}"

Comment on lines +5 to +8
agent = Agent(
instructions="You help book apartments on Airbnb.",
llm="gpt-4o-mini",
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)
    )

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 29, 2025

βœ… Deploy Preview for praisonai ready!

Name Link
πŸ”¨ Latest commit 3622a8b
πŸ” Latest deploy log https://app.netlify.com/sites/praisonai/deploys/67e85e26a961eb0008184be3
😎 Deploy Preview https://deploy-preview-434--praisonai.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

shaneholloman pushed a commit to shaneholloman/praisonai that referenced this pull request Feb 4, 2026
Add Gradio UI for Airbnb Booking Assistant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant