mirror of
https://github.com/alibaba/higress.git
synced 2026-04-22 20:47:36 +08:00
optimize model router&mapper (#1866)
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
## Function Description
|
||||
The `model-router` plugin implements the function of routing based on the model parameter in the LLM protocol.
|
||||
## Feature Description
|
||||
The `model-router` plugin implements routing functionality based on the model parameter in LLM protocols.
|
||||
|
||||
## Configuration Fields
|
||||
|
||||
| Name | Data Type | Filling Requirement | Default Value | Description |
|
||||
| ----------- | --------------- | ----------------------- | ------ | ------------------------------------------- |
|
||||
| `modelKey` | string | Optional | model | The location of the model parameter in the request body |
|
||||
| `addProviderHeader` | string | Optional | - | Which request header to place the provider name parsed from the model parameter |
|
||||
| `modelToHeader` | string | Optional | - | Which request header to directly place the model parameter |
|
||||
| `enableOnPathSuffix` | array of string | Optional | ["/v1/chat/completions"] | Only effective for requests with these specific path suffixes |
|
||||
| Name | Data Type | Requirement | Default Value | Description |
|
||||
| ----------- | --------------- | ----------------------- | ------ | ------------------------------------------- |
|
||||
| `modelKey` | string | Optional | model | Location of the model parameter in the request body |
|
||||
| `addProviderHeader` | string | Optional | - | Which request header to add the provider name parsed from the model parameter |
|
||||
| `modelToHeader` | string | Optional | - | Which request header to directly add the model parameter to |
|
||||
| `enableOnPathSuffix` | array of string | Optional | ["/v1/chat/completions"] | Only effective for requests with these specific path suffixes, can be configured as "*" to match all paths |
|
||||
|
||||
## Runtime Attributes
|
||||
## Runtime Properties
|
||||
|
||||
Plugin execution phase: Authentication phase
|
||||
Plugin execution priority: 900
|
||||
|
||||
## Effect Description
|
||||
|
||||
### Routing Based on the model Parameter
|
||||
### Routing Based on Model Parameter
|
||||
|
||||
The following configuration is required:
|
||||
The following configuration is needed:
|
||||
|
||||
```yaml
|
||||
modelToHeader: x-higress-llm-model
|
||||
```
|
||||
|
||||
The plugin will extract the model parameter from the request and set it in the x-higress-llm-model request header, which can be used for subsequent routing. For example, the original LLM request body:
|
||||
The plugin extracts the model parameter from the request and sets it to the x-higress-llm-model request header for subsequent routing. For example, the original LLM request body is:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -35,7 +35,7 @@ The plugin will extract the model parameter from the request and set it in the x
|
||||
"stream": false,
|
||||
"messages": [{
|
||||
"role": "user",
|
||||
"content": "What is the GitHub address of the main repository for the higress project"
|
||||
"content": "What is the GitHub address of the Higress project's main repository?"
|
||||
}],
|
||||
"presence_penalty": 0,
|
||||
"temperature": 0.7,
|
||||
@@ -43,21 +43,21 @@ The plugin will extract the model parameter from the request and set it in the x
|
||||
}
|
||||
```
|
||||
|
||||
After processing by this plugin, the following request header (which can be used for route matching) will be added:
|
||||
After processing by this plugin, the following request header will be added (can be used for route matching):
|
||||
|
||||
x-higress-llm-model: qwen-long
|
||||
|
||||
### Extracting the provider Field from the model Parameter for Routing
|
||||
### Extracting Provider Field from Model Parameter for Routing
|
||||
|
||||
> Note that this mode requires the client to specify the provider using a `/` separator in the model parameter.
|
||||
> Note that this mode requires the client to specify the provider in the model parameter using the `/` delimiter
|
||||
|
||||
The following configuration is required:
|
||||
The following configuration is needed:
|
||||
|
||||
```yaml
|
||||
addProviderHeader: x-higress-llm-provider
|
||||
```
|
||||
|
||||
The plugin will extract the provider part (if present) from the model parameter in the request and set it in the x-higress-llm-provider request header, which can be used for subsequent routing, and rewrite the model parameter to the model name part. For example, the original LLM request body:
|
||||
The plugin extracts the provider part (if any) from the model parameter in the request, sets it to the x-higress-llm-provider request header for subsequent routing, and rewrites the model parameter to only contain the model name part. For example, the original LLM request body is:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -67,7 +67,7 @@ The plugin will extract the provider part (if present) from the model parameter
|
||||
"stream": false,
|
||||
"messages": [{
|
||||
"role": "user",
|
||||
"content": "What is the GitHub address of the main repository for the higress project"
|
||||
"content": "What is the GitHub address of the Higress project's main repository?"
|
||||
}],
|
||||
"presence_penalty": 0,
|
||||
"temperature": 0.7,
|
||||
@@ -75,7 +75,7 @@ The plugin will extract the provider part (if present) from the model parameter
|
||||
}
|
||||
```
|
||||
|
||||
After processing by this plugin, the following request header (which can be used for route matching) will be added:
|
||||
After processing by this plugin, the following request header will be added (can be used for route matching):
|
||||
|
||||
x-higress-llm-provider: dashscope
|
||||
|
||||
@@ -89,7 +89,7 @@ The original LLM request body will be changed to:
|
||||
"stream": false,
|
||||
"messages": [{
|
||||
"role": "user",
|
||||
"content": "What is the GitHub address of the main repository for the higress project"
|
||||
"content": "What is the GitHub address of the Higress project's main repository?"
|
||||
}],
|
||||
"presence_penalty": 0,
|
||||
"temperature": 0.7,
|
||||
|
||||
Reference in New Issue
Block a user