feat: cache token stat.
This commit is contained in:
@@ -16,6 +16,8 @@ type AIAnalysisRecord struct {
|
||||
OutputTokens int `json:"outputTokens"`
|
||||
InputSizeBytes int `json:"inputSizeBytes"`
|
||||
OutputSizeBytes int `json:"outputSizeBytes"`
|
||||
CacheHitTokens int `json:"cacheHitTokens"`
|
||||
CacheMissTokens int `json:"cacheMissTokens"`
|
||||
DurationMs int64 `json:"durationMs"`
|
||||
OriginalFileSize int64 `json:"originalFileSize"`
|
||||
CompressedContentSize int64 `json:"compressedContentSize"`
|
||||
|
||||
+12
-8
@@ -6,10 +6,12 @@ import (
|
||||
|
||||
type AIPricingConfig struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"size:64;uniqueIndex" json:"name"`
|
||||
Provider string `gorm:"size:64" json:"provider"`
|
||||
InputPricePerMillion float64 `json:"inputPricePerMillion"`
|
||||
OutputPricePerMillion float64 `json:"outputPricePerMillion"`
|
||||
Name string `gorm:"size:64;uniqueIndex" json:"name"`
|
||||
Provider string `gorm:"size:64" json:"provider"`
|
||||
InputPricePerMillion float64 `json:"inputPricePerMillion"`
|
||||
OutputPricePerMillion float64 `json:"outputPricePerMillion"`
|
||||
CacheHitPricePerMillion float64 `json:"cacheHitPricePerMillion"`
|
||||
CacheMissPricePerMillion float64 `json:"cacheMissPricePerMillion"`
|
||||
}
|
||||
|
||||
func EnsureDefaultAIPricing(db *gorm.DB) error {
|
||||
@@ -21,9 +23,11 @@ func EnsureDefaultAIPricing(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
return db.Create(&AIPricingConfig{
|
||||
Name: "deepseek-v4-flash",
|
||||
Provider: "tencentmaas",
|
||||
InputPricePerMillion: 1,
|
||||
OutputPricePerMillion: 2,
|
||||
Name: "deepseek-v4-flash",
|
||||
Provider: "tencentmaas",
|
||||
InputPricePerMillion: 1,
|
||||
CacheHitPricePerMillion: 1,
|
||||
CacheMissPricePerMillion: 0.02,
|
||||
OutputPricePerMillion: 2,
|
||||
}).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user