agentscope.realtimeDashScopeRealtimeModel
class DashScopeRealtimeModel(RealtimeModelBase)
agentscope/realtime/_dashscope/_model.py:31–465DashScope 实时模型,处理低延迟的实时语音与多模态交互。位于 agentscope.realtime 包,继承自 RealtimeModelBase。核心成员包括 connect、close、events、push_audio、push_text、push_tool_result。
The protocol is OpenAI-shaped (session.update,
input_audio_buffer.append, response.create) but narrower: no
text turns, no conversation.item.truncate, and history that cannot
be seeded on connect.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Parameters | 类class | 参数,处理低延迟的实时语音与多模态交互。 Tuneables surfaced to the UI. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(model: str, credential: DashScopeCredential, parameters: 'DashScopeRealtimeModel.Parameters | None' = None… | 初始化 `DashScopeRealtimeModel` 实例。 Initialize the DashScope realtime model. |
属性摘要Property Summary
| 属性Property | 说明Description |
|---|---|
input_transcription_enabled | 读取 `input_transcription_enabled` 属性。 Whether DashScope input transcription is enabled. |
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
type | — | 类型字段。 | 'dashscope_omni_realtime' |
supports_text_input | — | 支持文本输入字段。 | False |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def connect(instructions: str, tools: list[dict] | None = None, **kwargs: Any) -> Noneasync | 建立连接并完成初始化。 Open the WebSocket and send the session config. |
async def close() -> Noneasync | 关闭连接并释放相关资源。 Stop reading and close the WebSocket. |
async def events() -> AsyncIterator[me.ModelEvent]async | 返回事件。 Yield events until the session ends. |
async def push_audio(pcm: bytes) -> Noneasync | 设置推送音频。 Append PCM16 mono audio at 16 kHz to the input buffer. |
async def push_text(text: str) -> Noneasync | 设置推送文本。 Unsupported: the API accepts audio and images only. |
async def push_tool_result(block: ToolResultBlock) -> Noneasync | 设置推送工具结果。 Send a ``function_call_output`` item. |
async def commit_turn() -> Noneasync | 返回提交轮次。 Commit the input buffer as one user turn. |
async def request_response() -> Noneasync | 返回请求响应。 Ask for a reply, cancelling one already in flight first. |
async def cancel_response() -> Noneasync | 返回取消响应。 Cancel the reply in flight, if any. |
构造器详情Constructor Detail
DashScopeRealtimeModel
def __init__(model: str, credential: DashScopeCredential, parameters: 'DashScopeRealtimeModel.Parameters | None' = None, model_card: RealtimeModelCard | None = None) -> None
初始化 DashScopeRealtimeModel 实例。
Initialize the DashScope realtime model.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
model | str | 模型实例(类型 `str`)。The model name, e.g. `"qwen3-omni-flash-realtime"`. |
credential | DashScopeCredential | DashScope 凭证。The DashScope credential. |
parameters默认default None | 'DashScopeRealtimeModel.Parameters | None' | 参数(类型 `'DashScopeRealtimeModel.Parameters | None'`)。Provider parameters; defaults are used if omitted. |
model_card默认default None | RealtimeModelCard | None | 模型卡片(类型 `RealtimeModelCard | None`)。The model card, looked up by name if omitted. |
agentscope/realtime/_dashscope/_model.py:86–114属性详情Attribute Detail
type
= 'dashscope_omni_realtime'类型字段。
The type field.
agentscope/realtime/_dashscope/_model.py:78supports_text_input
= False支持文本输入字段。
The supports text input field.
agentscope/realtime/_dashscope/_model.py:79属性详情Property Detail
input_transcription_enabled
def input_transcription_enabled() -> bool
读取 input_transcription_enabled 属性。
Whether DashScope input transcription is enabled.
agentscope/realtime/_dashscope/_model.py:82–84方法详情Method Detail
connect
async def connect(instructions: str, tools: list[dict] | None = None, **kwargs: Any) -> None
建立连接并完成初始化。
Open the WebSocket and send the session config.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
instructions | str | 指令(类型 `str`)。The instructions. |
tools默认default None | list[dict] | None | 工具列表(类型 `list[dict] | None`)。The tools. |
kwargs | Any | 关键字参数(类型 `Any`)。The kwargs. |
agentscope/realtime/_dashscope/_model.py:120–171close
async def close() -> None
关闭连接并释放相关资源。
Stop reading and close the WebSocket.
agentscope/realtime/_dashscope/_model.py:173–176events
async def events() -> AsyncIterator[me.ModelEvent]
返回事件。
Yield events until the session ends.
agentscope/realtime/_dashscope/_model.py:192–199push_audio
async def push_audio(pcm: bytes) -> None
设置推送音频。
Append PCM16 mono audio at 16 kHz to the input buffer.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
pcm | bytes | pcm(类型 `bytes`)。The pcm. |
agentscope/realtime/_dashscope/_model.py:205–212push_text
async def push_text(text: str) -> None
设置推送文本。
Unsupported: the API accepts audio and images only.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | str | 文本(类型 `str`)。The text. |
agentscope/realtime/_dashscope/_model.py:214–218push_tool_result
async def push_tool_result(block: ToolResultBlock) -> None
设置推送工具结果。
Send a function_call_output item.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
block | ToolResultBlock | 内容块(类型 `ToolResultBlock`)。The block. |
agentscope/realtime/_dashscope/_model.py:220–238commit_turn
async def commit_turn() -> None
返回提交轮次。
Commit the input buffer as one user turn.
agentscope/realtime/_dashscope/_model.py:240–242request_response
async def request_response() -> None
返回请求响应。
Ask for a reply, cancelling one already in flight first.
agentscope/realtime/_dashscope/_model.py:248–252cancel_response
async def cancel_response() -> None
返回取消响应。
Cancel the reply in flight, if any.
agentscope/realtime/_dashscope/_model.py:254–257嵌套类详情Nested Class Detail
Parameters
class Parameters参数,处理低延迟的实时语音与多模态交互。位于 agentscope.realtime 包,继承自 RealtimeModelBase.Parameters。
Tuneables surfaced to the UI. Declared in agentscope.realtime. Extends RealtimeModelBase.Parameters.