diff --git a/src/posts/config/pipeline.md b/src/posts/config/pipeline.md index 9c790c023..3d41cb588 100644 --- a/src/posts/config/pipeline.md +++ b/src/posts/config/pipeline.md @@ -160,13 +160,62 @@ category: "strategy": "drop", "algo": "fixwin", "fixwin": { - "default": 60 + "default": { + "window-size": 60, + "limit": 60 + } } } ``` `strategy`:会话中的请求速率超过限制时的处理策略,`drop`为丢弃新请求,`wait`为等待请求速率降到限制以下 -`algo`: 使用的算法,目前仅支持 `fixwin` (固定窗口),即一分钟内最多处理多少个请求 +`algo`: 使用的算法,目前仅支持 `fixwin` (固定窗口),即窗口期内最多处理多少个请求,可自行实现其他限速算法,具体查看插件编写教程 -`fixwin`:具体速率设置,一分钟内最多处理多少个请求, 支持对特定session指定限速,格式为 {type}_{id},示例:group_12345678,person_12341234 \ No newline at end of file +`fixwin`:具体速率设置,设定的窗口期内最多处理多少个请求,支持对特定session指定限速,格式为 {type}_{id},示例:group_12345678,person_12341234 + +`window-size`:窗口期大小,单位秒 + +`limit`:窗口期内最多处理多少个请求 + +例如: + +```json +"fixwin": { + "default": { + "window-size": 60, + "limit": 60 + }, + "group_12345678": { + "window-size": 30, + "limit": 60 + }, + "person_12341234": { + "window-size": 60, + "limit": 60 + } +} +``` + +将设定: + +- 默认群窗口期60秒内最多处理60个请求 +- 群号为12345678的窗口期30秒内最多处理60个请求 +- 用户号为12341234的窗口期60秒内最多处理60个请求 + +## 对话历史记录截断 msg-truncate + +将在发送消息给模型之前对当前会话的历史消息进行截断,以限制传给模型的消息长度 + +```json +"msg-truncate": { + "method": "round", + "round": { + "max-round": 10 + } +} +``` + +`method`:截断方法,`round`为按回合截断,目前仅支持`round`,可自行实现其他截断方法,具体查看插件编写教程 + +`round`:按回合截断,`max-round`为最多保留多少回合的历史消息 diff --git a/src/posts/plugin/extension.md b/src/posts/plugin/extension.md index 253deacd1..c3be7fe1f 100644 --- a/src/posts/plugin/extension.md +++ b/src/posts/plugin/extension.md @@ -95,3 +95,12 @@ index: false - 装饰器:`pkg.platform.adapter.adapter_class(name: str)` - 参考实现:`pkg.platform.adapters/` - 使用方式:`data/config/platform.json`的`platform-adapters`中各个配置信息,将在初始化时自动根据`adapter`名称查找对应的适配器实现,并将配置传递给适配器以进行初始化。消息平台适配器实现复杂,建议多参考现有的实现。 + +### 对话历史消息截断器 + +新增一个对话历史消息截断器,在发送到模型之前对历史消息进行截断。 + +- 基类:`pkg.pipeline.msgtrun.truncator.Truncator` +- 装饰器:`pkg.pipeline.msgtrun.truncator.truncator_class(name: str)` +- 参考实现:`pkg.pipeline.msgtrun.truncators/` +- 使用方式:需要在`data/config/pipeline.json`的`msg-truncate`字段中设置需要使用的截断器`method`为新增的截断器名称。 \ No newline at end of file