24 lines
1.3 KiB
Go
24 lines
1.3 KiB
Go
package request
|
||
|
||
// Message 聊天消息结构体
|
||
type Message struct {
|
||
Role string `json:"role" form:"role" binding:"required"` // 角色: system, user, assistant
|
||
Content string `json:"content" form:"content" binding:"required"` // 消息内容
|
||
}
|
||
|
||
// ChatRequest 聊天请求结构体
|
||
type ChatRequest struct {
|
||
Messages []Message `json:"messages" form:"messages" binding:"required"` // 对话消息列表
|
||
Model string `json:"model" form:"model"` // 模型名称,如果为空则使用默认模型
|
||
Stream bool `json:"stream" form:"stream"` // 是否流式响应,默认false
|
||
Temperature float64 `json:"temperature" form:"temperature"` // 温度参数,控制随机性,范围0-1
|
||
MaxTokens int `json:"max_tokens" form:"max_tokens"` // 最大生成token数
|
||
TopP float64 `json:"top_p" form:"top_p"` // 核采样参数
|
||
RequestID string `json:"request_id,omitempty" form:"request_id,omitempty"` // 请求ID,用于流式响应管理
|
||
}
|
||
|
||
// StopRequest 停止生成请求结构体
|
||
type StopRequest struct {
|
||
RequestID string `json:"request_id" form:"request_id" binding:"required"` // 要停止的请求ID
|
||
}
|