Files
ai_proxy/server/model/app/ai_request_log.go
2026-03-03 15:39:23 +08:00

28 lines
1.2 KiB
Go

package app
import (
"git.echol.cn/loser/ai_proxy/server/global"
"time"
)
// AiRequestLog AI请求日志
type AiRequestLog struct {
global.GVA_MODEL
UserID uint `json:"user_id" gorm:"index;comment:用户ID"`
BindingID uint `json:"binding_id" gorm:"index;comment:绑定ID"`
ProviderID uint `json:"provider_id" gorm:"index;comment:提供商ID"`
PresetID uint `json:"preset_id" gorm:"index;comment:预设ID"`
Model string `json:"model" gorm:"type:varchar(100);comment:使用的模型"`
PromptTokens int `json:"prompt_tokens" gorm:"comment:输入token数"`
CompletionTokens int `json:"completion_tokens" gorm:"comment:输出token数"`
TotalTokens int `json:"total_tokens" gorm:"comment:总token数"`
Duration int64 `json:"duration" gorm:"comment:请求耗时(毫秒)"`
Status string `json:"status" gorm:"type:varchar(20);index;comment:请求状态"` // success, error
ErrorMessage string `json:"error_message" gorm:"type:text;comment:错误信息"`
RequestTime time.Time `json:"request_time" gorm:"index;comment:请求时间"`
}
func (AiRequestLog) TableName() string {
return "ai_request_logs"
}