feat(models): 统一模型规格价格与路由
This commit is contained in:
1 parent
d268a938e5
commit
236b850177
36 files changed
+3404
-421
No files matched your search
@@ -18,6 +18,8 @@ type ModelChannel struct {
|
||||
APIFormat string `json:"apiFormat" gorm:"size:24"`
|
||||
ConcurrencyLimit int `json:"concurrencyLimit"`
|
||||
ModelsJSON string `json:"modelsJson" gorm:"type:text"`
|
||||
// RetiredModelsJSON 记录已被一个模型家族吸收的上游 SKU,防止目录拉取时重新创建重复记录。
|
||||
RetiredModelsJSON string `json:"-" gorm:"type:text"`
|
||||
HeadersJSON string `json:"-" gorm:"type:text"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
@@ -28,6 +30,7 @@ type ChannelModel struct {
|
||||
ID string `json:"id" gorm:"primaryKey;size:36"`
|
||||
ChannelID string `json:"channelId" gorm:"size:36;index;uniqueIndex:idx_channel_model_key_active,priority:1,where:deleted_at IS NULL"`
|
||||
ModelKey string `json:"modelKey" gorm:"size:120;uniqueIndex:idx_channel_model_key_active,priority:2,where:deleted_at IS NULL"`
|
||||
ProviderModelKey string `json:"providerModelKey" gorm:"size:120"`
|
||||
DisplayName string `json:"displayName" gorm:"size:160"`
|
||||
Capability string `json:"capability" gorm:"size:32;index"`
|
||||
Protocol ChannelInterfaceType `json:"protocol" gorm:"size:32;index"`
|
||||
@@ -42,9 +45,39 @@ type ChannelModel struct {
|
||||
CapabilityConfigJSON string `json:"-" gorm:"type:text"`
|
||||
CapabilityVersion int64 `json:"capabilityVersion"`
|
||||
CapabilityConfig map[string]any `json:"capabilityConfig,omitempty" gorm:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
// PriceTiers 是系统渠道模型的价格真相。标量价格仅为旧调用与历史数据兼容,
|
||||
// 新的创作端报价必须按所选规格命中一个价格档。
|
||||
PriceTiers []ChannelModelPriceTier `json:"priceTiers" gorm:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
}
|
||||
|
||||
// ChannelModelPriceTier 表示渠道模型在一个规格组合下的可执行上游 SKU 和用户价格。
|
||||
// SelectorJSON 是规格选择器真相,例如 {"operation":"image_to_video","vquality":"720p",
|
||||
// "videoSeconds":"10"} 或 {"operation":"text_to_image","quality":"2k"}。
|
||||
// SelectorKey 是规范化 JSON,用于 PostgreSQL 的活动规格唯一约束。旧的 Resolution / VideoSeconds
|
||||
// 仅保留给历史 API 与升级回填,不能再作为 SKU 唯一性依据。
|
||||
type ChannelModelPriceTier struct {
|
||||
ID string `json:"id" gorm:"primaryKey;size:36"`
|
||||
ChannelModelID string `json:"channelModelId" gorm:"size:36;index;uniqueIndex:idx_channel_model_price_tier_active,priority:1,where:deleted_at IS NULL"`
|
||||
SelectorKey string `json:"selectorKey" gorm:"size:500;not null;default:{};uniqueIndex:idx_channel_model_price_tier_active,priority:2,where:deleted_at IS NULL"`
|
||||
SelectorJSON string `json:"-" gorm:"type:text;not null;default:{}"`
|
||||
Selector map[string]string `json:"selector,omitempty" gorm:"-"`
|
||||
Resolution string `json:"resolution" gorm:"size:24;not null;default:*"`
|
||||
VideoSeconds int `json:"videoSeconds" gorm:"not null;default:0"`
|
||||
ProviderModelKey string `json:"providerModelKey" gorm:"size:120"`
|
||||
BillingMode string `json:"billingMode" gorm:"size:32"`
|
||||
UnitPriceMicrocredits int64 `json:"unitPriceMicrocredits"`
|
||||
InputTokenPriceMicrocredits int64 `json:"inputTokenPriceMicrocredits"`
|
||||
OutputTokenPriceMicrocredits int64 `json:"outputTokenPriceMicrocredits"`
|
||||
CachedTokenPriceMicrocredits int64 `json:"cachedTokenPriceMicrocredits"`
|
||||
PriceConfigured bool `json:"priceConfigured" gorm:"index"`
|
||||
Enabled bool `json:"enabled" gorm:"index"`
|
||||
PriceVersion int64 `json:"priceVersion"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
}
|
||||
|
||||
type ApiCallLog struct {
|
||||
|
||||
Reference in new issue
Block a user