feat: integrate OCI agent streaming and web voice client
This commit is contained in:
@@ -20,6 +20,7 @@ import pytest
|
||||
from pydantic import ValidationError
|
||||
from voice_assistant.audio.models import CANONICAL_AUDIO_FORMAT
|
||||
from voice_assistant.audio_gateway.app.protocol import (
|
||||
AgentDelta,
|
||||
AgentResponse,
|
||||
AudioChunk,
|
||||
AudioStart,
|
||||
@@ -38,6 +39,7 @@ from voice_assistant.audio_gateway.app.protocol import (
|
||||
)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("model", "expected_type"),
|
||||
[
|
||||
@@ -101,6 +103,7 @@ def test_session_ready_output():
|
||||
(TurnStarted, "turn.started"),
|
||||
(STTPartial, "stt.partial"),
|
||||
(STTFinal, "stt.final"),
|
||||
(AgentDelta, "agent.delta"),
|
||||
(AgentResponse, "agent.response"),
|
||||
(TurnEnded, "turn.ended"),
|
||||
(Interrupted, "interrupted"),
|
||||
@@ -115,7 +118,7 @@ def test_turn_output_event_types(
|
||||
"turn_id": 1,
|
||||
}
|
||||
|
||||
if model in (STTPartial, STTFinal, AgentResponse):
|
||||
if model in (STTPartial, STTFinal, AgentDelta, AgentResponse):
|
||||
data["text"] = "test"
|
||||
|
||||
event = model(**data)
|
||||
@@ -168,3 +171,30 @@ def test_error_event_defaults():
|
||||
assert event.retryable is False
|
||||
assert event.details == {}
|
||||
|
||||
|
||||
def test_agent_delta_serialization():
|
||||
event = AgentDelta(
|
||||
session_id="session-1",
|
||||
turn_id=7,
|
||||
text=" mundo",
|
||||
)
|
||||
|
||||
assert event.model_dump() == {
|
||||
"type": "agent.delta",
|
||||
"session_id": "session-1",
|
||||
"turn_id": 7,
|
||||
"text": " mundo",
|
||||
}
|
||||
|
||||
|
||||
def test_agent_delta_rejects_wrong_type():
|
||||
with pytest.raises(ValidationError):
|
||||
AgentDelta.model_validate(
|
||||
{
|
||||
"type": "agent.response",
|
||||
"session_id": "session-1",
|
||||
"turn_id": 7,
|
||||
"text": "Olá",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user