67 lines
2.4 KiB
Go
67 lines
2.4 KiB
Go
package response
|
|
|
|
// ChatCompletionResponse OpenAI兼容的聊天响应
|
|
type ChatCompletionResponse struct {
|
|
ID string `json:"id"`
|
|
Object string `json:"object"`
|
|
Created int64 `json:"created"`
|
|
Model string `json:"model"`
|
|
Choices []ChatCompletionChoice `json:"choices"`
|
|
Usage *ChatCompletionUsage `json:"usage,omitempty"`
|
|
// 统一格式的用量统计(用于各种上游的标准化)
|
|
StandardUsage *ChatCompletionUsage `json:"standard_usage,omitempty"`
|
|
}
|
|
|
|
type ChatCompletionChoice struct {
|
|
Index int `json:"index"`
|
|
Message ChatMessage `json:"message"`
|
|
FinishReason string `json:"finish_reason"`
|
|
}
|
|
|
|
type ChatMessage struct {
|
|
Role string `json:"role"`
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
type ChatCompletionUsage struct {
|
|
PromptTokens int `json:"prompt_tokens"`
|
|
CompletionTokens int `json:"completion_tokens"`
|
|
TotalTokens int `json:"total_tokens"`
|
|
}
|
|
|
|
// ChatCompletionStreamResponse 流式响应
|
|
type ChatCompletionStreamResponse struct {
|
|
ID string `json:"id"`
|
|
Object string `json:"object"`
|
|
Created int64 `json:"created"`
|
|
Model string `json:"model"`
|
|
Choices []ChatCompletionStreamChoice `json:"choices"`
|
|
}
|
|
|
|
type ChatCompletionStreamChoice struct {
|
|
Index int `json:"index"`
|
|
Delta ChatMessageDelta `json:"delta"`
|
|
FinishReason *string `json:"finish_reason"`
|
|
}
|
|
|
|
type ChatMessageDelta struct {
|
|
Role string `json:"role,omitempty"`
|
|
Content string `json:"content,omitempty"`
|
|
}
|
|
|
|
// RegexExecutionLogs 正则脚本执行日志
|
|
type RegexExecutionLogs struct {
|
|
InputScripts []RegexScriptLog `json:"input_scripts,omitempty"` // 输入前执行的脚本
|
|
OutputScripts []RegexScriptLog `json:"output_scripts,omitempty"` // 输出后执行的脚本
|
|
TotalMatches int `json:"total_matches"` // 总匹配次数
|
|
}
|
|
|
|
// RegexScriptLog 单个正则脚本的执行日志
|
|
type RegexScriptLog struct {
|
|
ScriptName string `json:"script_name"` // 脚本名称
|
|
ScriptID string `json:"script_id"` // 脚本ID
|
|
Executed bool `json:"executed"` // 是否执行
|
|
MatchCount int `json:"match_count"` // 匹配次数
|
|
ErrorMessage string `json:"error_message,omitempty"` // 错误信息
|
|
}
|