Enhance WebSocket session configuration by introducing an optional config.resolved event, which provides a public snapshot of the session's configuration. Update the API reference documentation to clarify the conditions under which this event is emitted and the details it includes. Modify session management to respect the new setting for emitting configuration details, ensuring sensitive information remains secure. Update tests to validate the new behavior and ensure compliance with the updated configuration schema.
This commit is contained in:
@@ -23,7 +23,7 @@ ws://<host>/ws?assistant_id=<assistant_id>
|
||||
```
|
||||
Client -> session.start
|
||||
Server <- session.started
|
||||
Server <- config.resolved
|
||||
Server <- (optional) config.resolved
|
||||
Client -> (binary pcm frames...)
|
||||
Server <- input.speech_started / transcript.delta / transcript.final
|
||||
Server <- assistant.response.delta / assistant.response.final
|
||||
@@ -237,7 +237,7 @@ Server <- session.stopped
|
||||
|---------|------|---------|
|
||||
| `audio_in` | ASR/VAD 输入侧事件 | `input.*`, `transcript.*` |
|
||||
| `audio_out` | 助手输出侧事件 | `assistant.*`, `output.audio.*`, `response.interrupted`, `metrics.ttfb` |
|
||||
| `control` | 会话控制事件 | `session.*`, `error`, `config.resolved`, `heartbeat` |
|
||||
| `control` | 会话控制事件 | `session.*`, `error`, `heartbeat`, `(optional) config.resolved` |
|
||||
|
||||
---
|
||||
|
||||
@@ -284,7 +284,8 @@ Server <- session.stopped
|
||||
|
||||
#### `config.resolved`
|
||||
|
||||
服务端最终配置快照,在 `session.started` 后立即发送。
|
||||
服务端返回的**公开配置快照**。
|
||||
默认不发送(SaaS 公网模式建议关闭);仅在 `WS_EMIT_CONFIG_RESOLVED=true` 时发送。
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -294,27 +295,19 @@ Server <- session.stopped
|
||||
"seq": 2,
|
||||
"trackId": "control",
|
||||
"config": {
|
||||
"assistantId": "asst_abc123",
|
||||
"configVersionId": "ver_xyz789",
|
||||
"channel": "web_debug",
|
||||
"output": {
|
||||
"mode": "audio"
|
||||
},
|
||||
"services": {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"model": "gpt-4"
|
||||
},
|
||||
"asr": {
|
||||
"provider": "sensevoice",
|
||||
"model": "paraformer"
|
||||
},
|
||||
"tts": {
|
||||
"provider": "aliyun",
|
||||
"model": "xiaoyun",
|
||||
"enabled": true
|
||||
}
|
||||
"tools": {
|
||||
"enabled": true,
|
||||
"count": 2
|
||||
},
|
||||
"tools": ["weather", "calculator"]
|
||||
"tracks": {
|
||||
"audio_in": "audio_in",
|
||||
"audio_out": "audio_out",
|
||||
"control": "control"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -322,13 +315,18 @@ Server <- session.stopped
|
||||
| 字段 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `trackId` | string | 固定为 `"control"` |
|
||||
| `config` | object | 已解析的运行时配置 |
|
||||
| `config.assistantId` | string | 助手 ID |
|
||||
| `config.configVersionId` | string | 配置版本 ID |
|
||||
| `config` | object | SaaS 安全的公开配置快照 |
|
||||
| `config.channel` | string | 回显 `session.start.metadata.channel`(如提供) |
|
||||
| `config.output` | object | 输出配置 |
|
||||
| `config.output.mode` | string | 输出模式:`"audio"` / `"text"` |
|
||||
| `config.services` | object | 服务配置(不包含密钥) |
|
||||
| `config.tools` | array | 可用工具列表 |
|
||||
| `config.tools.enabled` | boolean | 是否启用工具能力 |
|
||||
| `config.tools.count` | number | 可用工具数量(不暴露工具清单) |
|
||||
| `config.tracks` | object | 可用轨道列表 |
|
||||
|
||||
**不会返回以下内部字段**:
|
||||
- `assistantId` / `appId` / `configVersionId`
|
||||
- `services`(provider/model/baseUrl 等)
|
||||
- 系统提示词原文及其它内部编排细节
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user