fix(*): 模型目录 - 修复前台开关、系统模型价格与访问控制
This commit is contained in:
@@ -475,7 +475,20 @@ export function modelOptionsFromChannels(channels: ModelChannel[]) {
|
||||
|
||||
export function hasSystemModelPrice(channel: ModelChannel, model: string) {
|
||||
if (channel.scope !== "system") return true;
|
||||
return channel.modelCosts?.some((item) => item.model === model && Number.isFinite(item.unitPriceMicrocredits) && item.unitPriceMicrocredits >= 0) === true;
|
||||
const positive = (value: number | undefined) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
||||
return channel.modelCosts?.some((item) => {
|
||||
if (item.model !== model) return false;
|
||||
const tiers = item.logicalPriceTiers || [];
|
||||
if (tiers.length) {
|
||||
return tiers.some((tier) => tier.billingMode === "token"
|
||||
? [tier.inputTokenPriceMicrocredits, tier.outputTokenPriceMicrocredits, tier.cachedTokenPriceMicrocredits].some(positive)
|
||||
: positive(tier.unitPriceMicrocredits));
|
||||
}
|
||||
if (item.billingMode === "token") {
|
||||
return [item.inputTokenPriceMicrocredits, item.outputTokenPriceMicrocredits, item.cachedTokenPriceMicrocredits].some(positive);
|
||||
}
|
||||
return positive(item.unitPriceMicrocredits);
|
||||
}) === true;
|
||||
}
|
||||
|
||||
export function normalizeModelOptionValue(value: unknown, channels: ModelChannel[]) {
|
||||
|
||||
@@ -29,6 +29,7 @@ export type FeatureAvailability = {
|
||||
taskCenterEnabled: boolean;
|
||||
creditsEnabled: boolean;
|
||||
customChannelsEnabled: boolean;
|
||||
frontendModelsEnabled: boolean;
|
||||
desktopLocalChannelsEnabled: boolean;
|
||||
configured?: boolean;
|
||||
updatedBy?: string;
|
||||
@@ -40,6 +41,7 @@ export const defaultFeatureAvailability: FeatureAvailability = {
|
||||
taskCenterEnabled: true,
|
||||
creditsEnabled: true,
|
||||
customChannelsEnabled: true,
|
||||
frontendModelsEnabled: true,
|
||||
desktopLocalChannelsEnabled: false,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user