Browse Source

fix: use channel type to determine api type (close #321)

JustSong 2 years ago
parent
commit
c134604cee
1 changed files with 5 additions and 4 deletions
  1. 5 4
      controller/relay-text.go

+ 5 - 4
controller/relay-text.go

@@ -85,13 +85,14 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
 		}
 		}
 	}
 	}
 	apiType := APITypeOpenAI
 	apiType := APITypeOpenAI
-	if strings.HasPrefix(textRequest.Model, "claude") {
+	switch channelType {
+	case common.ChannelTypeAnthropic:
 		apiType = APITypeClaude
 		apiType = APITypeClaude
-	} else if strings.HasPrefix(textRequest.Model, "ERNIE") {
+	case common.ChannelTypeBaidu:
 		apiType = APITypeBaidu
 		apiType = APITypeBaidu
-	} else if strings.HasPrefix(textRequest.Model, "PaLM") {
+	case common.ChannelTypePaLM:
 		apiType = APITypePaLM
 		apiType = APITypePaLM
-	} else if strings.HasPrefix(textRequest.Model, "chatglm_") {
+	case common.ChannelTypeZhipu:
 		apiType = APITypeZhipu
 		apiType = APITypeZhipu
 	}
 	}
 	baseURL := common.ChannelBaseURLs[channelType]
 	baseURL := common.ChannelBaseURLs[channelType]