package proto import ( "github.com/ollama/ollama/api" "gorm.io/gorm" ) type AIQueueMessage struct { Type string `json:"type"` //声明不同消息类型 ID uint `json:"id"` //消息id Msg api.GenerateResponse `json:"msg"` //原始消息 } type WSMessage struct { Code int `json:"code"` //返回码,0表示成功, 其它状态码 Type string `json:"type"` //接收及发送消息类型 Msg AIQueueMessage `json:"msg"` //消息内容,只进行转发,不做处理 SessionID int `json:"session_id"` //应用层会话id ToID int `json:"to_id"` //接收者id } type WSMessageReq struct { Type string `json:"type"` //接收及发送消息类型 Function string `json:"function"` //功能名称 Msg string `json:"msg"` //消息内容,只进行转发,不做处理 SessionID int `json:"session_id"` //应用层会话id ToID int `json:"to_id"` //接收者id ModelID uint `json:"model_id"` //模型id IsImage bool `json:"is_image"` //是否为图片(图片消息),如果是图片消息,则msg为图片消息结构为{"img_url":"","text":""} IsFile bool `json:"is_file"` //是否为文件(文件消息),如果是文件消息,则msg为文件消息结构为{"file_url":"","text":""} IsKBase bool `json:"is_kbase"` //是否为知识库消息 KBaseID uint `json:"kbase_id"` //知识库id,为知识库消息时必传 KBaseType string `json:"kbase_type"` //知识库模式,1为query 2为chat Temperature float32 `json:"temperature"` //温度,默认0.5,核采样阈值。取值越高随机性越强,即相同的问题得到的不同答案的可能性越大 TopP float32 `json:"top_p"` //doubao 模型的top_p参数 TopK float32 `json:"top_k"` //spark 模型的top_k参数 } type ModelParam struct { Model string `json:"model"` //模型名称 Domain string `json:"domain"` //domain参数,spark需要 Url string `json:"url"` //模型地址 APPID string `json:"appid"` //应用id APISecret string `json:"apiSecret"` //应用密钥 APIKey string `json:"apiKey"` //应用key System string `json:"system"` //系统参数 AccessKey string `json:"access_key"` //accessKey参数 SecretKey string `json:"secret_key"` //secretKey参数 //其他参数 Temperature float32 `json:"temperature"` //温度,默认0.5,核采样阈值。取值越高随机性越强,即相同的问题得到的不同答案的可能性越大 MaxTokens int `json:"maxTokens"` //最大生成长度,默认4096 TopK float32 `json:"topK"` //取概率最大的前k个词 TopP float32 `json:"topP"` //取 } func (m *ModelParam) SetDefaultParams() { if m.Temperature == 0 { m.Temperature = DefaultTemperature } if m.MaxTokens == 0 { m.MaxTokens = DefaultMaxTokens } if m.TopK == 0 { m.TopK = DefaultTopK } if m.TopP == 0 { m.TopP = DefaultTopP } } type SessionResponse struct { gorm.Model UserID int `gorm:"column:user_id"` //只能由用户创建 Name string `gorm:"column:name"` Context []int `gorm:"column:context;type:json"` //会话上下文 MsgCount int `gorm:"column:msg_count"` //消息数量 TokenUsage uint `gorm:"column:token_usage"` //token使用数量 } 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"` //消息队列 IsHasImage bool `json:"is_has_image"` //是否有图片 } type ImageMsgContent struct { ImgName string `json:"img_name"` //图片名称 ImgUrl string `json:"img_url"` //图片url } // 用户向模型发送图片的消息结构 type UserImageMsg struct { ImageContent []ImageMsgContent `json:"image_content"` //图片内容 Text string `json:"text"` //问题文本 } type UserFileResponse struct { ID int `json:"ID"` //文件ID FileID int `json:"FileID"` //文件ID UserFileName string `json:"UserFileName"` //用户文件名称 FileStoreName string `json:"file_store_name"` //文件存储名称 } type FileMessageContent struct { FileContent UserFileResponse `json:"file_content"` //文件内容 FileType string `json:"file_type"` //文件类型 } type UserFileMessage struct { FileContent []FileMessageContent `json:"file_content"` //文件内容 Text string `json:"text"` //问题文本 }