From ae1670b9b890115d3a65d23da11725b81d3a4029 Mon Sep 17 00:00:00 2001 From: Sakurasan <1173092237@qq.com> Date: Sun, 28 May 2023 22:28:52 +0800 Subject: [PATCH] reset openai endpoint --- router/router.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/router/router.go b/router/router.go index c0a1972..7f0e132 100644 --- a/router/router.go +++ b/router/router.go @@ -13,6 +13,7 @@ import ( "net/http" "net/http/httputil" "opencatd-open/store" + "os" "strings" "time" @@ -90,6 +91,13 @@ type ChatCompletionResponse struct { } `json:"usage"` } +func init() { + if openai_endpoint := os.Getenv("openai_endpoint"); openai_endpoint != "" { + log.Println("replace %s to %s", baseUrl, openai_endpoint) + baseUrl = openai_endpoint + } +} + func AuthMiddleware() gin.HandlerFunc { return func(c *gin.Context) { if rootToken == "" {