{"id":26878063,"url":"https://github.com/24h-du-code-2025/backend","last_synced_at":"2026-03-04T22:30:54.229Z","repository":{"id":284431800,"uuid":"952995998","full_name":"24h-du-code-2025/backend","owner":"24h-du-code-2025","description":"Backend repository containing implementation of an AI agent for hotel management.","archived":false,"fork":false,"pushed_at":"2025-05-22T15:50:37.000Z","size":292,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-03T21:04:34.092Z","etag":null,"topics":["ai-agent","api","artificial-intelligence","flask","llm","websocket"],"latest_commit_sha":null,"homepage":"https://les24hducode.fr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/24h-du-code-2025.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-22T10:27:25.000Z","updated_at":"2025-03-27T16:31:01.000Z","dependencies_parsed_at":"2025-03-27T17:37:21.346Z","dependency_job_id":null,"html_url":"https://github.com/24h-du-code-2025/backend","commit_stats":null,"previous_names":["24h-du-code-2025/back-end","24h-du-code-2025/backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/24h-du-code-2025/backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/24h-du-code-2025%2Fbackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/24h-du-code-2025%2Fbackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/24h-du-code-2025%2Fbackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/24h-du-code-2025%2Fbackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/24h-du-code-2025","download_url":"https://codeload.github.com/24h-du-code-2025/backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/24h-du-code-2025%2Fbackend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30096720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T21:59:23.547Z","status":"ssl_error","status_checked_at":"2026-03-04T21:57:50.415Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","api","artificial-intelligence","flask","llm","websocket"],"created_at":"2025-03-31T12:19:01.702Z","updated_at":"2026-03-04T22:30:54.210Z","avatar_url":"https://github.com/24h-du-code-2025.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backend - AI ChatBot\r\n\r\nBackend implementation of the AI ChatBot that won the **[\"24 Heures du Code\"](https://les24hducode.fr/)** hackathon.\r\n\r\n## 🏆 Objective\r\n\r\nThe 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.\r\n\r\nThe 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.\r\n\r\n---\r\n\r\n## 🛠️ Application Overview\r\n\r\nThe 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.\r\n\r\n### 📌 How It Works:\r\n1. **User Input Processing**: Messages are sent to the AI agent.\r\n2. **Tool Invocation**: The AI agent determines the required tools based on the user’s intent.\r\n3. **Parameter Handling**: With the help of `pydantic`, the agent extracts relevant details and fills in missing parameters if possible.\r\n4. **Clarification Requests**: If user input is incomplete or unclear, the agent prompts for missing details.\r\n5. **API Interaction**: The necessary tool sends a request to the **Hotel California REST API**.\r\n6. **Response Handling**: The chatbot displays the API response to the user in the chat.\r\n\r\n![Diagram](assets/diagram.png)\r\n\r\n### ⬇️ Core Functionalities:\r\n- **Client Management**\r\n- **Restaurant Reservations**\r\n- **Hotel Accommodation Information**\r\n- **Weather Updates**\r\n- **Local Events Lookup**\r\n\r\n---\r\n\r\n### 🔧 ChatBot Features\r\n\r\n✅ **Conversational Memory**: The AI agent retains message history, allowing it to provide context-aware responses.\r\n\r\n✅ **Speech Recognition**: Users can interact with the chatbot via voice input.\r\n\r\n✅ **Multilingual Support**: The chatbot understands and responds in multiple languages.\r\n\r\n---\r\n\r\n## 🚀 Run Application\r\n\r\n1. **Clone the repository:**\r\n   ```bash\r\n   git clone https://github.com/24h-du-code-2025/backend.git \u003cdirectory\u003e\r\n   ```\r\n\r\n2. **Navigate to the repository directory:**\r\n   ```bash\r\n   cd \u003cdirectory\u003e\r\n   ```\r\n\r\n3. **Create and activate a virtual environment:**\r\n   ```bash\r\n   python3 -m venv venv\r\n   source venv/bin/activate\r\n   ```\r\n\r\n4. **Install dependencies:**\r\n   ```bash\r\n   pip install -r requirements.txt\r\n   ```\r\n\r\n5. **Create a `.env` file** using the `.env.dist` template and fill it with environment variables:\r\n   ```ini\r\n   ATLAS_URI=mongodb://127.0.0.1/?retryWrites=true\u0026w=majority\r\n   DB_NAME=hotel-california\r\n   LLM_MODEL=CHATGPT\r\n   HOTEL_API_URL=https://app-584240518682.europe-west9.run.app/\r\n   HOTEL_API_KEY=\r\n   OPEN_WEATHER_API_KEY=\r\n   OPENAI_API_KEY=\r\n   LANGSMITH_TRACING=true\r\n   LANGSMITH_ENDPOINT=\"https://api.smith.langchain.com\"\r\n   LANGSMITH_API_KEY=\r\n   LANGSMITH_PROJECT=\"hackaton\"\r\n   ```\r\n\r\n6. **Launch the server:**\r\n   ```bash\r\n   flask --app server run --debug\r\n   ```\r\n\r\n   **🔹 Note:** Ensure you have a **MongoDB instance running** on port **27017** before starting the application.\r\n\r\n---\r\n\r\n## 📁 Project Structure  \r\n\r\n| Folder / File | Description |\r\n|--------------|------------|\r\n| [`assets/`](assets) | Application diagrams |\r\n| [`model/`](model) | Model classes for interacting with the hotel REST API |\r\n| [`prompts/`](prompts) | Prompt templates sent to the LLM |\r\n| [`tools/`](tools) | Function tools used by the AI agent |\r\n| [`utils/`](utils) | Utility functions |\r\n| [`config.py`](config.py) | Configuration class storing environment variables |\r\n| [`server.py`](server.py) | Main Flask application |\r\n\r\n---\r\n\r\n## ⚙️ Technical Stack  \r\n\r\n- **🐍 Python** – Core programming language\r\n- **🌶️ Flask** – Web framework\r\n- **🍃 PyMongo** – MongoDB integration\r\n- **🔗 LangChain** – LLM orchestration\r\n- **🕸️ LangGraph** – LLM graph-based reasoning + creation of AI agents\r\n- **📂 LangSmith** – LLM debugging \u0026 tracing\r\n- **🤖 OpenAI** – AI model integration\r\n- **🗣️ Whisper** – Speech-to-text processing\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F24h-du-code-2025%2Fbackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F24h-du-code-2025%2Fbackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F24h-du-code-2025%2Fbackend/lists"}