feat: integrate OCI agent streaming and web voice client

This commit is contained in:
2026-10-13 19:49:27 +00:00
parent 088473a0c8
commit 19a415daae
19 changed files with 2034 additions and 23 deletions

View File

@@ -0,0 +1,58 @@
from voice_assistant.agent.text_chunker import TextChunker
def test_chunker_emits_sentence():
chunker = TextChunker(min_chars=5)
assert chunker.feed("Olá, tudo bem?") == [
"Olá, tudo bem?"
]
def test_chunker_handles_incremental_deltas():
chunker = TextChunker(min_chars=5)
assert chunker.feed("Olá,") == []
assert chunker.feed(" tudo") == []
assert chunker.feed(" bem?") == [
"Olá, tudo bem?"
]
def test_chunker_preserves_remaining_text():
chunker = TextChunker(min_chars=5)
assert chunker.feed("Olá, tudo bem? Posso ajudar") == [
"Olá, tudo bem?"
]
assert chunker.flush() == "Posso ajudar"
def test_chunker_breaks_long_text():
chunker = TextChunker(
min_chars=5,
max_chars=20,
)
segments = chunker.feed(
"Esta é uma frase bastante longa sem pontuação"
)
assert segments
assert all(
len(segment) <= 20
for segment in segments
)
def test_chunker_rejects_invalid_limits():
try:
TextChunker(min_chars=20, max_chars=10)
except ValueError:
pass
else:
raise AssertionError(
"Expected ValueError for invalid limits."
)