Add dynamic variables support in session management and UI components. Implement validation rules for dynamic variables in metadata, including key format and value constraints. Enhance session start handling to manage dynamic variable errors. Update documentation and tests to reflect new functionality.
This commit is contained in:
@@ -65,7 +65,11 @@ Rules:
|
||||
"mode": "audio"
|
||||
},
|
||||
"systemPrompt": "You are concise.",
|
||||
"greeting": "Hi, how can I help?"
|
||||
"greeting": "Hi, how can I help?",
|
||||
"dynamicVariables": {
|
||||
"customer_name": "Alice",
|
||||
"plan_tier": "Pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -74,6 +78,13 @@ Rules:
|
||||
- Client-side `metadata.services` is ignored.
|
||||
- Service config (including secrets) is resolved server-side (env/backend).
|
||||
- Client should pass stable IDs (`appId`, `channel`, `configVersionId`) plus small runtime overrides (e.g. `output`, `bargeIn`, greeting/prompt style hints).
|
||||
- `metadata.dynamicVariables` is optional and must be an object of string key/value pairs.
|
||||
- Key pattern: `^[a-zA-Z_][a-zA-Z0-9_]{0,63}$`
|
||||
- Max entries: 30
|
||||
- Max value length: 1000 chars
|
||||
- Placeholder format in `systemPrompt` and `greeting`: `{{variable_name}}`.
|
||||
- Missing referenced placeholders reject `session.start` with `protocol.dynamic_variables_missing`.
|
||||
- Invalid `dynamicVariables` payload rejects `session.start` with `protocol.dynamic_variables_invalid`.
|
||||
|
||||
Text-only mode:
|
||||
- Set `metadata.output.mode = "text"`.
|
||||
|
||||
@@ -105,7 +105,11 @@
|
||||
"mode": "audio"
|
||||
},
|
||||
"systemPrompt": "你是简洁助手",
|
||||
"greeting": "你好,我能帮你什么?"
|
||||
"greeting": "你好,我能帮你什么?",
|
||||
"dynamicVariables": {
|
||||
"customer_name": "Alice",
|
||||
"plan_tier": "Pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -135,12 +139,22 @@
|
||||
- `bargeIn`
|
||||
- `knowledge`
|
||||
- `knowledgeBaseId`
|
||||
- `openerAudio`
|
||||
- `history`
|
||||
- `userId`
|
||||
- `assistantId`
|
||||
- `source`
|
||||
- `dynamicVariables`
|
||||
- 客户端传入 `metadata.services` 会被忽略(服务端会记录 warning),服务配置由后端/环境变量决定。
|
||||
|
||||
`metadata.dynamicVariables` 规则:
|
||||
- 可选;必须是 `object<string,string>`。
|
||||
- key 正则:`^[a-zA-Z_][a-zA-Z0-9_]{0,63}$`
|
||||
- 最多 30 个变量,单个 value 最长 1000 字符。
|
||||
- `systemPrompt` / `greeting` 中支持占位符语法:`{{variable_name}}`。
|
||||
- 若模板引用了缺失变量,`session.start` 会被拒绝,错误码 `protocol.dynamic_variables_missing`。
|
||||
- 若 `dynamicVariables` 结构/内容非法,`session.start` 会被拒绝,错误码 `protocol.dynamic_variables_invalid`。
|
||||
|
||||
`output.mode` 用法:
|
||||
- `"audio"`(默认语音输出)
|
||||
- `"text"`(纯文本输出)
|
||||
@@ -517,4 +531,3 @@ Server <- output.audio.end
|
||||
Client -> session.stop
|
||||
Server <- session.stopped
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user