This commit is contained in:
2025-09-09 16:05:39 +08:00
parent c88252272c
commit a416353c29
10 changed files with 532 additions and 27 deletions
+6 -25
View File
@@ -7,36 +7,17 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/pet"
petRequest "github.com/flipped-aurora/gin-vue-admin/server/model/pet/request"
petResponse "github.com/flipped-aurora/gin-vue-admin/server/model/pet/response"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/google/uuid"
"go.uber.org/zap"
)
// ChatRequest 聊天请求结构体
type ChatRequest struct {
Message string `json:"message" binding:"required"` // 用户消息
SessionId string `json:"sessionId"` // 会话ID,可选
Stream bool `json:"stream"` // 是否流式响应
Temperature float64 `json:"temperature"` // 温度参数
MaxTokens int `json:"maxTokens"` // 最大token数
Model string `json:"model"` // 模型名称
}
// ChatResponse 聊天响应结构体
type ChatResponse struct {
Message string `json:"message"` // AI回复消息
SessionId string `json:"sessionId"` // 会话ID
IsSensitive bool `json:"isSensitive"` // 是否包含敏感词
TokenCount int `json:"tokenCount"` // Token消耗数量
ResponseTime int64 `json:"responseTime"` // 响应时间(ms)
RequestId string `json:"requestId,omitempty"` // 请求ID
}
// StreamEvent 流式事件结构体
type StreamEvent struct {
Event string `json:"event"` // 事件类型: message, error, done
Data interface{} `json:"data"` // 事件数据
}
// 使用新定义的模型结构
type ChatRequest = petRequest.ChatRequest
type ChatResponse = petResponse.ChatResponse
type StreamEvent = petResponse.StreamEvent
// PetChatService 宠物聊天服务
type PetChatService struct{}