🎨 结构中继控制器

This commit is contained in:
MartialBE
2023-12-02 03:28:18 +08:00
parent 2114bc1982
commit be364ae09b
45 changed files with 1267 additions and 204 deletions

View File

@@ -25,13 +25,13 @@ func (c *ImageAzureResponse) ResponseHandler(resp *http.Response) (OpenAIRespons
operation_location := resp.Header.Get("operation-location")
if operation_location == "" {
return nil, types.ErrorWrapper(errors.New("image url is empty"), "get_images_url_failed", http.StatusInternalServerError)
return nil, common.ErrorWrapper(errors.New("image url is empty"), "get_images_url_failed", http.StatusInternalServerError)
}
client := common.NewClient()
req, err := client.NewRequest("GET", operation_location, common.WithHeader(c.Header))
if err != nil {
return nil, types.ErrorWrapper(err, "get_images_request_failed", http.StatusInternalServerError)
return nil, common.ErrorWrapper(err, "get_images_request_failed", http.StatusInternalServerError)
}
getImageAzureResponse := ImageAzureResponse{}
@@ -59,14 +59,14 @@ func (c *ImageAzureResponse) ResponseHandler(resp *http.Response) (OpenAIRespons
}
}
return nil, types.ErrorWrapper(errors.New("get image Timeout"), "get_images_url_failed", http.StatusInternalServerError)
return nil, common.ErrorWrapper(errors.New("get image Timeout"), "get_images_url_failed", http.StatusInternalServerError)
}
func (p *AzureProvider) ImageGenerationsAction(request *types.ImageRequest, isModelMapped bool, promptTokens int) (usage *types.Usage, errWithCode *types.OpenAIErrorWithStatusCode) {
requestBody, err := p.GetRequestBody(&request, isModelMapped)
if err != nil {
return nil, types.ErrorWrapper(err, "json_marshal_failed", http.StatusInternalServerError)
return nil, common.ErrorWrapper(err, "json_marshal_failed", http.StatusInternalServerError)
}
fullRequestURL := p.GetFullRequestURL(p.ImagesGenerations, request.Model)
@@ -75,7 +75,7 @@ func (p *AzureProvider) ImageGenerationsAction(request *types.ImageRequest, isMo
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.Model == "dall-e-2" {