AI-search plugin supports controlling through the web_search_options parameter. (#1893)

This commit is contained in:
澄潭
2025-03-14 21:52:33 +08:00
committed by GitHub
parent 26bfdd45ff
commit 5e7e20ff7e
3 changed files with 51 additions and 1 deletions

View File

@@ -11,12 +11,13 @@ description: higress 支持通过集成搜索引擎Google/Bing/Arxiv/Elastics
## 运行属性
插件执行阶段:`默认阶段`
插件执行优先级:`440`
插件执行优先级:`460`
## 配置字段
| 名称 | 数据类型 | 填写要求 | 默认值 | 描述 |
|------|----------|----------|--------|------|
| defaultEnable | bool | 选填 | true | 插件功能默认是否开启。设置为false时仅当请求中包含web_search_options字段时才启用插件功能 |
| needReference | bool | 选填 | false | 是否在回答中添加引用来源 |
| referenceFormat | string | 选填 | `"**References:**\n%s"` | 引用内容格式,必须包含%s占位符 |
| defaultLang | string | 选填 | - | 默认搜索语言代码如zh-CN/en-US |
@@ -242,6 +243,22 @@ searchRewrite:
timeoutMillisecond: 15000
```
### 按需启用插件配置
配置插件仅在请求中包含`web_search_options`字段时才启用:
```yaml
defaultEnable: false
searchFrom:
- type: google
apiKey: "your-google-api-key"
cx: "search-engine-id"
serviceName: "google-svc.dns"
servicePort: 443
```
这种配置适用于支持web_search选项的模型例如OpenAI的gpt-4o-search-preview模型。当请求中包含`web_search_options`字段时,即使是空对象(`"web_search_options": {}`),插件也会被激活。
## 注意事项
1. 提示词模版必须包含`{search_results}``{question}`占位符,可选使用`{cur_date}`插入当前日期格式2006年1月2日