https://github.com/24h-du-code-2025/backend
Backend repository containing implementation of an AI agent for hotel management.
https://github.com/24h-du-code-2025/backend
ai-agent api artificial-intelligence flask llm websocket
Last synced: 4 months ago
JSON representation
Backend repository containing implementation of an AI agent for hotel management.
- Host: GitHub
- URL: https://github.com/24h-du-code-2025/backend
- Owner: 24h-du-code-2025
- Created: 2025-03-22T10:27:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-22T15:50:37.000Z (about 1 year ago)
- Last Synced: 2026-03-03T21:04:34.092Z (4 months ago)
- Topics: ai-agent, api, artificial-intelligence, flask, llm, websocket
- Language: Python
- Homepage: https://les24hducode.fr/
- Size: 285 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Backend - AI ChatBot
Backend implementation of the AI ChatBot that won the **["24 Heures du Code"](https://les24hducode.fr/)** hackathon.
## π Objective
The primary goal of the hackathon was to develop a chatbot to automate the reception process at **Hotel California**. Instead of clients having to ask hotel managers for information and make requests manually, they could interact with an AI-powered chatbot that handles basic management tasks seamlessly.
The hackathon organizers provided a pre-developed **REST API** for the Hotel California system. The chatbot's objective was to interpret user requests in natural language and translate them into appropriate API calls.
---
## π οΈ Application Overview
The chatbot interacts with users via a **frontend UI**, which communicates with the backend using **WebSockets**. The backend processes user messages using the `LangGraph` framework, directing them to an **AI agent** that utilizes predefined tools to execute tasks efficiently.
### π How It Works:
1. **User Input Processing**: Messages are sent to the AI agent.
2. **Tool Invocation**: The AI agent determines the required tools based on the userβs intent.
3. **Parameter Handling**: With the help of `pydantic`, the agent extracts relevant details and fills in missing parameters if possible.
4. **Clarification Requests**: If user input is incomplete or unclear, the agent prompts for missing details.
5. **API Interaction**: The necessary tool sends a request to the **Hotel California REST API**.
6. **Response Handling**: The chatbot displays the API response to the user in the chat.

### β¬οΈ Core Functionalities:
- **Client Management**
- **Restaurant Reservations**
- **Hotel Accommodation Information**
- **Weather Updates**
- **Local Events Lookup**
---
### π§ ChatBot Features
β
**Conversational Memory**: The AI agent retains message history, allowing it to provide context-aware responses.
β
**Speech Recognition**: Users can interact with the chatbot via voice input.
β
**Multilingual Support**: The chatbot understands and responds in multiple languages.
---
## π Run Application
1. **Clone the repository:**
```bash
git clone https://github.com/24h-du-code-2025/backend.git
```
2. **Navigate to the repository directory:**
```bash
cd
```
3. **Create and activate a virtual environment:**
```bash
python3 -m venv venv
source venv/bin/activate
```
4. **Install dependencies:**
```bash
pip install -r requirements.txt
```
5. **Create a `.env` file** using the `.env.dist` template and fill it with environment variables:
```ini
ATLAS_URI=mongodb://127.0.0.1/?retryWrites=true&w=majority
DB_NAME=hotel-california
LLM_MODEL=CHATGPT
HOTEL_API_URL=https://app-584240518682.europe-west9.run.app/
HOTEL_API_KEY=
OPEN_WEATHER_API_KEY=
OPENAI_API_KEY=
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
LANGSMITH_API_KEY=
LANGSMITH_PROJECT="hackaton"
```
6. **Launch the server:**
```bash
flask --app server run --debug
```
**πΉ Note:** Ensure you have a **MongoDB instance running** on port **27017** before starting the application.
---
## π Project Structure
| Folder / File | Description |
|--------------|------------|
| [`assets/`](assets) | Application diagrams |
| [`model/`](model) | Model classes for interacting with the hotel REST API |
| [`prompts/`](prompts) | Prompt templates sent to the LLM |
| [`tools/`](tools) | Function tools used by the AI agent |
| [`utils/`](utils) | Utility functions |
| [`config.py`](config.py) | Configuration class storing environment variables |
| [`server.py`](server.py) | Main Flask application |
---
## βοΈ Technical Stack
- **π Python** β Core programming language
- **πΆοΈ Flask** β Web framework
- **π PyMongo** β MongoDB integration
- **π LangChain** β LLM orchestration
- **πΈοΈ LangGraph** β LLM graph-based reasoning + creation of AI agents
- **π LangSmith** β LLM debugging & tracing
- **π€ OpenAI** β AI model integration
- **π£οΈ Whisper** β Speech-to-text processing