From c134604cee3fed967165ffe7f879a980cf235d1f Mon Sep 17 00:00:00 2001 From: JustSong Date: Mon, 24 Jul 2023 23:34:14 +0800 Subject: [PATCH] fix: use channel type to determine api type (close #321) --- controller/relay-text.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/controller/relay-text.go b/controller/relay-text.go index 25a10679..52e10f2b 100644 --- a/controller/relay-text.go +++ b/controller/relay-text.go @@ -85,13 +85,14 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode { } } apiType := APITypeOpenAI - if strings.HasPrefix(textRequest.Model, "claude") { + switch channelType { + case common.ChannelTypeAnthropic: apiType = APITypeClaude - } else if strings.HasPrefix(textRequest.Model, "ERNIE") { + case common.ChannelTypeBaidu: apiType = APITypeBaidu - } else if strings.HasPrefix(textRequest.Model, "PaLM") { + case common.ChannelTypePaLM: apiType = APITypePaLM - } else if strings.HasPrefix(textRequest.Model, "chatglm_") { + case common.ChannelTypeZhipu: apiType = APITypeZhipu } baseURL := common.ChannelBaseURLs[channelType]