From 1fc17daa356e0aa9e83e7560c781a07d874ad32c Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Sun, 21 Jan 2024 15:37:12 +0800 Subject: [PATCH] deny allow list if unknown model --- process.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/process.go b/process.go index 739311b..a0b6ab2 100644 --- a/process.go +++ b/process.go @@ -59,6 +59,11 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s // record chat message from user record.Body = string(inBody) requestBody, requestBodyOK := ParseRequestBody(inBody) + // if there allow list and unknown body, return error + if len(upstream.Allow) > 0 && requestBodyOK != nil { + errCtx = append(errCtx, errors.New("[proxy.rewrite]: allow list but unknown model")) + return + } // record if parse success if requestBodyOK == nil { record.Model = requestBody.Model