mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-16 08:04:10 +00:00
feat: support baichuan's models now (close #1057)
This commit is contained in:
7
relay/channel/baichuan/constants.go
Normal file
7
relay/channel/baichuan/constants.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package baichuan
|
||||
|
||||
var ModelList = []string{
|
||||
"Baichuan2-Turbo",
|
||||
"Baichuan2-Turbo-192k",
|
||||
"Baichuan-Text-Embedding",
|
||||
}
|
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/songquanpeng/one-api/common"
|
||||
"github.com/songquanpeng/one-api/relay/channel"
|
||||
"github.com/songquanpeng/one-api/relay/channel/ai360"
|
||||
"github.com/songquanpeng/one-api/relay/channel/baichuan"
|
||||
"github.com/songquanpeng/one-api/relay/channel/moonshot"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
"github.com/songquanpeng/one-api/relay/util"
|
||||
@@ -84,6 +85,8 @@ func (a *Adaptor) GetModelList() []string {
|
||||
return ai360.ModelList
|
||||
case common.ChannelTypeMoonshot:
|
||||
return moonshot.ModelList
|
||||
case common.ChannelTypeBaichuan:
|
||||
return baichuan.ModelList
|
||||
default:
|
||||
return ModelList
|
||||
}
|
||||
@@ -97,6 +100,8 @@ func (a *Adaptor) GetChannelName() string {
|
||||
return "360"
|
||||
case common.ChannelTypeMoonshot:
|
||||
return "moonshot"
|
||||
case common.ChannelTypeBaichuan:
|
||||
return "baichuan"
|
||||
default:
|
||||
return "openai"
|
||||
}
|
||||
|
@@ -55,7 +55,8 @@ func RelayTextHelper(c *gin.Context) *model.ErrorWithStatusCode {
|
||||
var requestBody io.Reader
|
||||
if meta.APIType == constant.APITypeOpenAI {
|
||||
// no need to convert request for openai
|
||||
if isModelMapped {
|
||||
shouldResetRequestBody := isModelMapped || meta.ChannelType == common.ChannelTypeBaichuan // frequency_penalty 0 is not acceptable for baichuan
|
||||
if shouldResetRequestBody {
|
||||
jsonStr, err := json.Marshal(textRequest)
|
||||
if err != nil {
|
||||
return openai.ErrorWrapper(err, "json_marshal_failed", http.StatusInternalServerError)
|
||||
|
Reference in New Issue
Block a user