package v1 import ( "encoding/json" "github.com/gogf/gf/v2/frame/g" ) // ModelListReq 模型列表请求 type ModelListReq struct { g.Meta `path:"/models" method:"get" mime:"json" tags:"管理后台-模型" summary:"模型列表"` Page int `json:"page" d:"1" v:"min:1" dc:"页码"` PageSize int `json:"page_size" d:"20" v:"min:1|max:100" dc:"每页数量"` Category string `json:"category" dc:"模型分类筛选:chat/embedding/image/audio/rerank/video"` Vendor string `json:"vendor" dc:"研发厂商筛选:openai/anthropic/google/alibaba/deepseek等,空=不过滤"` Status string `json:"status" dc:"状态筛选:active/deprecated/offline"` Search string `json:"search" dc:"搜索关键词(模型名或显示名)"` PricingStatus string `json:"pricing_status" dc:"定价状态筛选:priced/unpriced"` } // ModelListRes 模型列表响应 type ModelListRes struct { List []ModelItem `json:"list"` Total int `json:"total"` Page int `json:"page"` PageSize int `json:"page_size"` } // ModelChannelInfo 模型关联的渠道信息 type ModelChannelInfo struct { ChannelID int64 `json:"channel_id"` ChannelName string `json:"channel_name"` Type int `json:"type"` } // ModelItem 模型信息 type ModelItem struct { ID int64 `json:"id"` ModelId string `json:"model_id"` ModelName string `json:"model_name"` Category string `json:"category"` Vendor string `json:"vendor"` // 研发厂商(空=未分类) Status string `json:"status"` MaxContext int `json:"max_context_tokens"` MaxOutput int `json:"max_output_tokens"` Capabilities map[string]bool `json:"capabilities"` Description string `json:"description"` Tags []string `json:"tags"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` DeprecatedAt *string `json:"deprecated_at"` SunsetDate *string `json:"sunset_date"` ReplacementModel string `json:"replacement_model"` // 定价摘要(来自 mdl_pricing 的 pricing JSONB) PricingMode string `json:"pricing_mode"` // "" | "token" | "per_request" | "tiered" | "per_second" InputPrice float64 `json:"input_price"` // $/1M tokens PerSecondPrices map[string]float64 `json:"per_second_prices,omitempty"` // 规格→$/秒(仅 per_second 模式) OutputPrice float64 `json:"output_price"` // $/1M tokens PerRequestPrice float64 `json:"per_request_price"` // $/request(按次计费模式) // 可用渠道列表(来自 chn_abilities + chn_channels) Channels []ModelChannelInfo `json:"channels"` } // ModelCreateReq 创建模型请求 type ModelCreateReq struct { g.Meta `path:"/models" method:"post" mime:"json" tags:"管理后台-模型" summary:"创建模型"` ModelId string `json:"model_id" v:"required|length:1,100#请输入模型标识|模型标识长度1-100" dc:"模型唯一标识"` ModelName string `json:"model_name" dc:"模型显示名称"` Category string `json:"category" v:"required|in:chat,embedding,image,audio,rerank,video#请选择分类|分类必须是 chat/embedding/image/audio/rerank/video" dc:"模型分类"` Vendor string `json:"vendor" v:"in:openai,anthropic,google,xai,mistral,cohere,meta,alibaba,bytedance,deepseek,zhipu,moonshot,minimax,baidu,tencent,xunfei,kuaishou,midjourney,suno#厂商值不合法" dc:"研发厂商(空=未分类)"` MaxContext int `json:"max_context_tokens" dc:"最大上下文 token 数"` MaxOutput int `json:"max_output_tokens" dc:"最大输出 token 数"` Capabilities map[string]bool `json:"capabilities" dc:"模型能力特性"` Description string `json:"description" dc:"模型描述"` Tags []string `json:"tags" dc:"标签列表"` } // ModelCreateRes 创建模型响应 type ModelCreateRes struct { ID int64 `json:"id"` } // ModelUpdateReq 更新模型请求 type ModelUpdateReq struct { g.Meta `path:"/models/{id}" method:"put" mime:"json" tags:"管理后台-模型" summary:"更新模型"` ID int64 `json:"id" in:"path" v:"required" dc:"模型ID"` ModelName string `json:"model_name" dc:"模型显示名称"` Category string `json:"category" v:"in:chat,embedding,image,audio,rerank,video" dc:"模型分类"` // Vendor 研发厂商;指针语义:nil=不更新,空串=清空回未分类,非空=设置(枚举校验在 logic 层做) Vendor *string `json:"vendor" dc:"研发厂商"` MaxContext int `json:"max_context_tokens" dc:"最大上下文 token 数"` MaxOutput int `json:"max_output_tokens" dc:"最大输出 token 数"` Capabilities map[string]bool `json:"capabilities" dc:"模型能力特性"` Description string `json:"description" dc:"模型描述"` Tags []string `json:"tags" dc:"标签列表"` Status string `json:"status" v:"in:active,deprecated,offline" dc:"状态"` SunsetDate *string `json:"sunset_date" dc:"下线日期(格式:YYYY-MM-DD,仅 deprecated 状态有效)"` ReplacementModel string `json:"replacement_model" dc:"推荐替代模型名"` } // ModelDeleteReq 删除模型请求 type ModelDeleteReq struct { g.Meta `path:"/models/{id}" method:"delete" mime:"json" tags:"管理后台-模型" summary:"删除模型"` ID int64 `json:"id" in:"path" v:"required" dc:"模型ID"` } // PricingItem 定价项(支持按次/按量/阶梯/按秒/特殊方案) type PricingItem struct { BillingMode string `json:"billing_mode" v:"required|in:token,per_request,tiered,per_second,special" dc:"计费模式(special 仅由特殊计费方案编辑器提交,不进通用模式下拉)"` MinTokens int64 `json:"min_tokens" dc:"阶梯起始 token 数"` MaxTokens *int64 `json:"max_tokens" dc:"阶梯结束 token 数(NULL=无上限)"` InputPrice float64 `json:"input_price" dc:"每 1M input token 价格"` OutputPrice float64 `json:"output_price" dc:"每 1M output token 价格"` PerRequestPrice *float64 `json:"per_request_price" dc:"按次单价(仅 per_request)"` CacheReadPrice float64 `json:"cache_read_price" dc:"缓存读取每 1M token 价格"` CacheCreationPrice float64 `json:"cache_creation_price" dc:"缓存创建每 1M token 价格"` PerSecondPrices map[string]float64 `json:"per_second_prices" dc:"按秒单价矩阵(仅 per_second):分辨率规格→每秒单价(本位币),\"*\"为兜底价,如 {\"480p\":0.25,\"720p\":0.5,\"*\":0.5}"` } // TimeSegmentItem 时段定价项(mdl_pricing.pricing JSONB 顶层 time_segments 数组元素)。 // 语义:按数组顺序先命中先生效(促销时段放前面覆盖常驻时段),未命中=默认价(乘数 1.0); // 最终费用 = 各项小计 × 租户乘数 × 时段乘数。 type TimeSegmentItem struct { Name string `json:"name" v:"required" dc:"时段名(写入计费快照)"` Days []int `json:"days" dc:"适用星期 1=周一..7=周日;空=每天"` StartTime string `json:"start_time" dc:"每日开始时刻 HH:MM;与 end_time 均空=全天"` EndTime string `json:"end_time" dc:"每日结束时刻 HH:MM;end