diff --git a/proto/status.go b/proto/status.go index 7b07867..1c8f29a 100644 --- a/proto/status.go +++ b/proto/status.go @@ -147,6 +147,7 @@ const ( ModelTypeQianfan = "qianfan" ModelTypeTongyi = "tongyi" ModelTypeHunyuan = "hunyuan" + ModelTypeGemini = "gemini" KnowledgeBaseServerResponseType = "kbase_query_resp" ) diff --git a/service/generalModel/openai.go b/service/generalModel/openai.go index 6445a5b..bf4c7ad 100644 --- a/service/generalModel/openai.go +++ b/service/generalModel/openai.go @@ -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) } } diff --git a/service/imService.go b/service/imService.go index cb2295a..b894c0e 100644 --- a/service/imService.go +++ b/service/imService.go @@ -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 }