From 929e43ef817c40fda8e6008f3a2433cd6dccef07 Mon Sep 17 00:00:00 2001 From: mrhaoji Date: Mon, 24 Jul 2023 22:37:57 +0800 Subject: [PATCH] fix: baseURL not working in APITypePaLM (#317) * fix: baseURL not working in APITypePaLM * chore: use the same logic as claude --------- Co-authored-by: JustSong --- controller/relay-text.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/relay-text.go b/controller/relay-text.go index 8dfdf6e1..25a10679 100644 --- a/controller/relay-text.go +++ b/controller/relay-text.go @@ -140,6 +140,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode { fullRequestURL += "?access_token=" + apiKey // TODO: access token expire in 30 days case APITypePaLM: fullRequestURL = "https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage" + if baseURL != "" { + fullRequestURL = fmt.Sprintf("%s/v1beta2/models/chat-bison-001:generateMessage", baseURL) + } apiKey := c.Request.Header.Get("Authorization") apiKey = strings.TrimPrefix(apiKey, "Bearer ") fullRequestURL += "?key=" + apiKey