fix: update web search handling and request structure in adaptor and openai_request
This commit is contained in:
@@ -57,18 +57,24 @@ type GeneralOpenAIRequest struct {
|
|||||||
Dimensions int `json:"dimensions,omitempty"`
|
Dimensions int `json:"dimensions,omitempty"`
|
||||||
Modalities json.RawMessage `json:"modalities,omitempty"`
|
Modalities json.RawMessage `json:"modalities,omitempty"`
|
||||||
Audio json.RawMessage `json:"audio,omitempty"`
|
Audio json.RawMessage `json:"audio,omitempty"`
|
||||||
EnableThinking any `json:"enable_thinking,omitempty"` // ali
|
// gemini
|
||||||
THINKING json.RawMessage `json:"thinking,omitempty"` // doubao,zhipu_v4
|
ExtraBody json.RawMessage `json:"extra_body,omitempty"`
|
||||||
ExtraBody json.RawMessage `json:"extra_body,omitempty"`
|
//xai
|
||||||
SearchParameters any `json:"search_parameters,omitempty"` //xai
|
SearchParameters json.RawMessage `json:"search_parameters,omitempty"`
|
||||||
WebSearchOptions *WebSearchOptions `json:"web_search_options,omitempty"`
|
// claude
|
||||||
|
WebSearchOptions *WebSearchOptions `json:"web_search_options,omitempty"`
|
||||||
// OpenRouter Params
|
// OpenRouter Params
|
||||||
Usage json.RawMessage `json:"usage,omitempty"`
|
Usage json.RawMessage `json:"usage,omitempty"`
|
||||||
Reasoning json.RawMessage `json:"reasoning,omitempty"`
|
Reasoning json.RawMessage `json:"reasoning,omitempty"`
|
||||||
// Ali Qwen Params
|
// Ali Qwen Params
|
||||||
VlHighResolutionImages json.RawMessage `json:"vl_high_resolution_images,omitempty"`
|
VlHighResolutionImages json.RawMessage `json:"vl_high_resolution_images,omitempty"`
|
||||||
|
EnableThinking any `json:"enable_thinking,omitempty"`
|
||||||
// ollama Params
|
// ollama Params
|
||||||
Think json.RawMessage `json:"think,omitempty"`
|
Think json.RawMessage `json:"think,omitempty"`
|
||||||
|
// baidu v2
|
||||||
|
WebSearch json.RawMessage `json:"web_search,omitempty"`
|
||||||
|
// doubao,zhipu_v4
|
||||||
|
THINKING json.RawMessage `json:"thinking,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
||||||
|
|||||||
@@ -81,20 +81,23 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
|
|||||||
if strings.HasSuffix(info.UpstreamModelName, "-search") {
|
if strings.HasSuffix(info.UpstreamModelName, "-search") {
|
||||||
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-search")
|
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-search")
|
||||||
request.Model = info.UpstreamModelName
|
request.Model = info.UpstreamModelName
|
||||||
toMap := request.ToMap()
|
if len(request.WebSearch) == 0 {
|
||||||
toMap["web_search"] = map[string]any{
|
toMap := request.ToMap()
|
||||||
"enable": true,
|
toMap["web_search"] = map[string]any{
|
||||||
"enable_citation": true,
|
"enable": true,
|
||||||
"enable_trace": true,
|
"enable_citation": true,
|
||||||
"enable_status": false,
|
"enable_trace": true,
|
||||||
|
"enable_status": false,
|
||||||
|
}
|
||||||
|
return toMap, nil
|
||||||
}
|
}
|
||||||
return toMap, nil
|
return request, nil
|
||||||
}
|
}
|
||||||
return request, nil
|
return request, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) ConvertRerankRequest(c *gin.Context, relayMode int, request dto.RerankRequest) (any, error) {
|
func (a *Adaptor) ConvertRerankRequest(c *gin.Context, relayMode int, request dto.RerankRequest) (any, error) {
|
||||||
return nil, nil
|
return nil, errors.New("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error) {
|
func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user