mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-02-04 09:56:47 +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:
43
.flow/specs/fn-1.2.md
Normal file
43
.flow/specs/fn-1.2.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Task 2: WebVTT Context Generation
|
||||
|
||||
**File:** `server/reflector/views/transcripts_chat.py` (modify)
|
||||
**Lines:** ~15
|
||||
**Dependencies:** Task 1
|
||||
|
||||
## Objective
|
||||
Generate WebVTT transcript context on connection.
|
||||
|
||||
## Implementation
|
||||
```python
|
||||
from reflector.utils.transcript_formats import topics_to_webvtt_named
|
||||
from reflector.views.transcripts import _get_is_multitrack
|
||||
|
||||
# Add after websocket.accept():
|
||||
# Get WebVTT context
|
||||
is_multitrack = await _get_is_multitrack(transcript)
|
||||
webvtt = topics_to_webvtt_named(
|
||||
transcript.topics,
|
||||
transcript.participants,
|
||||
is_multitrack
|
||||
)
|
||||
|
||||
# Truncate if needed
|
||||
webvtt_truncated = webvtt[:15000] if len(webvtt) > 15000 else webvtt
|
||||
|
||||
# Send to client for verification
|
||||
await websocket.send_json({
|
||||
"type": "context",
|
||||
"webvtt": webvtt_truncated,
|
||||
"truncated": len(webvtt) > 15000
|
||||
})
|
||||
```
|
||||
|
||||
## Validation
|
||||
- [ ] WebVTT generated on connection
|
||||
- [ ] Truncated to 15k chars if needed
|
||||
- [ ] Client receives context message
|
||||
- [ ] Format matches WebVTT spec (timestamps, speaker names)
|
||||
|
||||
## Notes
|
||||
- Log if truncation occurs
|
||||
- Keep echo functionality for testing
|
||||
Reference in New Issue
Block a user