From 46ee30ced7da9be072e9e8b36df9941af37589c6 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Fri, 16 Feb 2024 22:31:32 +0800 Subject: [PATCH] use path as default model name --- main.go | 1 + process.go | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 5b624cd..ea23e0a 100644 --- a/main.go +++ b/main.go @@ -109,6 +109,7 @@ func main() { CreatedAt: time.Now(), Authorization: c.Request.Header.Get("Authorization"), UserAgent: c.Request.Header.Get("User-Agent"), + Model: c.Request.URL.Path, } // check authorization header diff --git a/process.go b/process.go index e337168..d3febf7 100644 --- a/process.go +++ b/process.go @@ -33,9 +33,6 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s path := strings.TrimPrefix(c.Request.URL.Path, "/v1") // recoognize whisper url - if strings.HasPrefix(path, "/audio/transcriptions") || strings.HasPrefix(path, "/audio/translations") { - record.Model = "whisper" - } remote.Path = upstream.URL.Path + path log.Println("[proxy.begin]:", remote) log.Println("[proxy.begin]: shouldResposne:", shouldResponse) @@ -65,7 +62,7 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s record.Body = string(inBody) requestBody, requestBodyOK := ParseRequestBody(inBody) // record if parse success - if requestBodyOK == nil && record.Model == "" { + if requestBodyOK == nil && requestBody.Model != "" { record.Model = requestBody.Model }