feat(*): 模型计费与渠道目录 - 支持视频 Token 报价结算和稳定模型展示

This commit is contained in:
ddCat
2026-09-18 23:26:54 +08:00
parent 90add8c466
commit 1a79005d25
57 changed files with 2904 additions and 341 deletions

View File

@@ -132,6 +132,25 @@ export type LogicalModelQuote = {
quantity: number;
amountMicrocredits: number;
estimated: boolean;
videoTokenEstimate?: {
formulaTokens: number;
reservedTokens: number;
outputWidth: number;
outputHeight: number;
framesPerSecond: number;
outputSeconds: number;
referenceSeconds: number;
referenceDurationEstimated: boolean;
dimensionsEstimated: boolean;
reservationMarginPercent: number;
};
};
export type ModelQuoteRequest = {
logicalModelID?: string;
channelId?: string;
modelKey?: string;
intent: ModelRequestIntent;
};
export type ModelCatalogSource = "frontend" | "system";
@@ -148,6 +167,8 @@ export type PublicChannelModel = {
id: string;
modelKey: string;
displayName: string;
channelLabel?: string;
description?: string;
sortOrder?: number;
icon: string;
capability: string;
@@ -187,6 +208,12 @@ export function quoteLogicalModel(id: string, intent: ModelRequestIntent, signal
return http.post<{ quote: LogicalModelQuote }>(`/models/${encodeURIComponent(id)}/quote`, intent, { signal });
}
export function quoteModel(request: ModelQuoteRequest, signal?: AbortSignal) {
if (request.logicalModelID) return quoteLogicalModel(request.logicalModelID, request.intent, signal);
if (!request.channelId || !request.modelKey) return Promise.reject(new Error("请选择需要报价的系统模型"));
return http.post<{ quote: LogicalModelQuote }>("/model-catalog/quote", { channelId: request.channelId, modelKey: request.modelKey, intent: request.intent }, { signal });
}
export function listAdminLogicalModels() {
return http.get<{ models?: AdminLogicalModel[] }>("/admin/logical-models").then((result) => ({
models: Array.isArray(result?.models) ? result.models.filter(Boolean).map(normalizeAdminLogicalModel) : [],

View File

@@ -52,6 +52,8 @@ export type ChannelModel = {
modelKey: string;
providerModelKey: string;
displayName: string;
channelLabel?: string;
description?: string;
sortOrder?: number;
icon: string;
capability: "text" | "image" | "video" | "audio" | "";
@@ -96,6 +98,8 @@ export type ChannelModelMutation = {
modelKey: string;
providerModelKey?: string;
displayName?: string;
channelLabel?: string;
description?: string;
icon?: string;
capability: ChannelModel["capability"];
protocol?: ChannelModel["protocol"];
@@ -214,6 +218,8 @@ export type BillingOrder = {
outputTokens: number;
cachedTokens: number;
usageAvailable: boolean;
videoFormulaTokens?: number;
usageSource?: "provider" | "video_formula";
status: "reserved" | "running" | "settled" | "refunded" | "uncertain";
providerRequestId?: string;
error?: string;