Implement Sprint 3: Chat Functionality
- Add ChatService with send_message and get_history methods
- Add POST /api/v1/notebooks/{id}/chat - Send message
- Add GET /api/v1/notebooks/{id}/chat/history - Get chat history
- Add ChatRequest model (message, include_references)
- Add ChatResponse model (message, sources[], timestamp)
- Add ChatMessage model (id, role, content, timestamp, sources)
- Add SourceReference model (source_id, title, snippet)
- Integrate chat router with main app
Features:
- Send messages to notebook chat
- Get AI responses with source references
- Retrieve chat history
- Support for citations in responses
Tests:
- 14 unit tests for ChatService
- 11 integration tests for chat API
- 25/25 tests passing
Related: Sprint 3 - Chat Functionality
108 lines
2.3 KiB
Markdown
108 lines
2.3 KiB
Markdown
# Prompt Sprint 3 - Chat Functionality
|
|
|
|
## 🎯 Sprint 3: Chat Functionality
|
|
|
|
**Iniziato**: 2026-04-06
|
|
**Stato**: 🟡 In Progress
|
|
**Assegnato**: @sprint-lead
|
|
|
|
---
|
|
|
|
## 📋 Obiettivo
|
|
|
|
Implementare la funzionalità di chat per interrogare le fonti dei notebook. Gli utenti potranno inviare messaggi e ricevere risposte basate sulle fonti caricate.
|
|
|
|
---
|
|
|
|
## 🏗️ Architettura
|
|
|
|
### Pattern (stesso di Sprint 1 & 2)
|
|
|
|
```
|
|
API Layer (FastAPI Routes)
|
|
↓
|
|
Service Layer (ChatService)
|
|
↓
|
|
External Layer (notebooklm-py client)
|
|
```
|
|
|
|
### Endpoints da implementare
|
|
|
|
1. **POST /api/v1/notebooks/{id}/chat** - Inviare messaggio
|
|
2. **GET /api/v1/notebooks/{id}/chat/history** - Ottenere storico chat
|
|
3. **POST /api/v1/notebooks/{id}/chat/save** - Salvare risposta come nota (v2)
|
|
|
|
---
|
|
|
|
## 📊 Task Breakdown Sprint 3
|
|
|
|
### Fase 1: Specifiche
|
|
- [ ] SPEC-006: Analisi requisiti Chat
|
|
- [ ] Definire flusso conversazione
|
|
- [ ] Definire formato messaggi
|
|
|
|
### Fase 2: API Design
|
|
- [ ] API-005: Modelli Pydantic (ChatMessage, ChatRequest, ChatResponse)
|
|
- [ ] Documentazione endpoints chat
|
|
|
|
### Fase 3: Implementazione
|
|
- [ ] DEV-012: ChatService
|
|
- [ ] DEV-013: POST /chat
|
|
- [ ] DEV-014: GET /chat/history
|
|
|
|
### Fase 4: Testing
|
|
- [ ] TEST-006: Unit tests ChatService
|
|
- [ ] TEST-007: Integration tests chat API
|
|
|
|
---
|
|
|
|
## 🔧 Implementazione
|
|
|
|
### ChatService Methods
|
|
|
|
```python
|
|
class ChatService:
|
|
async def send_message(
|
|
notebook_id: UUID,
|
|
message: str,
|
|
include_references: bool = True
|
|
) -> ChatResponse:
|
|
"""Send message and get response."""
|
|
|
|
async def get_history(notebook_id: UUID) -> list[ChatMessage]:
|
|
"""Get chat history for notebook."""
|
|
```
|
|
|
|
### Modelli
|
|
|
|
```python
|
|
class ChatRequest(BaseModel):
|
|
message: str
|
|
include_references: bool = True
|
|
|
|
class ChatResponse(BaseModel):
|
|
message: str
|
|
sources: list[SourceReference]
|
|
timestamp: datetime
|
|
|
|
class ChatMessage(BaseModel):
|
|
id: UUID
|
|
role: str # "user" | "assistant"
|
|
content: str
|
|
timestamp: datetime
|
|
sources: list[SourceReference] | None
|
|
```
|
|
|
|
---
|
|
|
|
## 🚀 Prossimi Passi
|
|
|
|
1. @sprint-lead: Attivare @api-designer per API-005
|
|
2. @api-designer: Definire modelli chat
|
|
3. @tdd-developer: Iniziare implementazione ChatService
|
|
|
|
---
|
|
|
|
**Dipende da**: Sprint 2 (Source Management) ✅
|
|
**Blocca**: Sprint 4 (Content Generation) 🔴
|