129 lines
5.4 KiB
Go
129 lines
5.4 KiB
Go
package response
|
||
|
||
import (
|
||
"time"
|
||
|
||
"github.com/flipped-aurora/gin-vue-admin/server/model/pet"
|
||
)
|
||
|
||
// ChatResponse 宠物助手聊天响应结构体
|
||
type ChatResponse struct {
|
||
ID uint `json:"id"` // 消息ID
|
||
Message string `json:"message"` // AI回复消息内容
|
||
SessionId string `json:"sessionId"` // 会话ID
|
||
IsSensitive bool `json:"isSensitive"` // 是否包含敏感词
|
||
TokenCount int `json:"tokenCount"` // Token消耗数量
|
||
ResponseTime int64 `json:"responseTime"` // 响应时间(毫秒)
|
||
RequestId string `json:"requestId,omitempty"` // 请求ID,用于流式响应管理
|
||
Model string `json:"model,omitempty"` // 使用的模型名称
|
||
CreatedAt time.Time `json:"createdAt"` // 创建时间
|
||
FinishReason string `json:"finishReason,omitempty"` // 完成原因:stop/length/content_filter
|
||
}
|
||
|
||
// StreamEvent 流式事件结构体
|
||
type StreamEvent struct {
|
||
Event string `json:"event"` // 事件类型: message, error, done, start
|
||
Data interface{} `json:"data"` // 事件数据
|
||
}
|
||
|
||
// StreamMessageData 流式消息数据结构体
|
||
type StreamMessageData struct {
|
||
Delta string `json:"delta"` // 增量消息内容
|
||
SessionId string `json:"sessionId"` // 会话ID
|
||
RequestId string `json:"requestId"` // 请求ID
|
||
}
|
||
|
||
// StreamErrorData 流式错误数据结构体
|
||
type StreamErrorData struct {
|
||
Error string `json:"error"` // 错误信息
|
||
Code string `json:"code"` // 错误代码
|
||
RequestId string `json:"requestId"` // 请求ID
|
||
}
|
||
|
||
// StreamDoneData 流式完成数据结构体
|
||
type StreamDoneData struct {
|
||
Message string `json:"message"` // 完整消息内容
|
||
SessionId string `json:"sessionId"` // 会话ID
|
||
RequestId string `json:"requestId"` // 请求ID
|
||
TokenCount int `json:"tokenCount"` // Token消耗数量
|
||
ResponseTime int64 `json:"responseTime"` // 响应时间(毫秒)
|
||
IsSensitive bool `json:"isSensitive"` // 是否包含敏感词
|
||
FinishReason string `json:"finishReason"` // 完成原因
|
||
}
|
||
|
||
// ChatHistoryResponse 聊天历史响应结构体
|
||
type ChatHistoryResponse struct {
|
||
List []pet.PetAiAssistantConversations `json:"list"` // 对话记录列表
|
||
Total int64 `json:"total"` // 总记录数
|
||
Page int `json:"page"` // 当前页码
|
||
PageSize int `json:"pageSize"` // 每页大小
|
||
}
|
||
|
||
// SessionInfo 会话信息结构体
|
||
type SessionInfo struct {
|
||
SessionId string `json:"sessionId"` // 会话ID
|
||
LastUpdated time.Time `json:"lastUpdated"` // 最后更新时间
|
||
MessageCount int `json:"messageCount"` // 消息数量
|
||
FirstMessage string `json:"firstMessage"` // 第一条消息内容(用作会话标题)
|
||
CreatedAt time.Time `json:"createdAt"` // 创建时间
|
||
}
|
||
|
||
// SessionsResponse 会话列表响应结构体
|
||
type SessionsResponse struct {
|
||
List []SessionInfo `json:"list"` // 会话列表
|
||
Total int64 `json:"total"` // 总会话数
|
||
Page int `json:"page"` // 当前页码
|
||
PageSize int `json:"pageSize"` // 每页大小
|
||
}
|
||
|
||
// TokenUsage Token使用情况结构体
|
||
type TokenUsage struct {
|
||
PromptTokens int `json:"promptTokens"` // 输入token数
|
||
CompletionTokens int `json:"completionTokens"` // 输出token数
|
||
TotalTokens int `json:"totalTokens"` // 总token数
|
||
}
|
||
|
||
// ModelInfo 模型信息结构体
|
||
type ModelInfo struct {
|
||
Name string `json:"name"` // 模型名称
|
||
Description string `json:"description"` // 模型描述
|
||
MaxTokens int `json:"maxTokens"` // 最大token数
|
||
Available bool `json:"available"` // 是否可用
|
||
}
|
||
|
||
// ModelsResponse 可用模型列表响应结构体
|
||
type ModelsResponse struct {
|
||
Models []ModelInfo `json:"models"` // 模型列表
|
||
}
|
||
|
||
// StatsResponse 统计信息响应结构体
|
||
type StatsResponse struct {
|
||
TotalSessions int64 `json:"totalSessions"` // 总会话数
|
||
TotalMessages int64 `json:"totalMessages"` // 总消息数
|
||
TotalTokens int64 `json:"totalTokens"` // 总token消耗
|
||
LastChatTime *time.Time `json:"lastChatTime"` // 最后聊天时间
|
||
AverageResponse float64 `json:"averageResponse"` // 平均响应时间(毫秒)
|
||
SensitiveCount int64 `json:"sensitiveCount"` // 敏感词触发次数
|
||
PopularQuestions []string `json:"popularQuestions"` // 热门问题
|
||
}
|
||
|
||
// ExportResponse 导出响应结构体
|
||
type ExportResponse struct {
|
||
FileName string `json:"fileName"` // 文件名
|
||
FileSize int64 `json:"fileSize"` // 文件大小(字节)
|
||
DownloadUrl string `json:"downloadUrl"` // 下载链接
|
||
ExpiresAt int64 `json:"expiresAt"` // 过期时间戳
|
||
}
|
||
|
||
// HealthResponse 健康检查响应结构体
|
||
type HealthResponse struct {
|
||
Status string `json:"status"` // 服务状态:healthy/unhealthy
|
||
LLMService string `json:"llmService"` // LLM服务状态
|
||
SensitiveFilter string `json:"sensitiveFilter"` // 敏感词过滤状态
|
||
Database string `json:"database"` // 数据库状态
|
||
LastChecked time.Time `json:"lastChecked"` // 最后检查时间
|
||
ResponseTime int64 `json:"responseTime"` // 响应时间(毫秒)
|
||
ActiveSessions int `json:"activeSessions"` // 活跃会话数
|
||
QueuedRequests int `json:"queuedRequests"` // 排队请求数
|
||
}
|