mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-14 20:23:46 +08:00
🎨 结构中继控制器
This commit is contained in:
@@ -73,7 +73,7 @@ func (p *BaiduProvider) ChatAction(request *types.ChatCompletionRequest, isModel
|
||||
requestBody := p.getChatRequestBody(request)
|
||||
fullRequestURL := p.GetFullRequestURL(p.ChatCompletions, request.Model)
|
||||
if fullRequestURL == "" {
|
||||
return nil, types.ErrorWrapper(nil, "invalid_baidu_config", http.StatusInternalServerError)
|
||||
return nil, common.ErrorWrapper(nil, "invalid_baidu_config", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
headers := p.GetRequestHeaders()
|
||||
@@ -84,7 +84,7 @@ func (p *BaiduProvider) ChatAction(request *types.ChatCompletionRequest, isModel
|
||||
client := common.NewClient()
|
||||
req, err := client.NewRequest(p.Context.Request.Method, fullRequestURL, common.WithBody(requestBody), common.WithHeader(headers))
|
||||
if err != nil {
|
||||
return nil, types.ErrorWrapper(err, "new_request_failed", http.StatusInternalServerError)
|
||||
return nil, common.ErrorWrapper(err, "new_request_failed", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if request.Stream {
|
||||
@@ -130,7 +130,7 @@ func (p *BaiduProvider) sendStreamRequest(req *http.Request) (usage *types.Usage
|
||||
// 发送请求
|
||||
resp, err := common.HttpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, types.ErrorWrapper(err, "http_request_failed", http.StatusInternalServerError)
|
||||
return nil, common.ErrorWrapper(err, "http_request_failed", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if common.IsFailureStatusCode(resp) {
|
||||
|
||||
@@ -48,14 +48,14 @@ func (p *BaiduProvider) EmbeddingsAction(request *types.EmbeddingRequest, isMode
|
||||
requestBody := p.getEmbeddingsRequestBody(request)
|
||||
fullRequestURL := p.GetFullRequestURL(p.Embeddings, request.Model)
|
||||
if fullRequestURL == "" {
|
||||
return nil, types.ErrorWrapper(nil, "invalid_baidu_config", http.StatusInternalServerError)
|
||||
return nil, common.ErrorWrapper(nil, "invalid_baidu_config", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
headers := p.GetRequestHeaders()
|
||||
client := common.NewClient()
|
||||
req, err := client.NewRequest(p.Context.Request.Method, fullRequestURL, common.WithBody(requestBody), common.WithHeader(headers))
|
||||
if err != nil {
|
||||
return nil, types.ErrorWrapper(err, "new_request_failed", http.StatusInternalServerError)
|
||||
return nil, common.ErrorWrapper(err, "new_request_failed", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
baiduEmbeddingResponse := &BaiduEmbeddingResponse{}
|
||||
|
||||
Reference in New Issue
Block a user