mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-31 04:45:23 +08:00
doc: add comment for query variables
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 309 KiB After Width: | Height: | Size: 104 KiB |
@@ -255,11 +255,16 @@
|
||||
|
||||

|
||||
|
||||
### 请求变量
|
||||
|
||||
当使用工作流时,LangBot 会显式传入以下参数,您可以自行在 Dify 工作流的开始节点中添加:
|
||||
|
||||
- `langbot_user_message_text`:用户消息的纯文本
|
||||
- `langbot_session_id`:用户会话id,私聊为 `person_<id>`,群聊为 `group_<id>`
|
||||
- `langbot_conversation_id`:用户会话id,由 LangBot 生成。用户重置会话后,会重新生成
|
||||
- `user_message_text`:用户消息的纯文本
|
||||
- `session_id`:用户会话id,私聊为 `person_<id>`,群聊为 `group_<id>`
|
||||
- `conversation_id`:字符串,用户会话id,由 LangBot 生成。用户重置会话后,会重新生成
|
||||
- `msg_create_time`:数字类型,收到此消息的时间戳(秒)
|
||||
|
||||
您可以[通过插件自定义任何变量](/plugin/dev/api-ref.html#%E8%AE%BE%E7%BD%AE%E8%AF%B7%E6%B1%82%E5%8F%98%E9%87%8F)。
|
||||
|
||||

|
||||
|
||||
@@ -301,7 +306,8 @@
|
||||
- `workflow`:智能体编排应用的配置
|
||||
- `app-id`: "上图中的应用ID",
|
||||
- `references_quote`:引用来源的提示语,默认为`参考资料来自:` 如果你在智能体应用中添加了展示回答来源这个配置将会起作用
|
||||
- `biz_params`:业务参数,用于传入到智能体编排应用中,city和date对应下方第二章图中的`变量名`,二者的值是要传入的可在其中调用的参数
|
||||
- `biz_params`:业务参数,用于传入到智能体编排应用中,city和date对应下方第二章图中的`变量名`,二者的值是要传入的可在其中调用的参数。
|
||||
- 与上述 Dify 相同,LangBot 也会传入`请求变量`到百炼应用。
|
||||
|
||||
`references_quote`解释图片
|
||||
|
||||
|
||||
@@ -56,6 +56,46 @@ ctx.add_return(name: str, value: Any)
|
||||
|
||||
添加返回值,事件返回值均为**可选**的,每个事件支持的返回值请查看`pkg.plugin.events`中的每个事件的注释。
|
||||
|
||||
## 请求 API
|
||||
|
||||
`请求(Query)`指的是用户向 LangBot 发送一个问题时,LangBot 处理该问题的程序上下文。此段落的 API 用于与这些上下文交互。
|
||||
|
||||
- 事件处理函数中,Query 对象一般位于`ctx.event.query`
|
||||
|
||||
### 设置请求变量
|
||||
|
||||
```python
|
||||
ctx.event.query.set_variable(key: str, value: typing.Any)
|
||||
```
|
||||
|
||||
请求变量是与此次 Query 绑定的一个 `dict`,其中包含了一些程序上下文信息。如果使用的是 Dify 或者 阿里云百炼 等 LLMOps 的runner,[这些变量将被传入对应平台的 API 作为变量](/config/function/provider.html#%E8%AF%B7%E6%B1%82%E5%8F%98%E9%87%8F)。
|
||||
如果您需要使用插件设置变量,建议在`PromptPreProcessing`事件时处理。
|
||||
|
||||
- `key`:该变量的名称
|
||||
- `value`:该变量的值
|
||||
|
||||
### 获取请求变量
|
||||
|
||||
```python
|
||||
ctx.event.query.get_variable(key: str)
|
||||
```
|
||||
|
||||
获取请求变量。
|
||||
|
||||
- `key`:变量名称
|
||||
- 返回值:`typing.Any`
|
||||
|
||||
### 获取所有请求变量
|
||||
|
||||
```python
|
||||
ctx.event.query.get_variables()
|
||||
```
|
||||
|
||||
获取此 Query 对象所有已设置的变量值。
|
||||
|
||||
- 返回值:`dict[str, typing.Any]`
|
||||
|
||||
|
||||
## LangBot API
|
||||
|
||||
以下 API 是 LangBot 直接提供给插件调用的,可以在事件处理函数之外调用。
|
||||
|
||||
Reference in New Issue
Block a user