세션 메모리와 비언어 이벤트 저장

This commit is contained in:
Yun Chan 2026-06-28 20:12:50 +09:00
parent e8e08935ed
commit 50fa4ad432
12 changed files with 2848 additions and 1277 deletions

View file

@ -77,6 +77,50 @@ class VoiceWebSocketContractTest(unittest.IsolatedAsyncioTestCase):
{"degraded": False, "persona_catalog_source": "session"},
)
def test_provider_events_get_internal_taxonomy_without_raw_payload(self) -> None:
events = voice_routes._safe_provider_events(
[
{
"type": "SIGH",
"confidence": 0.81,
"text": "raw transcript must drop",
},
{
"kind": "voice_activity",
"start_ms": 10,
"raw_text": "drop",
},
{
"label": "vendor custom marker",
"score": 0.44,
},
]
)
self.assertEqual(
events,
[
{
"type": "SIGH",
"confidence": 0.81,
"event_type": "sigh",
"category": "paralinguistic",
},
{
"kind": "voice_activity",
"start_ms": 10,
"event_type": "voice_activity",
"category": "speech_activity",
},
{
"label": "vendor custom marker",
"score": 0.44,
"event_type": "vendor_custom_marker",
"category": "unknown",
},
],
)
async def test_audio_start_binary_chunks_audio_end_ping_close_contract(self) -> None:
websocket = FakeWebSocket(
[
@ -90,6 +134,15 @@ class VoiceWebSocketContractTest(unittest.IsolatedAsyncioTestCase):
"format": "webm",
"silence_ms": "450",
"barge_in": "true",
"provider_events": [
{
"type": "sigh",
"confidence": 0.82,
"text": "raw transcript must not persist",
},
{"kind": "noise", "label": "x" * 120},
"invalid",
],
}
),
_control({"type": "close"}),
@ -141,6 +194,23 @@ class VoiceWebSocketContractTest(unittest.IsolatedAsyncioTestCase):
self.assertEqual(kwargs["audio_ended_at"], 12.0)
self.assertEqual(kwargs["silence_ms"], 450)
self.assertIs(kwargs["barge_in"], True)
self.assertEqual(
kwargs["provider_events"],
[
{
"type": "sigh",
"confidence": 0.82,
"event_type": "sigh",
"category": "paralinguistic",
},
{
"kind": "noise",
"label": "x" * 80,
"event_type": "background_noise",
"category": "audio_quality",
},
],
)
async def test_text_turn_strips_text_runs_turn_and_ping_close_still_work(self) -> None:
websocket = FakeWebSocket(