添加国外服务器中转ai请求数据,添加gemini
This commit is contained in:
parent
270d3c3535
commit
62e6ef7eb0
|
|
@ -141,7 +141,7 @@ func OpenAIToGeneralMassageAndSendMsgQueue(data *openai.ChatCompletionChunk, cha
|
|||
var apiMsg api.GenerateResponse
|
||||
apiMsg.Model = proto.ModelTypeSpark
|
||||
apiMsg.Response = data.Choices[0].Delta.Content
|
||||
if data.Created < 0 { //这里由于没有返回结束标志,所以用该字段来判断
|
||||
if data.Created < 0 || data.Choices[0].FinishReason != "" { //这里由于没有返回结束标志,所以用该字段来判断
|
||||
apiMsg.Done = true
|
||||
} else {
|
||||
apiMsg.Done = false
|
||||
|
|
@ -286,6 +286,10 @@ func DoOpenAIForeignAICallBack(chunk openai.ChatCompletionChunk, modelParam prot
|
|||
|
||||
// 处理国外服务器返回的模型消息
|
||||
func OpenAIForeignAIResponseToGeneralMassageAndSendMsgQueue(data *proto.ReceiveMessageForeignAIRRequest) {
|
||||
chunk := data.ChatCompletionChunk
|
||||
imCtx := &data.IMParamContext
|
||||
msgStr, _ := json.Marshal(chunk)
|
||||
go dao.InsertAIStreamMsgToDB(imCtx.UserID, imCtx.SessionID, uint(imCtx.ModelID), string(msgStr), data.ModelParam.Model) //存入数据库
|
||||
//转入队列
|
||||
OpenAIToGeneralMassageAndSendMsgQueue(&data.ChatCompletionChunk, data.IMParamContext.Channel, data.IMParamContext.SessionID, data.IMParamContext.UserID)
|
||||
//保存消息,流式需要暂存消息使用redis
|
||||
|
|
@ -300,7 +304,7 @@ func OpenAIForeignAIResponseToGeneralMassageAndSendMsgQueue(data *proto.ReceiveM
|
|||
//if PromptTokensStr != "" {
|
||||
// PromptTokens, _ = strconv.ParseInt(PromptTokensStr, 10, 64)
|
||||
//}
|
||||
chunk := data.ChatCompletionChunk
|
||||
|
||||
if len(chunk.Choices) > 0 {
|
||||
if proto.Config.LOG_OUTPUT {
|
||||
log.Printf("openai_%s stream msg:%s\n", data.PlatForm, chunk.Choices[0].Delta.Content)
|
||||
|
|
|
|||
Loading…
Reference in New Issue