feat: support cloudflare AI gateway now (close #565, #598)

This commit is contained in:
JustSong
2023-10-14 15:26:28 +08:00
parent f073592d39
commit e28d4b1741
2 changed files with 10 additions and 4 deletions

View File

@@ -119,6 +119,11 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
baseURL = c.GetString("base_url")
}
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
if channelType == common.ChannelTypeOpenAI {
if strings.HasPrefix(baseURL, "https://gateway.ai.cloudflare.com") {
fullRequestURL = fmt.Sprintf("%s%s", baseURL, strings.TrimPrefix(requestURL, "/v1"))
}
}
switch apiType {
case APITypeOpenAI:
if channelType == common.ChannelTypeAzure {