vllm_omni.protocol.realtime.items ¶
Realtime conversation items: shape, truncation and the transcript inside one.
A Realtime conversation is a list of items --- a user message, an assistant message, a function call --- each with a content list of typed parts. The client creates them (conversation.item.create), truncates an assistant item's audio after a barge-in (conversation.item.truncate), and the server echoes them back inside conversation.item.* and response.done events.
The rules in this module are the ones both sides have to agree on: which defaults a bare item gets, how far a transcript is cut when the client says it only heard N milliseconds of audio, and what makes a truncate request invalid. Item storage --- which items a session currently holds, in what order --- is the consumer's state, not this module's.
validate_realtime_video_frames sits here too: camera frames ride along an input_audio_buffer.append in the vLLM-Omni extension of the protocol, and validating them is the same kind of wire-shape check.
normalize_conversation_item ¶
text_chars_for_audio_ms_from_marks ¶
text_chars_for_audio_ms_from_marks(
audio_end_ms: int,
text_len: int,
marks: list[object],
*,
final_ms: object | None = None,
) -> int
truncate_realtime_item_content ¶
truncate_realtime_item_content(
item: dict[str, object],
*,
content_index: int,
audio_end_ms: int,
) -> None
validate_realtime_item_truncate ¶
validate_realtime_item_truncate(
item: Mapping[str, object],
*,
content_index: int,
audio_end_ms: int,
) -> str | None
validate_realtime_video_frames ¶
Validate omni-duplex camera frames on input_audio_buffer.append.
Wire contract matches the official MiniCPM-o duplex loop: one base base64 JPEG per ~1 s audio chunk, optionally followed by that unit's stacked composite tiling the sub-frames captured inside it (at most 2 images either way). A caller-supplied max_slice_nums is rejected rather than silently ignored: slicing is Stage 0's decision here, and Stage 0 already applies the official HD suggestion for a stacked unit (max_slice_nums=[2, 1]). The wire simply does not let the client choose it.