A sophisticated AI-powered hotel booking assistant built with Gradio, Claude API, and sentence transformers. This chatbot specializes in helping users find, compare, and book hotels based on their specific requirements using the MultiWOZ dataset.
This project implements a comprehensive hotel booking chatbot that:
- Uses the Claude API for natural language understanding and generation
- Leverages sentence transformers for semantic search and embeddings
- Implements a mock OpenSearch-like client for hotel information retrieval
- Provides a user-friendly Gradio interface with conversation history
- Includes comprehensive tools for different hotel-related intents
- Uses MultiWOZ dataset (focused on hotels) for training and testing
- Hotel Search: Find hotels based on location, price, amenities, and other criteria
- Booking Management: Create, modify, and cancel hotel reservations
- Information Retrieval: Get detailed information about hotels and their services
- Recommendations: Receive personalized hotel suggestions based on preferences
- Comparison: Compare multiple hotels side-by-side
- Availability Checking: Real-time availability and pricing information
- Streaming Responses: Real-time chat with Claude API streaming support
- Semantic Search: Vector-based search using sentence transformers
- Context Management: Intelligent conversation context and history handling
- Intent Detection: Automatic detection of user intents (search, booking, info, etc.)
- Multi-modal Search: Hybrid text and vector search capabilities
- Session Management: Persistent user sessions with preferences
The project follows a modular architecture with clear separation of concerns:
chatbot/
├── clients/ # External service clients
│ ├── llm_client.py # Claude API client with streaming
│ ├── embedding_client.py # Sentence transformers client
│ └── search_client.py # Mock OpenSearch client
├── context/ # Context management
│ └── context_manager.py # Search and load context information
├── prompts/ # System prompts
│ └── hotel_prompts.py # Hotel-specific prompt templates
├── tool_collection/ # Intent-specific tools
│ └── hotel_tools.py # Tools for hotel operations
├── tests/ # Comprehensive test suite
│ ├── test_clients.py
│ ├── test_context_manager.py
│ ├── test_hotel_tools.py
│ └── test_prompts.py
├── notebooks/ # Data analysis and experimentation
│ ├── analyze_multiwoz.ipynb # MultiWOZ dataset analysis
│ └── multiwoz-master/ # Downloaded MultiWOZ dataset
├── app.py # Main Gradio application
└── requirements.txt # Dependencies
- Python 3.8+
- pip package manager
- Anthropic API key for Claude
-
Clone the repository:
git clone <repository-url> cd chatbot
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
export ANTHROPIC_API_KEY="your-claude-api-key-here"
-
Download and prepare MultiWOZ dataset (optional - sample data is included): The dataset is automatically downloaded when you run the application for the first time.
-
Start the Gradio application:
python app.py
-
Open your browser and navigate to:
http://localhost:7860 -
Start chatting with the hotel booking assistant!
Hotel Search:
User: "Find me a 4-star hotel in Cambridge with parking and free wifi under £200 per night"
Assistant: "I found several hotels matching your criteria..."
Booking Request:
User: "I want to book the Grand Cambridge Hotel for 2 nights"
Assistant: "I'd be happy to help you book the Grand Cambridge Hotel..."
Information Query:
User: "What amenities does the Luxury Cambridge Resort have?"
Assistant: "The Luxury Cambridge Resort offers excellent amenities including..."
- Main Chat: Primary conversation area with the AI assistant
- Quick Search: Side panel for rapid hotel searches with filters
- Amenities Filter: Select preferred hotel amenities
- Session Management: Clear chat or start new sessions
- Example Prompts: Pre-configured examples to get started
The project includes comprehensive code quality tools:
# Format code with Black
black .
# Lint with flake8
flake8 .
# Sort imports with isort
isort .
# Run tests
pytest
# Run tests with coverage
pytest --cov# Run all tests
pytest
# Run specific test modules
pytest tests/test_clients.py
pytest tests/test_hotel_tools.py
# Run with verbose output
pytest -v
# Run with coverage report
pytest --cov --cov-report=html- Implement the core logic in the appropriate module (clients/, context/, tool_collection/)
- Add comprehensive tests in the tests/ directory
- Update prompts if needed in prompts/hotel_prompts.py
- Extend the Gradio interface in app.py if UI changes are needed
- Update documentation and this README
ANTHROPIC_API_KEY: Your Claude API key (required)SENTENCE_TRANSFORMERS_HOME: Custom cache directory for models (optional)
- Model Selection: Change the sentence transformer model in
embedding_client.py - Search Parameters: Adjust similarity thresholds and result limits in
context_manager.py - UI Styling: Modify the Gradio interface styling in
app.py - Hotel Database: Add more hotels to the mock database in
hotel_tools.py
- anthropic: Claude API client for LLM interactions
- sentence-transformers: Embedding generation and semantic search
- gradio: Web-based user interface
- numpy: Numerical computations
- pandas: Data manipulation and analysis
- pytest: Testing framework
- black: Code formatting
- flake8: Code linting
- isort: Import sorting
- jupyter: Notebook environment for data analysis
- matplotlib: Data visualization
- scipy: Scientific computing
The project uses the MultiWOZ dataset (Multi-Domain Wizard-of-Oz) focused on hotel bookings:
- Dataset Location:
notebooks/multiwoz-master/data/MultiWOZ_2.2/ - Analysis Notebook:
notebooks/analyze_multiwoz.ipynb - Focus: Hotel domain dialogues and intent patterns
- Usage: Training data for intent detection and response patterns
The project includes comprehensive tests covering:
- Client modules: LLM, embedding, and search client functionality
- Context management: Session handling and context building
- Hotel tools: Intent detection, search, and booking operations
- Prompts: System prompt generation and formatting
- Functionality testing: All core features and edge cases
- Error handling: Invalid inputs and error scenarios
- Integration testing: Component interaction verification
- Mock testing: External API calls and dependencies
- Embedding Caching: Sentence transformer models are cached locally
- Session Management: Efficient in-memory session storage
- Search Optimization: Vector similarity search with configurable thresholds
- Response Streaming: Real-time response generation with Claude API
- API Key Protection: Environment variable-based API key management
- Input Validation: Comprehensive input sanitization
- Error Handling: Graceful error handling without exposing internals
- Session Isolation: User sessions are isolated and secure
- Real Hotel Integration: Connect to actual hotel booking APIs
- Payment Processing: Add secure payment handling
- Multi-language Support: Extend to support multiple languages
- Advanced Analytics: User behavior and booking pattern analysis
- Mobile Interface: React Native or Flutter mobile app
- Voice Interface: Speech-to-text and text-to-speech capabilities
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Run the test suite (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- API Key Error: Ensure
ANTHROPIC_API_KEYis set correctly - Model Download: First run may take time to download sentence transformer models
- Port Conflicts: Change the port in
app.pyif 7860 is occupied - Memory Issues: Reduce batch sizes in embedding client for lower memory usage
- Check the test suite for usage examples
- Review the notebooks for data analysis examples
- Examine the Gradio interface code for UI customization
- Read the comprehensive docstrings in each module
This project is licensed under the MIT License - see the LICENSE file for details.
- MultiWOZ Dataset: University of Cambridge for the dialogue dataset
- Anthropic: Claude API for advanced language understanding
- Hugging Face: Sentence transformers and model hosting
- Gradio: Excellent framework for ML interfaces