[CI/Build][MiniCPM-o] Allow auto-response before input commit (#5567)
Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
7 files changed
+104
-6
No files matched your search
@@ -265,14 +265,26 @@ class DemoState:
|
||||
indices[event_type] = index
|
||||
return indices
|
||||
|
||||
def event_order_ok(self, *, require_input_commit: bool = True) -> bool:
|
||||
def event_order_ok(
|
||||
self,
|
||||
*,
|
||||
require_input_commit: bool = True,
|
||||
require_commit_before_response: bool = True,
|
||||
) -> bool:
|
||||
if not self.events or self.events[0].get("type") != "session.created":
|
||||
return False
|
||||
first_commit_index = self.first_index("input_audio_buffer.committed")
|
||||
first_response_index = self.first_index("response.created")
|
||||
if first_response_index is None:
|
||||
return False
|
||||
if require_input_commit and (first_commit_index is None or first_commit_index > first_response_index):
|
||||
if require_input_commit and first_commit_index is None:
|
||||
return False
|
||||
if (
|
||||
require_input_commit
|
||||
and require_commit_before_response
|
||||
and first_commit_index is not None
|
||||
and first_commit_index > first_response_index
|
||||
):
|
||||
return False
|
||||
indices_by_type = self.first_response_lifecycle_indices()
|
||||
if not indices_by_type:
|
||||
@@ -1409,7 +1421,10 @@ async def run_demo(args: argparse.Namespace) -> dict[str, object]:
|
||||
require_input_commit=not continuous_input,
|
||||
)
|
||||
if validation_mode == "model-policy"
|
||||
else state.event_order_ok(require_input_commit=not continuous_input)
|
||||
else state.event_order_ok(
|
||||
require_input_commit=not continuous_input,
|
||||
require_commit_before_response=False,
|
||||
)
|
||||
)
|
||||
input_transcription_ok = _input_transcription_ok(
|
||||
state.input_transcription_count,
|
||||
|
||||
@@ -114,7 +114,7 @@ def test_duplex_single_session_response_required(omni_server, model_prefix: str,
|
||||
)
|
||||
)
|
||||
)
|
||||
assert result["ok"] is True
|
||||
assert result["ok"] is True, json.dumps(result, ensure_ascii=False, indent=2)
|
||||
assert result["audio_delta_count"] > 0
|
||||
assert result["done_count"] == 1
|
||||
assert result["error_count"] == 0
|
||||
@@ -137,7 +137,7 @@ def test_duplex_two_sessions_resume_and_takeover(omni_server, model_prefix: str,
|
||||
)
|
||||
)
|
||||
)
|
||||
assert result["ok"] is True
|
||||
assert result["ok"] is True, json.dumps(result, ensure_ascii=False, indent=2)
|
||||
assert result["session_count"] == 2
|
||||
assert result["resume"]["ok"] is True
|
||||
assert result["takeover"]["ok"] is True
|
||||
|
||||
@@ -874,6 +874,39 @@ def test_realtime_duplex_demo_model_policy_accepts_continuous_input_without_comm
|
||||
assert state.model_policy_event_order_ok(expected_turns=3, require_input_commit=False)
|
||||
|
||||
|
||||
def test_realtime_duplex_demo_distinguishes_late_and_missing_commit():
|
||||
demo = _load_demo_module()
|
||||
state = demo.DemoState()
|
||||
response_id = "resp-1"
|
||||
item_id = f"item_{response_id}"
|
||||
for event in (
|
||||
{"type": "session.created"},
|
||||
{"type": "response.created", "response_id": response_id},
|
||||
{"type": "conversation.item.added", "item": {"id": item_id}},
|
||||
{"type": "response.output_item.added", "response_id": response_id},
|
||||
{"type": "response.content_part.added", "response_id": response_id},
|
||||
{"type": "response.speak", "response_id": response_id},
|
||||
{"type": "response.audio.delta", "response_id": response_id, "delta": "AAAA"},
|
||||
{"type": "response.audio.done", "response_id": response_id},
|
||||
{"type": "response.content_part.done", "response_id": response_id},
|
||||
{"type": "response.output_item.done", "response_id": response_id},
|
||||
{"type": "response.done", "response_id": response_id},
|
||||
{"type": "input_audio_buffer.committed"},
|
||||
):
|
||||
state.add(event)
|
||||
|
||||
assert not state.event_order_ok(require_input_commit=True)
|
||||
assert state.event_order_ok(
|
||||
require_input_commit=True,
|
||||
require_commit_before_response=False,
|
||||
)
|
||||
state.events.pop()
|
||||
assert not state.event_order_ok(
|
||||
require_input_commit=True,
|
||||
require_commit_before_response=False,
|
||||
)
|
||||
|
||||
|
||||
def test_realtime_duplex_demo_accepts_overlap_unit_terminating_continuous_response():
|
||||
demo = _load_demo_module()
|
||||
state = demo.DemoState()
|
||||
|
||||
Reference in new issue
Block a user