添加国外服务器中转ai请求数据,添加gemini

This commit is contained in:
junleea 2025-05-13 11:14:14 +08:00
parent b334b8185d
commit 36c39974a7
3 changed files with 4 additions and 2 deletions

View File

@ -147,6 +147,7 @@ const (
ModelTypeQianfan = "qianfan"
ModelTypeTongyi = "tongyi"
ModelTypeHunyuan = "hunyuan"
ModelTypeGemini = "gemini"
KnowledgeBaseServerResponseType = "kbase_query_resp"
)

View File

@ -296,7 +296,6 @@ func OpenAIForeignAIResponseToGeneralMassageAndSendMsgQueue(data *proto.ReceiveM
//PromptTokens = chunk.Usage.PromptTokens
}
//将消息存入数据库
if chunk.Created < 0 { //这里由于没有返回结束标志,所以用该字段来判断
tokens := chunk.Usage.TotalTokens
PromptTokens := chunk.Usage.PromptTokens
@ -304,6 +303,6 @@ func OpenAIForeignAIResponseToGeneralMassageAndSendMsgQueue(data *proto.ReceiveM
DOSaveMessageAndToken(&data.IMParamContext, answer, "openai_"+data.PlatForm, tokens, PromptTokens)
} else {
//流式消息暂存到redis
worker.SetRedis(data.IMParamContext.Channel+"_stream_msg", answer)
worker.SetRedisWithExpire(data.IMParamContext.Channel+"_stream_msg", answer, time.Second*30)
}
}

View File

@ -174,6 +174,8 @@ func WSReceiveMessageServiceV2(modelParam proto.ModelParam, ctx *proto.IMParamCo
Tongyi(modelParam, ctx)
case proto.ModelTypeHunyuan:
generalModel.OpenAI(modelParam, ctx, ctx.ModelType)
case proto.ModelTypeGemini:
generalModel.OpenAIForeignAI(modelParam, ctx, ctx.ModelType)
default:
resErr, resID = errors.New("model type not exist:"+ctx.ModelType), 0
}