mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-22 02:06:38 +08:00
feat: support minimax
This commit is contained in:
parent
5e07ff85eb
commit
e0df8bbbda
@ -208,6 +208,7 @@ const (
|
|||||||
ChannelTypeLingYiWanWu = 31
|
ChannelTypeLingYiWanWu = 31
|
||||||
ChannelTypeAws = 33
|
ChannelTypeAws = 33
|
||||||
ChannelTypeCohere = 34
|
ChannelTypeCohere = 34
|
||||||
|
ChannelTypeMiniMax = 35
|
||||||
|
|
||||||
ChannelTypeDummy // this one is only for count, do not add any channel after this
|
ChannelTypeDummy // this one is only for count, do not add any channel after this
|
||||||
)
|
)
|
||||||
|
@ -7,3 +7,5 @@ var ModelList = []string{
|
|||||||
"yi-34b-chat-200k",
|
"yi-34b-chat-200k",
|
||||||
"yi-vl-plus",
|
"yi-vl-plus",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ChannelName = "lingyiwanwu"
|
||||||
|
13
relay/channel/minimax/constants.go
Normal file
13
relay/channel/minimax/constants.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package minimax
|
||||||
|
|
||||||
|
// https://www.minimaxi.com/document/guides/chat-model/V2?id=65e0736ab2845de20908e2dd
|
||||||
|
|
||||||
|
var ModelList = []string{
|
||||||
|
"abab6.5-chat",
|
||||||
|
"abab6.5s-chat",
|
||||||
|
"abab6-chat",
|
||||||
|
"abab5.5-chat",
|
||||||
|
"abab5.5s-chat",
|
||||||
|
}
|
||||||
|
|
||||||
|
var ChannelName = "minimax"
|
10
relay/channel/minimax/relay-minimax.go
Normal file
10
relay/channel/minimax/relay-minimax.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package minimax
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
relaycommon "one-api/relay/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
|
return fmt.Sprintf("%s/v1/text/chatcompletion_v2", info.BaseUrl), nil
|
||||||
|
}
|
@ -5,3 +5,5 @@ var ModelList = []string{
|
|||||||
"moonshot-v1-32k",
|
"moonshot-v1-32k",
|
||||||
"moonshot-v1-128k",
|
"moonshot-v1-128k",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ChannelName = "moonshot"
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"one-api/relay/channel"
|
"one-api/relay/channel"
|
||||||
"one-api/relay/channel/ai360"
|
"one-api/relay/channel/ai360"
|
||||||
"one-api/relay/channel/lingyiwanwu"
|
"one-api/relay/channel/lingyiwanwu"
|
||||||
|
"one-api/relay/channel/minimax"
|
||||||
"one-api/relay/channel/moonshot"
|
"one-api/relay/channel/moonshot"
|
||||||
relaycommon "one-api/relay/common"
|
relaycommon "one-api/relay/common"
|
||||||
"one-api/service"
|
"one-api/service"
|
||||||
@ -26,7 +27,8 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
if info.ChannelType == common.ChannelTypeAzure {
|
switch info.ChannelType {
|
||||||
|
case common.ChannelTypeAzure:
|
||||||
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
|
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
|
||||||
requestURL := strings.Split(info.RequestURLPath, "?")[0]
|
requestURL := strings.Split(info.RequestURLPath, "?")[0]
|
||||||
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, info.ApiVersion)
|
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, info.ApiVersion)
|
||||||
@ -37,9 +39,16 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
|||||||
|
|
||||||
requestURL = fmt.Sprintf("/openai/deployments/%s/%s", model_, task)
|
requestURL = fmt.Sprintf("/openai/deployments/%s/%s", model_, task)
|
||||||
return relaycommon.GetFullRequestURL(info.BaseUrl, requestURL, info.ChannelType), nil
|
return relaycommon.GetFullRequestURL(info.BaseUrl, requestURL, info.ChannelType), nil
|
||||||
}
|
case common.ChannelTypeMiniMax:
|
||||||
|
return minimax.GetRequestURL(info)
|
||||||
|
//case common.ChannelTypeCustom:
|
||||||
|
// url := info.BaseUrl
|
||||||
|
// url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
|
||||||
|
// return url, nil
|
||||||
|
default:
|
||||||
return relaycommon.GetFullRequestURL(info.BaseUrl, info.RequestURLPath, info.ChannelType), nil
|
return relaycommon.GetFullRequestURL(info.BaseUrl, info.RequestURLPath, info.ChannelType), nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, info *relaycommon.RelayInfo) error {
|
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, info *relaycommon.RelayInfo) error {
|
||||||
channel.SetupApiRequestHeader(info, c, req)
|
channel.SetupApiRequestHeader(info, c, req)
|
||||||
@ -90,11 +99,24 @@ func (a *Adaptor) GetModelList() []string {
|
|||||||
return moonshot.ModelList
|
return moonshot.ModelList
|
||||||
case common.ChannelTypeLingYiWanWu:
|
case common.ChannelTypeLingYiWanWu:
|
||||||
return lingyiwanwu.ModelList
|
return lingyiwanwu.ModelList
|
||||||
|
case common.ChannelTypeMiniMax:
|
||||||
|
return minimax.ModelList
|
||||||
default:
|
default:
|
||||||
return ModelList
|
return ModelList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) GetChannelName() string {
|
func (a *Adaptor) GetChannelName() string {
|
||||||
|
switch a.ChannelType {
|
||||||
|
case common.ChannelType360:
|
||||||
|
return ai360.ChannelName
|
||||||
|
case common.ChannelTypeMoonshot:
|
||||||
|
return moonshot.ChannelName
|
||||||
|
case common.ChannelTypeLingYiWanWu:
|
||||||
|
return lingyiwanwu.ChannelName
|
||||||
|
case common.ChannelTypeMiniMax:
|
||||||
|
return minimax.ChannelName
|
||||||
|
default:
|
||||||
return ChannelName
|
return ChannelName
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user