From fcd4d2eaaf5148222199c65df3909239854afbf1 Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 21 Sep 2024 22:39:30 +0800 Subject: [PATCH] chore: use ctxkey.RequestModel to eliminate hardcoding --- relay/adaptor/ali/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/relay/adaptor/ali/main.go b/relay/adaptor/ali/main.go index 759e08b1..ec5848ce 100644 --- a/relay/adaptor/ali/main.go +++ b/relay/adaptor/ali/main.go @@ -3,6 +3,7 @@ package ali import ( "bufio" "encoding/json" + "github.com/songquanpeng/one-api/common/ctxkey" "github.com/songquanpeng/one-api/common/render" "io" "net/http" @@ -102,9 +103,9 @@ func EmbeddingHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStat StatusCode: resp.StatusCode, }, nil } - reqeustModel := c.Keys["request_model"] + requestModel := c.GetString(ctxkey.RequestModel) fullTextResponse := embeddingResponseAli2OpenAI(&aliResponse) - fullTextResponse.Model = reqeustModel.(string) + fullTextResponse.Model = requestModel jsonResponse, err := json.Marshal(fullTextResponse) if err != nil { return openai.ErrorWrapper(err, "marshal_response_body_failed", http.StatusInternalServerError), nil