mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-06 00:33:43 +08:00
feat: add OpenAI compatible channel (close #2091)
This commit is contained in:
@@ -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") {
|
||||
|
||||
@@ -51,5 +51,6 @@ const (
|
||||
BaiduV2
|
||||
XunfeiV2
|
||||
AliBailian
|
||||
OpenAICompatible
|
||||
Dummy
|
||||
)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user