feat: add OpenAI compatible channel (close #2091)

This commit is contained in:
JustSong
2025-02-16 17:38:06 +08:00
parent 8b8cd03e85
commit cafd0a0327
7 changed files with 94 additions and 57 deletions

View File

@@ -17,6 +17,9 @@ func ResponseText2Usage(responseText string, modelName string, promptTokens int)
}
func GetFullRequestURL(baseURL string, requestURL string, channelType int) string {
if channelType == channeltype.OpenAICompatible {
return fmt.Sprintf("%s%s", strings.TrimSuffix(baseURL, "/"), strings.TrimPrefix(requestURL, "/v1"))
}
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
if strings.HasPrefix(baseURL, "https://gateway.ai.cloudflare.com") {

View File

@@ -51,5 +51,6 @@ const (
BaiduV2
XunfeiV2
AliBailian
OpenAICompatible
Dummy
)

View File

@@ -51,6 +51,7 @@ var ChannelBaseURLs = []string{
"https://qianfan.baidubce.com", // 47
"https://spark-api-open.xf-yun.com", // 48
"https://dashscope.aliyuncs.com", // 49
"", // 50
}
func init() {