fix(*): 模型目录 - 修复前台开关、系统模型价格与访问控制
This commit is contained in:
1 parent
5d9986f6c7
commit
1bb5d1423a
19 files changed
+989
-84
No files matched your search
@@ -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[]) {
|
||||
|
||||
Reference in new issue
Block a user