mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-02-04 18:06:48 +00:00
feat: add WebVTT context generation to chat WebSocket endpoint
- Import topics_to_webvtt_named and recordings controller - Add _get_is_multitrack helper function - Generate WebVTT context on WebSocket connection - Add get_context message type to retrieve WebVTT - Maintain backward compatibility with echo for other messages - Add test fixture and test for WebVTT context generation Implements task fn-1.2: WebVTT context generation for transcript chat
This commit is contained in:
52
.flow/specs/fn-1.1.md
Normal file
52
.flow/specs/fn-1.1.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# Task 1: WebSocket Endpoint Skeleton
|
||||
|
||||
**File:** `server/reflector/views/transcripts_chat.py`
|
||||
**Lines:** ~30
|
||||
**Dependencies:** None
|
||||
|
||||
## Objective
|
||||
Create basic WebSocket endpoint with auth and connection handling.
|
||||
|
||||
## Implementation
|
||||
```python
|
||||
from typing import Optional
|
||||
from fastapi import APIRouter, Depends, WebSocket, WebSocketDisconnect
|
||||
import reflector.auth as auth
|
||||
from reflector.db.transcripts import transcripts_controller
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.websocket("/transcripts/{transcript_id}/chat")
|
||||
async def transcript_chat_websocket(
|
||||
transcript_id: str,
|
||||
websocket: WebSocket,
|
||||
user: Optional[auth.UserInfo] = Depends(auth.current_user_optional),
|
||||
):
|
||||
# 1. Auth check
|
||||
user_id = user["sub"] if user else None
|
||||
transcript = await transcripts_controller.get_by_id_for_http(
|
||||
transcript_id, user_id
|
||||
)
|
||||
|
||||
# 2. Accept connection
|
||||
await websocket.accept()
|
||||
|
||||
try:
|
||||
# 3. Basic message loop (stub)
|
||||
while True:
|
||||
data = await websocket.receive_json()
|
||||
await websocket.send_json({"type": "echo", "data": data})
|
||||
except WebSocketDisconnect:
|
||||
pass
|
||||
```
|
||||
|
||||
## Validation
|
||||
- [ ] Endpoint accessible at `ws://localhost:1250/v1/transcripts/{id}/chat`
|
||||
- [ ] Auth check executes (404 if transcript not found)
|
||||
- [ ] Connection accepts
|
||||
- [ ] Echo messages back to client
|
||||
- [ ] Disconnect handled gracefully
|
||||
|
||||
## Notes
|
||||
- Test with `websocat` or browser WebSocket client
|
||||
- Don't add LLM yet, just echo
|
||||
Reference in New Issue
Block a user