mirror of
https://github.com/alibaba/higress.git
synced 2026-06-10 05:07:30 +08:00
more optimize of ai search plugin (#1896)
This commit is contained in:
@@ -20,6 +20,7 @@ Plugin execution priority: `440`
|
||||
| defaultEnable | bool | Optional | true | Whether the plugin functionality is enabled by default. When set to false, the plugin will only be activated when the request contains a web_search_options field |
|
||||
| needReference | bool | Optional | false | Whether to add reference sources in the response |
|
||||
| referenceFormat | string | Optional | `"**References:**\n%s"` | Reference content format, must include %s placeholder |
|
||||
| referenceLocation | string | Optional | "head" | Reference position: "head" at the beginning of the response, "tail" at the end of the response |
|
||||
| defaultLang | string | Optional | - | Default search language code (e.g. zh-CN/en-US) |
|
||||
| promptTemplate | string | Optional | Built-in template | Prompt template, must include `{search_results}` and `{question}` placeholders |
|
||||
| searchFrom | array of object | Required | - | Refer to search engine configuration below, at least one engine must be configured |
|
||||
@@ -45,6 +46,7 @@ It is strongly recommended to enable this feature when using Arxiv or Elasticsea
|
||||
| llmUrl | string | Required | - | LLM service API URL |
|
||||
| llmModelName | string | Required | - | LLM model name |
|
||||
| timeoutMillisecond | number | Optional | 30000 | API call timeout (milliseconds) |
|
||||
| maxCount | number | Optional | 3 | Maximum number of search queries generated by the search rewrite |
|
||||
|
||||
## Search Engine Common Configuration
|
||||
|
||||
@@ -224,6 +226,18 @@ searchFrom:
|
||||
servicePort: 8080
|
||||
```
|
||||
|
||||
### Custom Reference Location
|
||||
|
||||
```yaml
|
||||
needReference: true
|
||||
referenceLocation: "tail" # Add references at the end of the response instead of the beginning
|
||||
searchFrom:
|
||||
- type: bing
|
||||
apiKey: "your-bing-key"
|
||||
serviceName: "search-service.dns"
|
||||
servicePort: 8080
|
||||
```
|
||||
|
||||
### Search Rewrite Configuration
|
||||
|
||||
```yaml
|
||||
@@ -258,6 +272,25 @@ searchFrom:
|
||||
|
||||
This configuration is suitable for models that support web search options, such as OpenAI's gpt-4o-search-preview model. When the request contains a `web_search_options` field, even if it's an empty object (`"web_search_options": {}`), the plugin will be activated.
|
||||
|
||||
### Search Context Size Configuration
|
||||
|
||||
You can dynamically adjust the number of search queries by adding a `search_context_size` parameter in the `web_search_options` field of the request:
|
||||
|
||||
```json
|
||||
{
|
||||
"web_search_options": {
|
||||
"search_context_size": "medium"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `search_context_size` supports three levels:
|
||||
- `low`: Generates 1 search query (suitable for simple questions)
|
||||
- `medium`: Generates 3 search queries (default)
|
||||
- `high`: Generates 5 search queries (suitable for complex questions)
|
||||
|
||||
This setting overrides the `maxCount` value in the configuration, allowing clients to dynamically adjust search depth based on question complexity.
|
||||
|
||||
## Notes
|
||||
|
||||
1. The prompt template must include `{search_results}` and `{question}` placeholders, optionally use `{cur_date}` to insert current date (format: January 2, 2006)
|
||||
|
||||
Reference in New Issue
Block a user