IAV-594/feat(IAVIA): Implement conversational chat system with AI agent integration
Summary
This MR implements the complete conversational chat feature for the IAVIA platform, enabling users to have multi-turn conversations with AI agents. The implementation follows a clean architecture pattern with separate controllers, services, repositories, and mappers.
Features Implemented
Conversation Management
| Endpoint | Method | Description |
|---|---|---|
/api/agents/conversations |
POST | Create new conversation |
/api/agents/conversations/{uid} |
GET | Get conversation by UID |
/api/agents/conversations/user/{userUid} |
GET | Get user conversations (paginated) |
/api/agents/conversations/user/{userUid}/status/{status} |
GET | Get conversations by status |
/api/agents/conversations/user/{userUid}/agent/{agentUid}/active |
GET | Get or create active conversation |
/api/agents/conversations/{uid}/end |
PUT | End conversation |
/api/agents/conversations/{uid} |
DELETE | Delete conversation |
/api/agents/conversations/user/{userUid}/stats |
GET | Get conversation statistics |
Message Management
| Endpoint | Method | Description |
|---|---|---|
/api/agents/messages/send |
POST | Send message (multipart) |
/api/agents/messages/{uid} |
GET | Get message by UID |
/api/agents/messages/conversation/{uid} |
GET | Get conversation messages (paginated) |
/api/agents/messages/conversation/{uid}/search |
GET | Search messages |
/api/agents/messages/detail/{uid} |
DELETE | Delete message |
/api/agents/messages/conversation/{uid}/stats |
GET | Get message statistics |
Key Implementation Details
-
Session Lifecycle: Conversations transition from
ACTIVE→COMPLETEDstatus - Message Flow: User message → Save → AI Processing → Agent response → Save both
- Context Window: Last 10 messages sent as context for AI continuity
- Token Tracking: Actual tokens from API or estimation (chars/4)
- Auto Title: First message content generates conversation title (max 50 chars)
Testing Checklist
-
Create conversation with valid agent -
Create conversation with inactive agent (should fail) -
Send message and receive AI response -
Send message with file attachments -
Retrieve conversation messages with pagination -
Search messages by content -
End conversation and verify status change -
Delete conversation and verify cascade delete -
Verify token usage tracking -
Verify conversation title generation
Dependencies
- External AI service at
${iavia.prompt-processing.url}/process - File manager service for attachment handling
Related Issues
- Closes IAV-594