fix: baseURL not working in APITypePaLM (#317)

* fix: baseURL not working in APITypePaLM

* chore: use the same logic as claude

---------

Co-authored-by: JustSong <songquanpeng@foxmail.com>
This commit is contained in:
mrhaoji 2023-07-24 22:37:57 +08:00 committed by GitHub
parent dce8bbe1ca
commit 929e43ef81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,6 +140,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
fullRequestURL += "?access_token=" + apiKey // TODO: access token expire in 30 days fullRequestURL += "?access_token=" + apiKey // TODO: access token expire in 30 days
case APITypePaLM: case APITypePaLM:
fullRequestURL = "https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage" 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 := c.Request.Header.Get("Authorization")
apiKey = strings.TrimPrefix(apiKey, "Bearer ") apiKey = strings.TrimPrefix(apiKey, "Bearer ")
fullRequestURL += "?key=" + apiKey fullRequestURL += "?key=" + apiKey