Skip to content

feat(chat): Add chat conversations and messages module for document analysis

zakariae yahya a demandé de fusionner feature/accounts-folders vers develop

Chat Module - Conversations & Messages

Overview

This MR implements the Chat module for document analysis, enabling users to have conversations with their indexed documents using RAG technology.

What's New

Database Models

Table Description
conversations User chat sessions with title and archive status
messages Individual messages with sender (user/agent), type, and RAG metadata

API Endpoints

POST   /chat/conversations              Create new conversation
GET    /chat/conversations              List user's conversations
GET    /chat/conversations/{id}         Get conversation details
PATCH  /chat/conversations/{id}         Update title
DELETE /chat/conversations/{id}         Delete with cascade
POST   /chat/conversations/{id}/messages Send message, get AI response
GET    /chat/conversations/{id}/messages Get conversation history

Architecture

Frontend -> FastAPI -> n8n (chatbot-rag) -> Qdrant + LiteLLM -> Response

Files Changed

New (7 files):

  • Integration/models/conversation.py
  • Integration/models/message.py
  • Integration/schemas/chat.py
  • Integration/services/conversation_service.py
  • Integration/services/message_service.py
  • Integration/chat_api.py
  • Integration/scripts/create_chat_tables.py

Modified (5 files):

  • Integration/models/enums.py
  • Integration/models/__init__.py
  • Integration/services/__init__.py
  • Agent/api_app.py
  • Agent/Readme.md

Configuration Required

Add to Agent/.env:

N8N_WEBHOOK_BASE_URL=https://ai.izemx.com  # or ngrok URL for dev
N8N_CHATBOT_TIMEOUT=60.0  # optional, defaults to 60s

Database Setup

Run the table creation script before first use:

python Integration/scripts/create_chat_tables.py

Dependencies

  • httpx (for async HTTP calls)
  • Existing: FastAPI, SQLAlchemy, Pydantic

Checklist

  • Models created (Conversation, Message)
  • Schemas created (Pydantic)
  • Services implemented
  • API endpoints created
  • Router integrated in api_app.py
  • README updated with Chat API section
  • Database table creation script
  • All tests passing (11/11)
  • n8n workflow imported (manual step)
Modification effectuée par zakariae yahya

Rapports de requête de fusion