添加doubao 图片功能日志输出
This commit is contained in:
parent
4d974e4eab
commit
13bcffa72d
15
proto/im.go
15
proto/im.go
|
|
@ -68,13 +68,14 @@ type SessionResponse struct {
|
|||
}
|
||||
|
||||
type IMParamContext struct {
|
||||
UserID int `json:"user_id"` //用户id
|
||||
SessionID int `json:"session_id"` //会话id
|
||||
FunctionID int `json:"function_id"` //功能id
|
||||
ModelID int `json:"model_id"` //模型id
|
||||
ModelType string `json:"model_type"` //模型类型
|
||||
Question string `json:"question"` //问题
|
||||
Channel string `json:"channel"` //消息队列
|
||||
UserID int `json:"user_id"` //用户id
|
||||
SessionID int `json:"session_id"` //会话id
|
||||
FunctionID int `json:"function_id"` //功能id
|
||||
ModelID int `json:"model_id"` //模型id
|
||||
ModelType string `json:"model_type"` //模型类型
|
||||
Question string `json:"question"` //问题
|
||||
Channel string `json:"channel"` //消息队列
|
||||
IsHasImage bool `json:"is_has_image"` //是否有图片
|
||||
}
|
||||
|
||||
// 用户向模型发送图片的消息结构
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ func DouBaoV2(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
|
|||
if err != nil {
|
||||
log.Println("get doubao session history message error:", err)
|
||||
}
|
||||
//messagesStr, _ := json.Marshal(messages)
|
||||
//log.Println("doubao messages:", string(messagesStr))
|
||||
messagesStr, _ := json.Marshal(messages)
|
||||
log.Println("doubao messages:", string(messagesStr))
|
||||
|
||||
req := model.CreateChatCompletionRequest{
|
||||
Model: modelParam.Model,
|
||||
|
|
@ -137,7 +137,9 @@ func DouBaoV2(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
|
|||
choices := recv.Choices[0]
|
||||
if choices.FinishReason == proto.FinishReasonStop {
|
||||
answer += choices.Delta.Content
|
||||
tokens += recv.Usage.TotalTokens
|
||||
if recv.Usage != nil {
|
||||
tokens += recv.Usage.TotalTokens
|
||||
}
|
||||
break
|
||||
} else {
|
||||
answer += choices.Delta.Content
|
||||
|
|
|
|||
Loading…
Reference in New Issue