package mistral import ( "net/http" "one-api/common" "one-api/types" ) func (p *MistralProvider) CreateEmbeddings(request *types.EmbeddingRequest) (*types.EmbeddingResponse, *types.OpenAIErrorWithStatusCode) { url, errWithCode := p.GetSupportedAPIUri(common.RelayModeEmbeddings) if errWithCode != nil { return nil, errWithCode } // 获取请求地址 fullRequestURL := p.GetFullRequestURL(url, request.Model) if fullRequestURL == "" { return nil, common.ErrorWrapper(nil, "invalid_mistral_config", http.StatusInternalServerError) } // 获取请求头 headers := p.GetRequestHeaders() // 创建请求 req, err := p.Requester.NewRequest(http.MethodPost, fullRequestURL, p.Requester.WithBody(request), p.Requester.WithHeader(headers)) if err != nil { return nil, common.ErrorWrapper(err, "new_request_failed", http.StatusInternalServerError) } defer req.Body.Close() mistralResponse := &types.EmbeddingResponse{} // 发送请求 _, errWithCode = p.Requester.SendRequest(req, mistralResponse, false) if errWithCode != nil { return nil, errWithCode } return mistralResponse, nil }