refactor: only enable search when specified
This commit is contained in:
parent
23364e876b
commit
6048fd0791
@ -23,11 +23,11 @@ type AliInput struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AliParameters struct {
|
type AliParameters struct {
|
||||||
TopP float64 `json:"top_p,omitempty"`
|
TopP float64 `json:"top_p,omitempty"`
|
||||||
TopK int `json:"top_k,omitempty"`
|
TopK int `json:"top_k,omitempty"`
|
||||||
Seed uint64 `json:"seed,omitempty"`
|
Seed uint64 `json:"seed,omitempty"`
|
||||||
EnableSearch bool `json:"enable_search,omitempty"`
|
EnableSearch bool `json:"enable_search,omitempty"`
|
||||||
IncrementalOutput bool `json:"incremental_output,omitempty"`
|
IncrementalOutput bool `json:"incremental_output,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AliChatRequest struct {
|
type AliChatRequest struct {
|
||||||
@ -82,6 +82,8 @@ type AliChatResponse struct {
|
|||||||
AliError
|
AliError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AliEnableSearchModelSuffix = "-internet"
|
||||||
|
|
||||||
func requestOpenAI2Ali(request GeneralOpenAIRequest) *AliChatRequest {
|
func requestOpenAI2Ali(request GeneralOpenAIRequest) *AliChatRequest {
|
||||||
messages := make([]AliMessage, 0, len(request.Messages))
|
messages := make([]AliMessage, 0, len(request.Messages))
|
||||||
for i := 0; i < len(request.Messages); i++ {
|
for i := 0; i < len(request.Messages); i++ {
|
||||||
@ -91,17 +93,20 @@ func requestOpenAI2Ali(request GeneralOpenAIRequest) *AliChatRequest {
|
|||||||
Role: strings.ToLower(message.Role),
|
Role: strings.ToLower(message.Role),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
enableSearch := false
|
||||||
|
aliModel := request.Model
|
||||||
|
if strings.HasSuffix(aliModel, AliEnableSearchModelSuffix) {
|
||||||
|
enableSearch = true
|
||||||
|
aliModel = strings.TrimSuffix(aliModel, AliEnableSearchModelSuffix)
|
||||||
|
}
|
||||||
return &AliChatRequest{
|
return &AliChatRequest{
|
||||||
Model: request.Model,
|
Model: aliModel,
|
||||||
Input: AliInput{
|
Input: AliInput{
|
||||||
Messages: messages,
|
Messages: messages,
|
||||||
},
|
},
|
||||||
Parameters: AliParameters{ // ChatGPT's parameters are not compatible with Ali's
|
Parameters: AliParameters{
|
||||||
// TopP: request.TopP,
|
EnableSearch: enableSearch,
|
||||||
// TopK: 50,
|
IncrementalOutput: request.Stream,
|
||||||
// //Seed: 0,
|
|
||||||
EnableSearch: true,
|
|
||||||
IncrementalOutput=true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,13 @@ const EditChannel = () => {
|
|||||||
break;
|
break;
|
||||||
case 17:
|
case 17:
|
||||||
localModels = ['qwen-turbo', 'qwen-plus', 'qwen-max', 'qwen-max-longcontext', 'text-embedding-v1'];
|
localModels = ['qwen-turbo', 'qwen-plus', 'qwen-max', 'qwen-max-longcontext', 'text-embedding-v1'];
|
||||||
|
let withInternetVersion = [];
|
||||||
|
for (let i = 0; i < localModels.length; i++) {
|
||||||
|
if (localModels[i].startsWith('qwen-')) {
|
||||||
|
withInternetVersion.push(localModels[i] + '-internet');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
localModels = [...localModels, ...withInternetVersion];
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
localModels = ['chatglm_turbo', 'chatglm_pro', 'chatglm_std', 'chatglm_lite'];
|
localModels = ['chatglm_turbo', 'chatglm_pro', 'chatglm_std', 'chatglm_lite'];
|
||||||
|
Loading…
Reference in New Issue
Block a user