fix: align model availability and retail pricing controls
This commit is contained in:
1 parent
af505c5596
commit
813b406da4
9 files changed
+130
-47
No files matched your search
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## 本轮范围
|
## 本轮范围
|
||||||
|
|
||||||
|
### 系统页面补齐
|
||||||
|
|
||||||
|
模型广场、详情、试用提示及 Key 分组授权统一展示报价待核实、用量计费待核实、执行接口待接入、暂不接入与可调用状态。筛选和状态标识一致,暂不接入不会显示为价格待配置。
|
||||||
|
|
||||||
|
管理端价格表按真实计费单位展示人民币 Token/张/任务/生成单价;分组编辑器补充固定单价和图像输入 Token 价。金额最多 8 位小数,保存保留报价来源与异步计费参数,不隐式换汇或再打折。新增 3 项回归覆盖暂缓接入优先级、固定价格编辑、图像输入价与单位切换。本次无数据库迁移或价格数据变更。
|
||||||
|
|
||||||
用户指出目录中仍有大量“价格待配置”“异步按任务计费待配置”。核对发现:无报价、无采购折扣、异步 Token 计费未实现、媒体原生协议不匹配是不同问题。保持现有平台结构,补齐已核实的配置和结算。
|
用户指出目录中仍有大量“价格待配置”“异步按任务计费待配置”。核对发现:无报价、无采购折扣、异步 Token 计费未实现、媒体原生协议不匹配是不同问题。保持现有平台结构,补齐已核实的配置和结算。
|
||||||
|
|
||||||
用户确认 Spark、Step、MiMo、Midjourney、Suno、Veo/Lyria、通义万相暂不接入。V43 为相应未定价路由记录 integrationDeferred;网关拒绝调用,目录显示“暂不接入”。保留原有目录、Key 授权和启用状态,管理统计不再把它们计入本期待配置价格数量。
|
用户确认 Spark、Step、MiMo、Midjourney、Suno、Veo/Lyria、通义万相暂不接入。V43 为相应未定价路由记录 integrationDeferred;网关拒绝调用,目录显示“暂不接入”。保留原有目录、Key 授权和启用状态,管理统计不再把它们计入本期待配置价格数量。
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { catalogClient, type CatalogProvider, type CatalogModel, type LogicalMod
|
|||||||
import UiModal from './UiModal.vue'
|
import UiModal from './UiModal.vue'
|
||||||
import ListPagination from './ListPagination.vue'
|
import ListPagination from './ListPagination.vue'
|
||||||
import { usePagination } from '../composables/usePagination'
|
import { usePagination } from '../composables/usePagination'
|
||||||
import { calculateTokenRetailPricing } from '../services/pricing'
|
import { calculateTokenRetailPricing, editRetailAmounts, platformPriceLabel, standardPriceLabel } from '../services/pricing'
|
||||||
|
|
||||||
|
import { routeReadinessLabel, routeReadinessReason } from '../services/model-catalog'
|
||||||
|
|
||||||
const props = defineProps<{ section: 'models' | 'channels' }>()
|
const props = defineProps<{ section: 'models' | 'channels' }>()
|
||||||
const emit = defineEmits<{ notify: [message: string] }>()
|
const emit = defineEmits<{ notify: [message: string] }>()
|
||||||
@@ -30,7 +32,7 @@ async function remove() {
|
|||||||
}
|
}
|
||||||
const channel = reactive({ code: '', name: '', protocol: 'openai-compatible' as CatalogProvider['protocol'], sourceType: 'relay' as CatalogProvider['sourceType'], baseUrl: '', credentialType: 'api-key' as NonNullable<CatalogProvider['credentialType']>, credentialSecret: '', description: '', status: 'active' as CatalogProvider['status'] })
|
const channel = reactive({ code: '', name: '', protocol: 'openai-compatible' as CatalogProvider['protocol'], sourceType: 'relay' as CatalogProvider['sourceType'], baseUrl: '', credentialType: 'api-key' as NonNullable<CatalogProvider['credentialType']>, credentialSecret: '', description: '', status: 'active' as CatalogProvider['status'] })
|
||||||
const model = reactive({ publicName: '', modelKey: '', vendorName: '', type: 'text' as LogicalModel['type'], mode: 'sync' as LogicalModel['mode'], description: '', inputTypes: 'text', outputTypes: 'text', status: 'active' as LogicalModel['status'] })
|
const model = reactive({ publicName: '', modelKey: '', vendorName: '', type: 'text' as LogicalModel['type'], mode: 'sync' as LogicalModel['mode'], description: '', inputTypes: 'text', outputTypes: 'text', status: 'active' as LogicalModel['status'] })
|
||||||
const group = reactive({ logicalModelId: '', providerId: '', sourceLabel: '', upstreamModel: '', input: '', output: '', cachedInput: '', unit: 'CNY / 1M tokens', discount: '', discountLabel: '', exchangeRate: '', priceSource: '', listPriceInput: '', listPriceOutput: '', listPriceCachedInput: '', priority: '100', maxConcurrency: '0', status: 'active' as CatalogModel['status'] })
|
const group = reactive({ logicalModelId: '', providerId: '', sourceLabel: '', upstreamModel: '', input: '', output: '', cachedInput: '', imageInput: '', price: '', unit: 'CNY / 1M tokens', discount: '', discountLabel: '', exchangeRate: '', priceSource: '', listPriceInput: '', listPriceOutput: '', listPriceCachedInput: '', priority: '100', maxConcurrency: '0', status: 'active' as CatalogModel['status'] })
|
||||||
const listCurrency = ref<'USD' | 'CNY'>('USD')
|
const listCurrency = ref<'USD' | 'CNY'>('USD')
|
||||||
const originalPricing = ref<CatalogModel['pricing']>()
|
const originalPricing = ref<CatalogModel['pricing']>()
|
||||||
const shownModels = computed(() => models.value.filter(item => `${item.publicName} ${item.vendorName || ''} ${item.modelKey || ''}`.toLowerCase().includes(query.value.toLowerCase())))
|
const shownModels = computed(() => models.value.filter(item => `${item.publicName} ${item.vendorName || ''} ${item.modelKey || ''}`.toLowerCase().includes(query.value.toLowerCase())))
|
||||||
@@ -70,6 +72,8 @@ function editGroup(parent: LogicalModel, item?: CatalogModel) {
|
|||||||
originalPricing.value = item?.pricing
|
originalPricing.value = item?.pricing
|
||||||
listCurrency.value = item?.pricing?.listPriceCny ? 'CNY' : 'USD'
|
listCurrency.value = item?.pricing?.listPriceCny ? 'CNY' : 'USD'
|
||||||
Object.assign(group, { logicalModelId: parent.id, providerId: item?.providerId || '', sourceLabel: item?.sourceLabel || '', upstreamModel: item?.upstreamModel || '', input: item?.pricing?.input?.toString() || '', output: item?.pricing?.output?.toString() || '', cachedInput: item?.pricing?.cachedInput?.toString() || '', unit: item?.pricing?.unit || 'CNY / 1M tokens', discount: item?.pricing?.discount?.toString() || '', discountLabel: item?.pricing?.discountLabel || '', exchangeRate: item?.pricing?.exchangeRate?.toString() || '', priceSource: item?.pricing?.priceSource || '', listPriceInput: item?.pricing?.listPriceUsd?.input?.toString() || '', listPriceOutput: item?.pricing?.listPriceUsd?.output?.toString() || '', listPriceCachedInput: item?.pricing?.listPriceUsd?.cachedInput?.toString() || '', priority: String(item?.priority ?? 100), maxConcurrency: String(item?.maxConcurrency ?? 0), status: item?.status || 'active' })
|
Object.assign(group, { logicalModelId: parent.id, providerId: item?.providerId || '', sourceLabel: item?.sourceLabel || '', upstreamModel: item?.upstreamModel || '', input: item?.pricing?.input?.toString() || '', output: item?.pricing?.output?.toString() || '', cachedInput: item?.pricing?.cachedInput?.toString() || '', unit: item?.pricing?.unit || 'CNY / 1M tokens', discount: item?.pricing?.discount?.toString() || '', discountLabel: item?.pricing?.discountLabel || '', exchangeRate: item?.pricing?.exchangeRate?.toString() || '', priceSource: item?.pricing?.priceSource || '', listPriceInput: item?.pricing?.listPriceUsd?.input?.toString() || '', listPriceOutput: item?.pricing?.listPriceUsd?.output?.toString() || '', listPriceCachedInput: item?.pricing?.listPriceUsd?.cachedInput?.toString() || '', priority: String(item?.priority ?? 100), maxConcurrency: String(item?.maxConcurrency ?? 0), status: item?.status || 'active' })
|
||||||
|
group.price = item?.pricing?.price?.toString() ?? ''
|
||||||
|
group.imageInput = item?.pricing?.imageInput?.toString() ?? ''
|
||||||
const list = item?.pricing?.listPriceCny || item?.pricing?.listPriceUsd
|
const list = item?.pricing?.listPriceCny || item?.pricing?.listPriceUsd
|
||||||
group.listPriceInput = list?.input?.toString() ?? ''
|
group.listPriceInput = list?.input?.toString() ?? ''
|
||||||
group.listPriceOutput = list?.output?.toString() ?? ''
|
group.listPriceOutput = list?.output?.toString() ?? ''
|
||||||
@@ -87,8 +91,10 @@ function calculateRetail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function groupPricing(): CatalogModel['pricing'] {
|
function groupPricing(): CatalogModel['pricing'] {
|
||||||
|
if (!originalPricing.value && [group.input, group.output, group.cachedInput, group.imageInput, group.price].every(value => value === '')) return undefined
|
||||||
|
const amounts = editRetailAmounts(originalPricing.value, group.unit, group)
|
||||||
const list = group.listPriceInput === '' && group.listPriceOutput === '' && group.listPriceCachedInput === '' ? undefined : {input:group.listPriceInput === '' ? undefined : Number(group.listPriceInput),output:group.listPriceOutput === '' ? undefined : Number(group.listPriceOutput),cachedInput:group.listPriceCachedInput === '' ? undefined : Number(group.listPriceCachedInput)}
|
const list = group.listPriceInput === '' && group.listPriceOutput === '' && group.listPriceCachedInput === '' ? undefined : {input:group.listPriceInput === '' ? undefined : Number(group.listPriceInput),output:group.listPriceOutput === '' ? undefined : Number(group.listPriceOutput),cachedInput:group.listPriceCachedInput === '' ? undefined : Number(group.listPriceCachedInput)}
|
||||||
return {...originalPricing.value,input:group.input === '' ? undefined : Number(group.input),output:group.output === '' ? undefined : Number(group.output),cachedInput:group.cachedInput === '' ? undefined : Number(group.cachedInput),unit:group.unit,discount:group.discount === '' ? undefined : Number(group.discount),discountLabel:group.discountLabel.trim() || undefined,exchangeRate:listCurrency.value === 'CNY' && list ? 1 : group.exchangeRate === '' ? undefined : Number(group.exchangeRate),priceSource:group.priceSource.trim() || undefined,listPriceUsd:listCurrency.value === 'USD' ? list : undefined,listPriceCny:listCurrency.value === 'CNY' ? list : undefined}
|
return {...amounts,discount:group.discount === '' ? undefined : Number(group.discount),discountLabel:group.discountLabel.trim() || undefined,exchangeRate:listCurrency.value === 'CNY' && list ? 1 : group.exchangeRate === '' ? undefined : Number(group.exchangeRate),priceSource:group.priceSource.trim() || undefined,listPriceUsd:group.unit === 'CNY / 1M tokens' ? (listCurrency.value === 'USD' ? list : undefined) : originalPricing.value?.listPriceUsd,listPriceCny:group.unit === 'CNY / 1M tokens' ? (listCurrency.value === 'CNY' ? list : undefined) : originalPricing.value?.listPriceCny}
|
||||||
}
|
}
|
||||||
async function save() {
|
async function save() {
|
||||||
if (saving.value) return
|
if (saving.value) return
|
||||||
@@ -139,7 +145,7 @@ async function toggle(kind: 'channel' | 'model' | 'group', item: CatalogProvider
|
|||||||
<section v-for="item in pagedModels" :key="item.id" class="model-definition-section">
|
<section v-for="item in pagedModels" :key="item.id" class="model-definition-section">
|
||||||
<header class="panel-header"><div><h3>{{ item.publicName }}</h3><small>{{ item.vendorName || '未标注厂商' }} · {{ item.modelKey || item.id }} · {{ item.type }} · {{ item.mode }}</small></div><div class="heading-actions"><label class="catalog-toggle"><input type="checkbox" :checked="item.status === 'active'" :disabled="saving" :aria-label="`${item.publicName} 启用`" @change="toggle('model', item)" />启用</label><button class="icon-button" :title="`编辑模型 ${item.publicName}`" @click="editModel(item)"><Pencil :size="16" /></button><button class="icon-button" :title="`删除模型 ${item.publicName}`" :disabled="saving" @click="confirmDelete('model', item.id, item.publicName)"><Trash2 :size="16" /></button><button class="button secondary small" @click="editGroup(item)"><Plus :size="15" />添加分组</button></div></header>
|
<header class="panel-header"><div><h3>{{ item.publicName }}</h3><small>{{ item.vendorName || '未标注厂商' }} · {{ item.modelKey || item.id }} · {{ item.type }} · {{ item.mode }}</small></div><div class="heading-actions"><label class="catalog-toggle"><input type="checkbox" :checked="item.status === 'active'" :disabled="saving" :aria-label="`${item.publicName} 启用`" @change="toggle('model', item)" />启用</label><button class="icon-button" :title="`编辑模型 ${item.publicName}`" @click="editModel(item)"><Pencil :size="16" /></button><button class="icon-button" :title="`删除模型 ${item.publicName}`" :disabled="saving" @click="confirmDelete('model', item.id, item.publicName)"><Trash2 :size="16" /></button><button class="button secondary small" @click="editGroup(item)"><Plus :size="15" />添加分组</button></div></header>
|
||||||
<p v-if="item.description" class="catalog-secondary">{{ item.description }}</p>
|
<p v-if="item.description" class="catalog-secondary">{{ item.description }}</p>
|
||||||
<div class="responsive-table"><table><thead><tr><th>分组名称</th><th>渠道</th><th>上游模型</th><th>输入 / 输出价格</th><th>对外折扣</th><th>并发</th><th>状态</th><th>操作</th></tr></thead><tbody><tr v-for="route in modelGroups(item.id)" :key="route.id"><td>{{ route.sourceLabel }}</td><td>{{ channelName(route.providerId) }}</td><td><code>{{ route.upstreamModel }}</code></td><td>{{ route.pricing?.input ?? '—' }} / {{ route.pricing?.output ?? '—' }}<small class="catalog-secondary">{{ route.pricing?.unit }}</small></td><td>{{ route.pricing?.discountLabel || '—' }}</td><td>{{ route.maxConcurrency === undefined || route.maxConcurrency === null || route.maxConcurrency === 0 ? '不限(由渠道限流)' : route.maxConcurrency }}</td><td><label class="catalog-toggle"><input type="checkbox" :checked="route.status === 'active'" :disabled="saving" :aria-label="`${route.sourceLabel} 启用`" @change="toggle('group', route)" />{{ route.status === 'active' ? '已启用' : '已停用' }}</label></td><td><button class="icon-button" :title="`编辑分组 ${route.sourceLabel}`" @click="editGroup(item, route)"><Pencil :size="16" /></button><button class="icon-button" :title="`删除分组 ${route.sourceLabel}`" :disabled="saving" @click="confirmDelete('group', route.id, route.sourceLabel || '默认分组')"><Trash2 :size="16" /></button></td></tr><tr v-if="!modelGroups(item.id).length"><td colspan="8">暂无分组</td></tr></tbody></table></div>
|
<div class="responsive-table"><table><thead><tr><th>分组名称</th><th>渠道</th><th>上游模型</th><th>人民币售价 / 计费单位</th><th>对外折扣</th><th>并发</th><th>状态</th><th>操作</th></tr></thead><tbody><tr v-for="route in modelGroups(item.id)" :key="route.id"><td>{{ route.sourceLabel }}</td><td>{{ channelName(route.providerId) }}</td><td><code>{{ route.upstreamModel }}</code></td><td>{{ route.pricingConfigured ? platformPriceLabel(route.pricing) : routeReadinessLabel(route) }}<small v-if="routeReadinessReason(route)" class="catalog-secondary">{{ routeReadinessReason(route) }}</small></td><td>{{ route.pricing?.discountLabel || '—' }}</td><td>{{ route.maxConcurrency === undefined || route.maxConcurrency === null || route.maxConcurrency === 0 ? '不限(由渠道限流)' : route.maxConcurrency }}</td><td><label class="catalog-toggle"><input type="checkbox" :checked="route.status === 'active'" :disabled="saving" :aria-label="`${route.sourceLabel} 启用`" @change="toggle('group', route)" />{{ route.status === 'active' ? '已启用' : '已停用' }}</label><small class="catalog-secondary">{{ routeReadinessLabel(route) }}</small></td><td><button class="icon-button" :title="`编辑分组 ${route.sourceLabel}`" @click="editGroup(item, route)"><Pencil :size="16" /></button><button class="icon-button" :title="`删除分组 ${route.sourceLabel}`" :disabled="saving" @click="confirmDelete('group', route.id, route.sourceLabel || '默认分组')"><Trash2 :size="16" /></button></td></tr><tr v-if="!modelGroups(item.id).length"><td colspan="8">暂无分组</td></tr></tbody></table></div>
|
||||||
</section>
|
</section>
|
||||||
<p v-if="!shownModels.length && !loading">暂无模型</p>
|
<p v-if="!shownModels.length && !loading">暂无模型</p>
|
||||||
<ListPagination v-model:page="modelPage" v-model:page-size="modelPageSize" :total="shownModels.length" label="管理端模型分页" />
|
<ListPagination v-model:page="modelPage" v-model:page-size="modelPageSize" :total="shownModels.length" label="管理端模型分页" />
|
||||||
@@ -172,17 +178,23 @@ async function toggle(kind: 'channel' | 'model' | 'group', item: CatalogProvider
|
|||||||
<label class="form-label" for="group-name">分组名称</label><input id="group-name" v-model="group.sourceLabel" class="text-input" required maxlength="160" />
|
<label class="form-label" for="group-name">分组名称</label><input id="group-name" v-model="group.sourceLabel" class="text-input" required maxlength="160" />
|
||||||
<label class="form-label" for="group-channel">渠道</label><select id="group-channel" v-model="group.providerId" class="text-input" required><option value="" disabled>请选择渠道</option><option v-for="item in channels" :key="item.id" :value="item.id">{{ item.name }}{{ item.status === 'disabled' ? '(已停用)' : '' }}</option></select>
|
<label class="form-label" for="group-channel">渠道</label><select id="group-channel" v-model="group.providerId" class="text-input" required><option value="" disabled>请选择渠道</option><option v-for="item in channels" :key="item.id" :value="item.id">{{ item.name }}{{ item.status === 'disabled' ? '(已停用)' : '' }}</option></select>
|
||||||
<label class="form-label" for="group-upstream">上游模型标识</label><input id="group-upstream" v-model="group.upstreamModel" class="text-input" required maxlength="160" />
|
<label class="form-label" for="group-upstream">上游模型标识</label><input id="group-upstream" v-model="group.upstreamModel" class="text-input" required maxlength="160" />
|
||||||
<div class="modal-form-grid"><label><span class="form-label">输入价格</span><input v-model="group.input" class="text-input" type="number" min="0" step="any" /></label><label><span class="form-label">输出价格</span><input v-model="group.output" class="text-input" type="number" min="0" step="any" /></label></div>
|
<label class="form-label" for="group-unit">人民币售价计费单位</label><select id="group-unit" v-model="group.unit" class="text-input" required><option value="CNY / 1M tokens">元 / 1M(一百万 Token)</option><option value="CNY / image">元 / 张</option><option value="CNY / task">元 / 任务</option><option value="CNY / generation">元 / 次生成</option></select>
|
||||||
|
<template v-if="group.unit === 'CNY / 1M tokens'">
|
||||||
|
<div class="modal-form-grid"><label><span class="form-label">文字输入价格(元 / 百万 Token)</span><input v-model="group.input" class="text-input" type="number" min="0" step="any" /></label><label><span class="form-label">输出价格(元 / 百万 Token)</span><input v-model="group.output" class="text-input" type="number" min="0" step="any" /></label></div>
|
||||||
<label class="form-label">缓存命中输入价格(留空按普通输入价格)<input v-model="group.cachedInput" class="text-input" type="number" min="0" step="any" /></label>
|
<label class="form-label">缓存命中输入价格(留空按普通输入价格)<input v-model="group.cachedInput" class="text-input" type="number" min="0" step="any" /></label>
|
||||||
<label class="form-label" for="group-unit">价格单位</label><input id="group-unit" v-model="group.unit" class="text-input" required />
|
<label class="form-label">图像输入价格(元 / 百万 Token,可选)<input v-model="group.imageInput" class="text-input" type="number" min="0" step="any" /></label>
|
||||||
|
</template>
|
||||||
|
<template v-else><label class="form-label">单价({{ group.unit === 'CNY / image' ? '元 / 张' : group.unit === 'CNY / task' ? '元 / 任务' : '元 / 次生成' }})<input v-model="group.price" class="text-input" type="number" min="0" max="1000000" step="any" /></label><small>已记录标准价:{{ standardPriceLabel(originalPricing) }}</small></template>
|
||||||
|
<template v-if="group.unit === 'CNY / 1M tokens'">
|
||||||
<label class="form-label" for="list-currency">渠道标准价币种</label><select id="list-currency" v-model="listCurrency" class="text-input"><option value="CNY">人民币 CNY</option><option value="USD">美元 USD</option></select>
|
<label class="form-label" for="list-currency">渠道标准价币种</label><select id="list-currency" v-model="listCurrency" class="text-input"><option value="CNY">人民币 CNY</option><option value="USD">美元 USD</option></select>
|
||||||
<div class="modal-form-grid"><label><span class="form-label">标准输入价({{ listCurrency }} / 百万 Token)</span><input v-model="group.listPriceInput" class="text-input" type="number" min="0" step="any" /></label><label><span class="form-label">标准输出价({{ listCurrency }} / 百万 Token)</span><input v-model="group.listPriceOutput" class="text-input" type="number" min="0" step="any" /></label></div>
|
<div class="modal-form-grid"><label><span class="form-label">标准输入价({{ listCurrency }} / 百万 Token)</span><input v-model="group.listPriceInput" class="text-input" type="number" min="0" step="any" /></label><label><span class="form-label">标准输出价({{ listCurrency }} / 百万 Token)</span><input v-model="group.listPriceOutput" class="text-input" type="number" min="0" step="any" /></label></div>
|
||||||
<label class="form-label">标准缓存输入价({{ listCurrency }} / 百万 Token,可选)<input v-model="group.listPriceCachedInput" class="text-input" type="number" min="0" step="any" /></label>
|
<label class="form-label">标准缓存输入价({{ listCurrency }} / 百万 Token,可选)<input v-model="group.listPriceCachedInput" class="text-input" type="number" min="0" step="any" /></label>
|
||||||
|
</template>
|
||||||
<label class="form-label">对外折扣数值<input v-model="group.discount" class="text-input" type="number" min="0" max="10" step="0.1" placeholder="例如:5.6 表示 5.6 折" /></label>
|
<label class="form-label">对外折扣数值<input v-model="group.discount" class="text-input" type="number" min="0" max="10" step="0.1" placeholder="例如:5.6 表示 5.6 折" /></label>
|
||||||
<label v-if="listCurrency === 'USD'" class="form-label">美元兑人民币汇率<input v-model="group.exchangeRate" class="text-input" type="number" min="0.00000001" step="any" /></label>
|
<label v-if="listCurrency === 'USD'" class="form-label">美元兑人民币汇率<input v-model="group.exchangeRate" class="text-input" type="number" min="0.00000001" step="any" /></label>
|
||||||
<button v-if="group.unit === 'CNY / 1M tokens'" type="button" class="button secondary" @click="calculateRetail">按标准价和对外折扣换算售价</button>
|
<button v-if="group.unit === 'CNY / 1M tokens'" type="button" class="button secondary" @click="calculateRetail">按标准价和对外折扣换算售价</button>
|
||||||
<small>1M Token=1,000,000 Token=一百万 Token。人民币原价不乘汇率;美元原价仅换算一次。采购 4.6 折加 1 个折扣点,对外填 5.6。</small>
|
<small>1M Token=1,000,000 Token=一百万 Token。人民币原价不乘汇率;美元原价仅换算一次。采购 4.6 折加 1 个折扣点,对外填 5.6。</small>
|
||||||
<label class="form-label" for="group-discount">对外折扣(仅展示)</label><input id="group-discount" v-model="group.discountLabel" class="text-input" maxlength="24" placeholder="例如:5.6折" /><small>输入、输出价格是实际扣费值,单位为 CNY / 1M tokens。折扣只用于向用户展示,不会替代人民币售价;留空表示不展示折扣。</small>
|
<label class="form-label" for="group-discount">对外折扣(仅展示)</label><input id="group-discount" v-model="group.discountLabel" class="text-input" maxlength="24" placeholder="例如:5.6折" /><small>上方人民币售价是实际扣费值。折扣和汇率仅在点击换算时参与计算,保存不会再次打折或换汇。留空不代表免费,也不会自动开放尚未完成计费或执行接口接入的模型。</small>
|
||||||
<div class="modal-form-grid"><label><span class="form-label">优先级</span><input v-model="group.priority" class="text-input" type="number" min="0" step="1" required /></label><label><span class="form-label">MOYI 分组并发上限</span><input v-model="group.maxConcurrency" class="text-input" type="number" min="0" step="1" required /><small>填 0 表示不设置平台分组上限,直接测量渠道方的真实并发;只有渠道明确给出共享上限时才填写正整数。</small></label></div>
|
<div class="modal-form-grid"><label><span class="form-label">优先级</span><input v-model="group.priority" class="text-input" type="number" min="0" step="1" required /></label><label><span class="form-label">MOYI 分组并发上限</span><input v-model="group.maxConcurrency" class="text-input" type="number" min="0" step="1" required /><small>填 0 表示不设置平台分组上限,直接测量渠道方的真实并发;只有渠道明确给出共享上限时才填写正整数。</small></label></div>
|
||||||
</template>
|
</template>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import type { ModelItem } from '../types'
|
import type { ModelItem } from '../types'
|
||||||
import { setGroupSelection } from '../services/model-catalog'
|
import { setGroupSelection, routeReadinessLabel } from '../services/model-catalog'
|
||||||
import { usePagination } from '../composables/usePagination'
|
import { usePagination } from '../composables/usePagination'
|
||||||
import ListPagination from './ListPagination.vue'
|
import ListPagination from './ListPagination.vue'
|
||||||
|
|
||||||
@@ -36,9 +36,9 @@ function clear() { expanded.value = []; emit('update:modelValue', []) }
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="group-permissions">
|
<div class="group-permissions">
|
||||||
<p>可同时选择多个模型,再勾选各模型可调用的分组。搜索或翻页会保留已选权限。</p>
|
<p>可同时选择多个模型,再勾选各模型可调用的分组。搜索或翻页会保留已选权限。授权不代表可立即调用,实际可用性以分组状态为准。</p>
|
||||||
<section v-if="modelValue.length" class="selected-summary" aria-label="已选模型与分组">
|
<section v-if="modelValue.length" class="selected-summary" aria-label="已选模型与分组">
|
||||||
<strong>已选 {{ selectedCount }} 个模型 · {{ selectedGroups.length }} 个可用分组<span v-if="unavailable.length"> · {{ unavailable.length }} 个暂不可用授权</span></strong>
|
<strong>已选 {{ selectedCount }} 个模型 · {{ selectedGroups.length }} 个已选分组<span v-if="unavailable.length"> · {{ unavailable.length }} 个暂不可用授权</span></strong>
|
||||||
<div class="selected-tags"><button v-for="group in selectedGroups" :key="group.id" type="button" :disabled="disabled" :aria-label="`移除 ${group.name} / ${group.sourceLabel || '默认分组'}`" @click="toggle([group.id], false)">{{ group.name }} / {{ group.sourceLabel || '默认分组' }} ×</button></div>
|
<div class="selected-tags"><button v-for="group in selectedGroups" :key="group.id" type="button" :disabled="disabled" :aria-label="`移除 ${group.name} / ${group.sourceLabel || '默认分组'}`" @click="toggle([group.id], false)">{{ group.name }} / {{ group.sourceLabel || '默认分组' }} ×</button></div>
|
||||||
</section>
|
</section>
|
||||||
<label class="permission-search">搜索模型或分组<input v-model="query" class="text-input" placeholder="模型名称、厂商、渠道或分组" :disabled="disabled" /></label>
|
<label class="permission-search">搜索模型或分组<input v-model="query" class="text-input" placeholder="模型名称、厂商、渠道或分组" :disabled="disabled" /></label>
|
||||||
@@ -46,11 +46,11 @@ function clear() { expanded.value = []; emit('update:modelValue', []) }
|
|||||||
<div class="permission-list">
|
<div class="permission-list">
|
||||||
<section v-for="model in pagedItems" :key="model.id" class="permission-model">
|
<section v-for="model in pagedItems" :key="model.id" class="permission-model">
|
||||||
<label class="model-choice"><input type="checkbox" :checked="modelChecked(model.id)" :disabled="disabled" @change="selectModel(model.id, ($event.target as HTMLInputElement).checked)" /><span><strong>{{ model.name }}</strong><small>{{ model.vendorName || '未标注厂商' }} · {{ model.groups.filter(group => modelValue.includes(group.id)).length }} / {{ model.groups.length }} 个分组已选</small></span></label>
|
<label class="model-choice"><input type="checkbox" :checked="modelChecked(model.id)" :disabled="disabled" @change="selectModel(model.id, ($event.target as HTMLInputElement).checked)" /><span><strong>{{ model.name }}</strong><small>{{ model.vendorName || '未标注厂商' }} · {{ model.groups.filter(group => modelValue.includes(group.id)).length }} / {{ model.groups.length }} 个分组已选</small></span></label>
|
||||||
<fieldset v-if="modelChecked(model.id)" :disabled="disabled"><legend>{{ model.name }} 的可调用分组</legend>
|
<fieldset v-if="modelChecked(model.id)" :disabled="disabled"><legend>{{ model.name }} 的分组权限</legend>
|
||||||
<p v-if="!model.groups.some(group => modelValue.includes(group.id))">请选择至少一个分组以授权该模型。</p>
|
<p v-if="!model.groups.some(group => modelValue.includes(group.id))">请选择至少一个分组以授权该模型。</p>
|
||||||
<label v-for="group in model.groups" :key="group.id" class="group-option">
|
<label v-for="group in model.groups" :key="group.id" class="group-option">
|
||||||
<input type="checkbox" :checked="modelValue.includes(group.id)" @change="toggle([group.id], ($event.target as HTMLInputElement).checked)" />
|
<input type="checkbox" :checked="modelValue.includes(group.id)" @change="toggle([group.id], ($event.target as HTMLInputElement).checked)" />
|
||||||
<span><strong>{{ group.sourceLabel || '默认分组' }}</strong><small>{{ group.provider }} · {{ group.mode }}</small></span>
|
<span><strong>{{ group.sourceLabel || '默认分组' }}</strong><small>{{ group.provider }} · {{ group.mode }} · {{ routeReadinessLabel(group) }}</small></span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
import type { CatalogModel, CatalogProvider, LogicalModel } from './catalog'
|
import type { CatalogModel, CatalogProvider, LogicalModel } from './catalog'
|
||||||
|
|
||||||
|
type Readiness = Pick<CatalogModel, 'pricingConfigured' | 'billingReady' | 'executionReady' | 'integrationDeferred' | 'billingReason'> & { status?: string }
|
||||||
|
export function routeReadinessLabel(route: Readiness) {
|
||||||
|
if (route.integrationDeferred) return '暂不接入'
|
||||||
|
if (route.status === 'disabled') return '已停用'
|
||||||
|
if (!route.pricingConfigured) return '报价待核实'
|
||||||
|
if (route.executionReady === false) return '执行接口待接入'
|
||||||
|
if (route.billingReady === false) return '用量计费待核实'
|
||||||
|
return '可调用'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function routeReadinessReason(route: Readiness) {
|
||||||
|
if (route.integrationDeferred) return '该模型本期暂不接入,当前不开放调用。'
|
||||||
|
if (route.status === 'disabled') return '该分组已停用。'
|
||||||
|
if (routeReadinessLabel(route) === '可调用') return ''
|
||||||
|
if (route.pricingConfigured && route.executionReady === false) return '该分组的执行接口尚未接入,当前不开放调用。'
|
||||||
|
return route.billingReason || `${routeReadinessLabel(route)},当前不开放调用。`
|
||||||
|
}
|
||||||
|
|
||||||
export interface ModelCatalogSummary {
|
export interface ModelCatalogSummary {
|
||||||
publishedModels: number
|
publishedModels: number
|
||||||
readyModels: number
|
readyModels: number
|
||||||
|
|||||||
@@ -15,6 +15,26 @@ export interface DisplayPricing {
|
|||||||
listPriceCny?: { input?: number; output?: number; cachedInput?: number }
|
listPriceCny?: { input?: number; output?: number; cachedInput?: number }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Change only editable retail amounts; retain source evidence and async billing metadata. */
|
||||||
|
export function editRetailAmounts(original: DisplayPricing | undefined, unit: string, values: { input: string | number; output: string | number; cachedInput: string | number; imageInput: string | number; price: string | number }) {
|
||||||
|
const result: DisplayPricing = { ...original, unit }
|
||||||
|
const parse = (value: string | number) => {
|
||||||
|
if (!String(value).trim()) return undefined
|
||||||
|
const amount = Number(value)
|
||||||
|
if (!Number.isFinite(amount) || amount < 0 || amount > 1000000 || Number(amount.toFixed(8)) !== amount) throw new Error('人民币价格须在 0–100 万之间,最多 8 位小数')
|
||||||
|
return amount
|
||||||
|
}
|
||||||
|
if (unit === 'CNY / 1M tokens') {
|
||||||
|
delete result.price
|
||||||
|
for (const key of ['input', 'output', 'cachedInput', 'imageInput'] as const) result[key] = parse(values[key])
|
||||||
|
} else {
|
||||||
|
if (!['CNY / image', 'CNY / task', 'CNY / generation'].includes(unit)) throw new Error('请选择已支持的人民币计费单位')
|
||||||
|
result.price = parse(values.price)
|
||||||
|
for (const key of ['input', 'output', 'cachedInput', 'imageInput'] as const) delete result[key]
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
function numberLabel(value: number | undefined, currency = '¥') {
|
function numberLabel(value: number | undefined, currency = '¥') {
|
||||||
if (value === undefined || value === null || !Number.isFinite(value)) return '待配置'
|
if (value === undefined || value === null || !Number.isFinite(value)) return '待配置'
|
||||||
return `${currency}${value.toLocaleString('zh-CN', { maximumFractionDigits: 8 })}`
|
return `${currency}${value.toLocaleString('zh-CN', { maximumFractionDigits: 8 })}`
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ import AccountAdmin from '../components/AccountAdmin.vue'
|
|||||||
import EnterprisePolicies from '../components/EnterprisePolicies.vue'
|
import EnterprisePolicies from '../components/EnterprisePolicies.vue'
|
||||||
import EnterpriseFinance from '../components/EnterpriseFinance.vue'
|
import EnterpriseFinance from '../components/EnterpriseFinance.vue'
|
||||||
import EnterpriseOperations from '../components/EnterpriseOperations.vue'
|
import EnterpriseOperations from '../components/EnterpriseOperations.vue'
|
||||||
import { providerCapabilityLabel, summarizeModelCatalog } from '../services/model-catalog'
|
import { platformPriceLabel } from '../services/pricing'
|
||||||
|
import { providerCapabilityLabel, summarizeModelCatalog, routeReadinessLabel } from '../services/model-catalog'
|
||||||
import { usePagination } from '../composables/usePagination'
|
import { usePagination } from '../composables/usePagination'
|
||||||
import ListPagination from '../components/ListPagination.vue'
|
import ListPagination from '../components/ListPagination.vue'
|
||||||
|
|
||||||
@@ -209,10 +210,10 @@ const configuredCapacityGroups = computed(() => adminSummary.value?.capacityGrou
|
|||||||
const hasUnlimitedCapacity = computed(() => configuredCapacityGroups.value.some(group => group.limit <= 0))
|
const hasUnlimitedCapacity = computed(() => configuredCapacityGroups.value.some(group => group.limit <= 0))
|
||||||
const configuredCapacity = computed(() => hasUnlimitedCapacity.value ? null : configuredCapacityGroups.value.reduce((total, group) => total + group.limit, 0))
|
const configuredCapacity = computed(() => hasUnlimitedCapacity.value ? null : configuredCapacityGroups.value.reduce((total, group) => total + group.limit, 0))
|
||||||
const pricing = computed(() => models.value.filter((model) => model.pricingConfigured).map((model) => ({
|
const pricing = computed(() => models.value.filter((model) => model.pricingConfigured).map((model) => ({
|
||||||
|
id: model.id,
|
||||||
model: model.name,
|
model: model.name,
|
||||||
unit: model.pricing?.unit || 'CNY / 1M tokens',
|
group: model.sourceLabel || '默认分组',
|
||||||
base: model.pricing?.input === undefined ? '—' : `¥${model.pricing.input}`,
|
priceLabel: platformPriceLabel(model.pricing),
|
||||||
output: model.pricing?.output === undefined ? '—' : `¥${model.pricing.output}`,
|
|
||||||
rule: model.pricing?.discountLabel || '标准价',
|
rule: model.pricing?.discountLabel || '标准价',
|
||||||
status: model.availability,
|
status: model.availability,
|
||||||
})))
|
})))
|
||||||
@@ -266,7 +267,7 @@ function mapModels(items: CatalogModel[], providersList: CatalogProvider[]): Mod
|
|||||||
description: model.description,
|
description: model.description,
|
||||||
latency: model.mode === 'async' ? '异步任务' : '未采样',
|
latency: model.mode === 'async' ? '异步任务' : '未采样',
|
||||||
specification: model.outputTypes.join(' / ') || '统一接口',
|
specification: model.outputTypes.join(' / ') || '统一接口',
|
||||||
availability: model.status === 'active' ? '在线' : '停用',
|
availability: routeReadinessLabel(model),
|
||||||
accent: model.type === '3d' ? 'orange' : 'violet',
|
accent: model.type === '3d' ? 'orange' : 'violet',
|
||||||
icon: model.type === '3d' ? Box : Boxes,
|
icon: model.type === '3d' ? Box : Boxes,
|
||||||
modelKey: model.modelKey,
|
modelKey: model.modelKey,
|
||||||
@@ -278,6 +279,8 @@ function mapModels(items: CatalogModel[], providersList: CatalogProvider[]): Mod
|
|||||||
vendorName: model.vendorName,
|
vendorName: model.vendorName,
|
||||||
pricingConfigured: model.pricingConfigured,
|
pricingConfigured: model.pricingConfigured,
|
||||||
billingReady: model.billingReady,
|
billingReady: model.billingReady,
|
||||||
|
billingReason: model.billingReason,
|
||||||
|
integrationDeferred: model.integrationDeferred,
|
||||||
executionReady: model.executionReady,
|
executionReady: model.executionReady,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -314,7 +317,7 @@ function mapModels(items: CatalogModel[], providersList: CatalogProvider[]): Mod
|
|||||||
<section class="page-heading"><div><span>BILLING OPERATIONS</span><h1>计费配置</h1><p>维护模型计费单位、价格和扣费规则。</p></div><button class="button secondary" title="进入用户与额度页面进行人工调账" @click="emit('navigate', 'admin-users')"><WalletCards :size="16" />人工发放额度</button></section>
|
<section class="page-heading"><div><span>BILLING OPERATIONS</span><h1>计费配置</h1><p>维护模型计费单位、价格和扣费规则。</p></div><button class="button secondary" title="进入用户与额度页面进行人工调账" @click="emit('navigate', 'admin-users')"><WalletCards :size="16" />人工发放额度</button></section>
|
||||||
<section class="notice warning-notice"><AlertTriangle :size="19" /><div><strong>当前采用管理员发放额度</strong><p>在线支付和订单接口尚未配置;管理员可以在“用户与额度”中增加、减少或设置人民币余额。价格目录会参与真实调用扣费。</p></div></section>
|
<section class="notice warning-notice"><AlertTriangle :size="19" /><div><strong>当前采用管理员发放额度</strong><p>在线支付和订单接口尚未配置;管理员可以在“用户与额度”中增加、减少或设置人民币余额。价格目录会参与真实调用扣费。</p></div></section>
|
||||||
<section class="metric-grid three"><article class="metric-card"><span class="icon-tile violet"><CircleDollarSign :size="18" /></span><div><small>本期额度发放</small><strong>人工</strong><em>用户与额度页可查流水</em></div></article><article class="metric-card"><span class="icon-tile cyan"><BarChart3 :size="18" /></span><div><small>本期实际消耗</small><strong>{{ adminSummary ? `¥${Number(adminSummary.costThisMonth || 0).toFixed(4)}` : '—' }}</strong><em>成功调用扣费累计</em></div></article><article class="metric-card"><span class="icon-tile orange"><WalletCards :size="18" /></span><div><small>已配置价格</small><strong>{{ pricing.length }}</strong><em>无价格模型不会对用户开放</em></div></article></section>
|
<section class="metric-grid three"><article class="metric-card"><span class="icon-tile violet"><CircleDollarSign :size="18" /></span><div><small>本期额度发放</small><strong>人工</strong><em>用户与额度页可查流水</em></div></article><article class="metric-card"><span class="icon-tile cyan"><BarChart3 :size="18" /></span><div><small>本期实际消耗</small><strong>{{ adminSummary ? `¥${Number(adminSummary.costThisMonth || 0).toFixed(4)}` : '—' }}</strong><em>成功调用扣费累计</em></div></article><article class="metric-card"><span class="icon-tile orange"><WalletCards :size="18" /></span><div><small>已配置价格</small><strong>{{ pricing.length }}</strong><em>无价格模型不会对用户开放</em></div></article></section>
|
||||||
<section class="panel table-card"><header class="panel-header"><div><span>PRICE CATALOG</span><h3>模型计费规则</h3></div><button class="button secondary small" @click="emit('navigate', 'admin-models')"><Plus :size="15" />前往模型与分组</button></header><div class="responsive-table"><table><thead><tr><th>模型</th><th>计费单位</th><th>输入 / 基础</th><th>输出 / 结果</th><th>扣费规则</th><th>状态</th></tr></thead><tbody><tr v-for="item in pricing" :key="`${item.model}-${item.rule}`"><td><strong>{{ item.model }}</strong></td><td>{{ item.unit }}</td><td>{{ item.base }}</td><td>{{ item.output }}</td><td>{{ item.rule }}</td><td><span class="status-chip success"><i></i>{{ item.status }}</span></td></tr><tr v-if="!pricing.length"><td colspan="6"><div class="empty-state compact"><CircleDollarSign :size="22" /><strong>暂无计费规则</strong><span>模型与分组页面提供已接入模型的真实价格配置</span></div></td></tr></tbody></table></div></section>
|
<section class="panel table-card"><header class="panel-header"><div><span>PRICE CATALOG</span><h3>模型计费规则</h3></div><button class="button secondary small" @click="emit('navigate', 'admin-models')"><Plus :size="15" />前往模型与分组</button></header><div class="responsive-table"><table><thead><tr><th>模型</th><th>分组</th><th>人民币售价 / 计费单位</th><th>扣费规则</th><th>状态</th></tr></thead><tbody><tr v-for="item in pricing" :key="item.id"><td><strong>{{ item.model }}</strong></td><td>{{ item.group }}</td><td>{{ item.priceLabel }}</td><td>{{ item.rule }}</td><td><span class="status-chip" :class="item.status === '可调用' ? 'success' : 'warning'"><i></i>{{ item.status }}</span></td></tr><tr v-if="!pricing.length"><td colspan="5"><div class="empty-state compact"><CircleDollarSign :size="22" /><strong>暂无计费规则</strong><span>模型与分组页面提供已接入模型的真实价格配置</span></div></td></tr></tbody></table></div></section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="view === 'admin-audit'">
|
<template v-else-if="view === 'admin-audit'">
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import {
|
|||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
import type { ApiKeyItem, CallMode, ModelItem, ModelType, TaskItem, TaskStatus } from '../types'
|
import type { ApiKeyItem, CallMode, ModelItem, ModelType, TaskItem, TaskStatus } from '../types'
|
||||||
import { catalogClient, platformApiBaseUrl, type AsyncMediaType, type AsyncTaskResult, type CatalogApiKey, type CatalogModel, type LogicalModel, type CatalogProject, type PlatformOverview, type UserUsageRecord } from '../services/catalog'
|
import { catalogClient, platformApiBaseUrl, type AsyncMediaType, type AsyncTaskResult, type CatalogApiKey, type CatalogModel, type LogicalModel, type CatalogProject, type PlatformOverview, type UserUsageRecord } from '../services/catalog'
|
||||||
import { buildModelCatalog } from '../services/model-catalog'
|
import { buildModelCatalog, routeReadinessLabel, routeReadinessReason } from '../services/model-catalog'
|
||||||
import { groupDiscountLabel as formatGroupDiscountLabel, modelStandardPriceLabel, platformPriceLabel } from '../services/pricing'
|
import { groupDiscountLabel as formatGroupDiscountLabel, modelStandardPriceLabel, platformPriceLabel } from '../services/pricing'
|
||||||
import { usePagination } from '../composables/usePagination'
|
import { usePagination } from '../composables/usePagination'
|
||||||
import ListPagination from '../components/ListPagination.vue'
|
import ListPagination from '../components/ListPagination.vue'
|
||||||
@@ -61,7 +61,7 @@ const modelType = ref<'全部' | ModelType>('全部')
|
|||||||
const modelProvider = ref('全部')
|
const modelProvider = ref('全部')
|
||||||
const modelVendor = ref('全部')
|
const modelVendor = ref('全部')
|
||||||
const modelMode = ref<'全部' | CallMode>('全部')
|
const modelMode = ref<'全部' | CallMode>('全部')
|
||||||
const modelAvailability = ref<'全部' | '在线' | '待上线'>('全部')
|
const modelAvailability = ref('全部')
|
||||||
type GalleryModel = ModelItem & { groups: ModelItem[]; providerNames: string[] }
|
type GalleryModel = ModelItem & { groups: ModelItem[]; providerNames: string[] }
|
||||||
const selectedModel = ref<GalleryModel | null>(null)
|
const selectedModel = ref<GalleryModel | null>(null)
|
||||||
const emptyModel: ModelItem = { id: '', name: '尚未选择模型', provider: '等待目录加载', type: '文本', mode: '同步', description: '', latency: '--', specification: '--', availability: '--', accent: 'violet', icon: MessageSquareText }
|
const emptyModel: ModelItem = { id: '', name: '尚未选择模型', provider: '等待目录加载', type: '文本', mode: '同步', description: '', latency: '--', specification: '--', availability: '--', accent: 'violet', icon: MessageSquareText }
|
||||||
@@ -72,7 +72,7 @@ const galleryModels = computed<GalleryModel[]>(() => buildModelCatalog(catalogDe
|
|||||||
const routes = groups.map(group => catalogModels.value.find(item => item.id === group.id)!).filter(Boolean)
|
const routes = groups.map(group => catalogModels.value.find(item => item.id === group.id)!).filter(Boolean)
|
||||||
const providerNames = [...new Set(routes.map(group => group.provider))]
|
const providerNames = [...new Set(routes.map(group => group.provider))]
|
||||||
return { ...mapCatalogModel(definition), groups: routes, providerNames,
|
return { ...mapCatalogModel(definition), groups: routes, providerNames,
|
||||||
provider: providerNames.join(' / ') || '暂无上线分组', availability: routes.some(group => group.pricingConfigured && group.billingReady !== false && group.executionReady !== false) ? '在线' : '待上线' }
|
provider: providerNames.join(' / ') || '暂无上线分组', availability: galleryAvailability(routes) }
|
||||||
}))
|
}))
|
||||||
const featuredModels = computed(() => [...galleryModels.value].sort((a, b) => Number(!!b.groups.length) - Number(!!a.groups.length)).slice(0, 3))
|
const featuredModels = computed(() => [...galleryModels.value].sort((a, b) => Number(!!b.groups.length) - Number(!!a.groups.length)).slice(0, 3))
|
||||||
const activeModel = ref<ModelItem>(emptyModel)
|
const activeModel = ref<ModelItem>(emptyModel)
|
||||||
@@ -159,7 +159,7 @@ const activeEmbedding = computed(() => catalogRoutes.value.find(m => m.id === ac
|
|||||||
const activeOutputTypes = computed(() => activeModel.value.outputTypes || [])
|
const activeOutputTypes = computed(() => activeModel.value.outputTypes || [])
|
||||||
const activeAsyncSupported = computed(() => activeModel.value.mode !== '异步' || (!!activeMediaKind.value && activeModel.value.executionReady !== false))
|
const activeAsyncSupported = computed(() => activeModel.value.mode !== '异步' || (!!activeMediaKind.value && activeModel.value.executionReady !== false))
|
||||||
const supportsMediaInput = computed(() => activeInputTypes.value.some(input => /image|audio|video|url|media/i.test(input)))
|
const supportsMediaInput = computed(() => activeInputTypes.value.some(input => /image|audio|video|url|media/i.test(input)))
|
||||||
const activeModelReady = computed(() => activeModel.value.pricingConfigured === true && activeModel.value.billingReady !== false && activeModel.value.executionReady !== false && activeAsyncSupported.value)
|
const activeModelReady = computed(() => routeReadinessLabel(activeModel.value) === '可调用' && activeAsyncSupported.value)
|
||||||
const submitLabel = computed(() => callMode.value === '异步' ? generationLabel(activeModel.value.type) : '开始调用')
|
const submitLabel = computed(() => callMode.value === '异步' ? generationLabel(activeModel.value.type) : '开始调用')
|
||||||
const promptPlaceholder = computed(() => ({
|
const promptPlaceholder = computed(() => ({
|
||||||
'文本': '描述你希望模型完成的任务',
|
'文本': '描述你希望模型完成的任务',
|
||||||
@@ -334,33 +334,29 @@ function groupStandardPriceLabel(group: ModelItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function groupDiscountLabel(group: ModelItem) {
|
function groupDiscountLabel(group: ModelItem) {
|
||||||
return formatGroupDiscountLabel(group.pricing, group.pricingConfigured)
|
return group.integrationDeferred ? '本期不开放' : !group.pricingConfigured ? '折扣待核实' : formatGroupDiscountLabel(group.pricing, group.pricingConfigured)
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupPriceLabel(group: ModelItem) {
|
function groupPriceLabel(group: ModelItem) {
|
||||||
if (!group.pricingConfigured || !group.pricing) return '当前不可调用:价格待配置'
|
if (group.integrationDeferred) return '暂不接入'
|
||||||
|
if (!group.pricingConfigured || !group.pricing) return '当前不可调用:报价待核实'
|
||||||
return platformPriceLabel(group.pricing)
|
return platformPriceLabel(group.pricing)
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasCallableGroup(model: GalleryModel) {
|
function hasCallableGroup(model: GalleryModel) {
|
||||||
return model.groups.some(group => group.pricingConfigured && group.billingReady !== false && group.executionReady !== false)
|
return model.groups.some(group => routeReadinessLabel(group) === '可调用')
|
||||||
}
|
}
|
||||||
|
|
||||||
function modelAvailabilityLabel(model: GalleryModel) {
|
function galleryAvailability(groups: ModelItem[]) {
|
||||||
if (!model.groups.length) return '待上线'
|
if (!groups.length) return '待上线'
|
||||||
if (model.groups.every(group => group.integrationDeferred)) return '暂不接入'
|
if (groups.some(group => routeReadinessLabel(group) === '可调用')) return '在线'
|
||||||
if (hasCallableGroup(model)) return '在线'
|
const candidate = groups.find(group => !group.integrationDeferred && group.pricingConfigured)
|
||||||
if (model.mode === '异步' && model.groups.some(group => group.pricingConfigured && group.executionReady === false)) return '异步执行器待接入'
|
|| groups.find(group => !group.integrationDeferred) || groups[0]!
|
||||||
if (model.mode === '异步' && model.groups.some(group => group.pricingConfigured && group.billingReady === false)) return '用量计费待核实'
|
return routeReadinessLabel(candidate)
|
||||||
return '价格待配置'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function modelUnavailableLabel(model: GalleryModel) {
|
function modelAvailabilityLabel(model: GalleryModel) { return galleryAvailability(model.groups) }
|
||||||
if (model.groups.length && model.groups.every(group => group.integrationDeferred)) return '暂不接入'
|
function modelUnavailableLabel(model: GalleryModel) { return galleryAvailability(model.groups) }
|
||||||
if (model.mode === '异步' && model.groups.some(group => group.pricingConfigured && group.executionReady === false)) return '异步执行器待接入'
|
|
||||||
if (model.mode === '异步' && model.groups.some(group => group.pricingConfigured && group.billingReady === false)) return '用量计费待核实'
|
|
||||||
return '价格待配置'
|
|
||||||
}
|
|
||||||
|
|
||||||
async function copy(value: string, label: string, target: string) {
|
async function copy(value: string, label: string, target: string) {
|
||||||
const result = await copyText(value)
|
const result = await copyText(value)
|
||||||
@@ -807,12 +803,12 @@ async function createProject() {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section-title"><div><span>精选能力</span><h2>推荐模型</h2></div><button class="text-link" @click="emit('navigate', 'models')">查看全部<ArrowRight :size="14" /></button></section>
|
<section class="section-title"><div><span>精选能力</span><h2>推荐模型</h2></div><button class="text-link" @click="emit('navigate', 'models')">查看全部<ArrowRight :size="14" /></button></section>
|
||||||
<section class="model-grid featured"><article v-for="model in featuredModels" :key="model.id" class="model-card" @click="selectedModel = model"><div class="model-card-top"><span class="model-icon" :class="model.accent"><component :is="model.icon" :size="20" /></span><span class="availability" :class="{ pending: !model.groups.length }"><i></i>{{ model.availability }}</span></div><h3>{{ model.name }}</h3><p>{{ model.description }}</p><footer><span>{{ model.mode }} · {{ model.latency }}</span><ArrowRight :size="16" /></footer></article><div v-if="!galleryModels.length" class="empty-state"><Box :size="24" /><strong>暂无已发布模型</strong><span>{{ catalogConnected ? '请由管理员配置并上线模型' : '请检查 Control Plane 连接' }}</span></div></section>
|
<section class="model-grid featured"><article v-for="model in featuredModels" :key="model.id" class="model-card" @click="selectedModel = model"><div class="model-card-top"><span class="model-icon" :class="model.accent"><component :is="model.icon" :size="20" /></span><span class="availability" :class="{ pending: !hasCallableGroup(model) }"><i></i>{{ model.availability }}</span></div><h3>{{ model.name }}</h3><p>{{ model.description }}</p><footer><span>{{ model.mode }} · {{ model.latency }}</span><ArrowRight :size="16" /></footer></article><div v-if="!galleryModels.length" class="empty-state"><Box :size="24" /><strong>暂无已发布模型</strong><span>{{ catalogConnected ? '请由管理员配置并上线模型' : '请检查 Control Plane 连接' }}</span></div></section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="view === 'models'">
|
<template v-else-if="view === 'models'">
|
||||||
<section class="page-heading"><div><span>MODEL CATALOG</span><h1>模型广场</h1><p>按能力选择模型,用一个 Key 完成接入。</p></div><button class="button secondary" @click="emit('navigate', 'docs')"><BookOpen :size="16" />接入指南</button></section>
|
<section class="page-heading"><div><span>MODEL CATALOG</span><h1>模型广场</h1><p>按能力选择模型,用一个 Key 完成接入。</p></div><button class="button secondary" @click="emit('navigate', 'docs')"><BookOpen :size="16" />接入指南</button></section>
|
||||||
<section class="model-filter-panel"><div class="model-filter-head"><div><strong>筛选模型</strong><span>模型厂商是实际研发方,供应商是请求经过的渠道或中转站</span></div><button v-if="activeModelFilters.length || modelQuery" class="text-link" @click="resetModelFilters">清空筛选</button></div><div class="model-filter-grid"><label class="search-input model-filter-search"><Search :size="16" /><input v-model="modelQuery" placeholder="搜索模型名称、厂商、渠道或能力" /></label><label class="select-filter"><span>模型厂商</span><select v-model="modelVendor"><option value="全部">全部模型厂商</option><option v-for="vendor in modelVendors" :key="vendor" :value="vendor">{{ vendor }}</option></select></label><label class="select-filter"><span>供应商 / 渠道</span><select v-model="modelProvider"><option value="全部">全部渠道</option><option v-for="provider in modelProviders" :key="provider" :value="provider">{{ provider }}</option></select></label><label class="select-filter"><span>模型类型</span><select v-model="modelType"><option v-for="type in modelTypes" :key="type" :value="type">{{ type === '全部' ? '全部类型' : type }}</option></select></label><label class="select-filter"><span>调用方式</span><select v-model="modelMode"><option v-for="mode in callModes" :key="mode" :value="mode">{{ mode === '全部' ? '全部方式' : mode }}</option></select></label><label class="select-filter"><span>可用状态</span><select v-model="modelAvailability"><option value="全部">全部状态</option><option value="在线">在线</option><option value="待上线">待上线</option></select></label></div><div class="filter-summary"><span>共 {{ filteredModels.length }} 个模型</span><span v-if="activeModelFilters.length">已选:{{ activeModelFilters.join(' · ') }}</span></div></section>
|
<section class="model-filter-panel"><div class="model-filter-head"><div><strong>筛选模型</strong><span>模型厂商是实际研发方,供应商是请求经过的渠道或中转站</span></div><button v-if="activeModelFilters.length || modelQuery" class="text-link" @click="resetModelFilters">清空筛选</button></div><div class="model-filter-grid"><label class="search-input model-filter-search"><Search :size="16" /><input v-model="modelQuery" placeholder="搜索模型名称、厂商、渠道或能力" /></label><label class="select-filter"><span>模型厂商</span><select v-model="modelVendor"><option value="全部">全部模型厂商</option><option v-for="vendor in modelVendors" :key="vendor" :value="vendor">{{ vendor }}</option></select></label><label class="select-filter"><span>供应商 / 渠道</span><select v-model="modelProvider"><option value="全部">全部渠道</option><option v-for="provider in modelProviders" :key="provider" :value="provider">{{ provider }}</option></select></label><label class="select-filter"><span>模型类型</span><select v-model="modelType"><option v-for="type in modelTypes" :key="type" :value="type">{{ type === '全部' ? '全部类型' : type }}</option></select></label><label class="select-filter"><span>调用方式</span><select v-model="modelMode"><option v-for="mode in callModes" :key="mode" :value="mode">{{ mode === '全部' ? '全部方式' : mode }}</option></select></label><label class="select-filter"><span>可用状态</span><select v-model="modelAvailability"><option value="全部">全部状态</option><option v-for="state in ['在线', '报价待核实', '用量计费待核实', '执行接口待接入', '暂不接入', '待上线']" :key="state" :value="state">{{ state }}</option></select></label></div><div class="filter-summary"><span>共 {{ filteredModels.length }} 个模型</span><span v-if="activeModelFilters.length">已选:{{ activeModelFilters.join(' · ') }}</span></div></section>
|
||||||
<section class="model-grid catalog"><article v-for="model in pagedModels" :key="model.id" class="model-card catalog-card" @click="selectedModel = model"><div class="model-card-top"><span class="model-icon" :class="model.accent"><component :is="model.icon" :size="21" /></span><span class="availability" :class="{ pending: !hasCallableGroup(model) }"><i></i>{{ modelAvailabilityLabel(model) }}</span></div><div class="model-title"><h3>{{ model.name }}</h3><span>{{ model.type }}</span></div><small class="provider"><strong>{{ model.vendorName || '未标注厂商' }}</strong><span>渠道:{{ model.provider }}</span><span v-if="model.sourceLabel"> · {{ model.sourceLabel }}</span></small><p>{{ model.description }}</p><div class="model-pricing"><span><strong>标准价</strong>{{ standardPriceLabel(model) }}</span><span><strong>分组售价 / 折扣</strong><template v-if="model.groups.length"><em v-for="group in model.groups" :key="group.id">{{ group.sourceLabel || '默认分组' }}:{{ groupPriceLabel(group) }} · {{ groupDiscountLabel(group) }}</em></template><em v-else>暂无上线分组</em></span></div><div class="model-specs"><span><Timer :size="14" />{{ model.latency }}</span><span><Layers3 :size="14" />{{ model.specification }}</span></div><footer><span class="mode-tag" :class="{ async: model.mode === '异步' }">{{ model.mode }}调用</span><button class="text-link" :disabled="!hasCallableGroup(model)" @click.stop="tryModel(model)">{{ !model.groups.length ? '分组待上线' : hasCallableGroup(model) ? `在线试用 · ${model.groups.length} 个分组` : modelUnavailableLabel(model) }}<ArrowRight :size="14" /></button></footer></article><div v-if="!filteredModels.length" class="empty-state"><Search :size="24" /><strong>没有找到匹配模型</strong><span>换个关键词或筛选条件试试</span></div></section>
|
<section class="model-grid catalog"><article v-for="model in pagedModels" :key="model.id" class="model-card catalog-card" @click="selectedModel = model"><div class="model-card-top"><span class="model-icon" :class="model.accent"><component :is="model.icon" :size="21" /></span><span class="availability" :class="{ pending: !hasCallableGroup(model) }"><i></i>{{ modelAvailabilityLabel(model) }}</span></div><div class="model-title"><h3>{{ model.name }}</h3><span>{{ model.type }}</span></div><small class="provider"><strong>{{ model.vendorName || '未标注厂商' }}</strong><span>渠道:{{ model.provider }}</span><span v-if="model.sourceLabel"> · {{ model.sourceLabel }}</span></small><p>{{ model.description }}</p><div class="model-pricing"><span><strong>标准价</strong>{{ standardPriceLabel(model) }}</span><span><strong>分组售价 / 折扣</strong><template v-if="model.groups.length"><em v-for="group in model.groups" :key="group.id">{{ group.sourceLabel || '默认分组' }}:{{ groupPriceLabel(group) }} · {{ groupDiscountLabel(group) }}</em></template><em v-else>暂无上线分组</em></span></div><div class="model-specs"><span><Timer :size="14" />{{ model.latency }}</span><span><Layers3 :size="14" />{{ model.specification }}</span></div><footer><span class="mode-tag" :class="{ async: model.mode === '异步' }">{{ model.mode }}调用</span><button class="text-link" :disabled="!hasCallableGroup(model)" @click.stop="tryModel(model)">{{ !model.groups.length ? '分组待上线' : hasCallableGroup(model) ? `在线试用 · ${model.groups.length} 个分组` : modelUnavailableLabel(model) }}<ArrowRight :size="14" /></button></footer></article><div v-if="!filteredModels.length" class="empty-state"><Search :size="24" /><strong>没有找到匹配模型</strong><span>换个关键词或筛选条件试试</span></div></section>
|
||||||
<ListPagination v-model:page="modelPage" v-model:page-size="modelPageSize" :total="filteredModels.length" label="模型广场分页" />
|
<ListPagination v-model:page="modelPage" v-model:page-size="modelPageSize" :total="filteredModels.length" label="模型广场分页" />
|
||||||
</template>
|
</template>
|
||||||
@@ -838,7 +834,7 @@ async function createProject() {
|
|||||||
<label v-if="callMode !== '异步'" class="form-label token-limit">最大输出 Token<input v-model.number="maxOutputTokens" class="text-input" type="number" min="1" max="32768" step="1" :disabled="running" /></label>
|
<label v-if="callMode !== '异步'" class="form-label token-limit">最大输出 Token<input v-model.number="maxOutputTokens" class="text-input" type="number" min="1" max="32768" step="1" :disabled="running" /></label>
|
||||||
<small v-if="callMode !== '异步'">按分组人民币售价和实际 Token 用量扣费;调用前预留额度,结束后释放差额。</small>
|
<small v-if="callMode !== '异步'">按分组人民币售价和实际 Token 用量扣费;调用前预留额度,结束后释放差额。</small>
|
||||||
<div v-if="activeInputTypes.length || activeOutputTypes.length" class="capability-strip"><span>输入</span><em v-for="input in activeInputTypes" :key="`input-${input}`">{{ mediaTypeLabel(input) }}</em><span>输出</span><em v-for="output in activeOutputTypes" :key="`output-${output}`">{{ mediaTypeLabel(output) }}</em></div>
|
<div v-if="activeInputTypes.length || activeOutputTypes.length" class="capability-strip"><span>输入</span><em v-for="input in activeInputTypes" :key="`input-${input}`">{{ mediaTypeLabel(input) }}</em><span>输出</span><em v-for="output in activeOutputTypes" :key="`output-${output}`">{{ mediaTypeLabel(output) }}</em></div>
|
||||||
<p v-if="!activeModelReady && activeModel.id" class="request-unavailable" role="status">{{ activeModel.executionReady === false ? '该分组尚未接通相应的执行服务,暂时不能调用。' : !activeModel.pricingConfigured || activeModel.billingReady === false ? '该分组的计费尚未配置完成,暂时不能调用。' : '该模型的调用方式暂不支持在线调试。' }}</p>
|
<p v-if="!activeModelReady && activeModel.id" class="request-unavailable" role="status">{{ routeReadinessReason(activeModel) || '该模型的调用方式暂不支持在线调试。' }}</p>
|
||||||
<label v-if="supportsMediaInput" class="form-label media-input-label"><span>媒体 URL(可选)</span><small>使用模型供应商可访问的 http 或 https 地址;图片会在这里预览</small><input v-model="mediaUrl" class="text-input" type="url" placeholder="https://…/media" :disabled="running" /><img v-if="safeMediaUrl(mediaUrl) && activeInputTypes.some(input => /image/i.test(input))" class="input-media-preview" :src="safeMediaUrl(mediaUrl)" alt="参考图片预览" /></label>
|
<label v-if="supportsMediaInput" class="form-label media-input-label"><span>媒体 URL(可选)</span><small>使用模型供应商可访问的 http 或 https 地址;图片会在这里预览</small><input v-model="mediaUrl" class="text-input" type="url" placeholder="https://…/media" :disabled="running" /><img v-if="safeMediaUrl(mediaUrl) && activeInputTypes.some(input => /image/i.test(input))" class="input-media-preview" :src="safeMediaUrl(mediaUrl)" alt="参考图片预览" /></label>
|
||||||
<label class="form-label prompt-label"><span>输入内容</span><small>{{ prompt.length }}/4000</small></label>
|
<label class="form-label prompt-label"><span>输入内容</span><small>{{ prompt.length }}/4000</small></label>
|
||||||
<textarea v-model="prompt" maxlength="4000" :placeholder="promptPlaceholder" :disabled="running"></textarea>
|
<textarea v-model="prompt" maxlength="4000" :placeholder="promptPlaceholder" :disabled="running"></textarea>
|
||||||
@@ -968,17 +964,17 @@ $env:OPENAI_API_KEY="你的 MOYI 用户 API Key"
|
|||||||
<SlidePanel v-if="selectedModel" :title="selectedModel.name" eyebrow="MODEL DETAILS" @close="selectedModel = null">
|
<SlidePanel v-if="selectedModel" :title="selectedModel.name" eyebrow="MODEL DETAILS" @close="selectedModel = null">
|
||||||
<div class="drawer-model-head"><span class="model-icon" :class="selectedModel.accent"><component :is="selectedModel.icon" :size="22" /></span><div><small>{{ selectedModel.vendorName || '未标注厂商' }}</small><strong>{{ selectedModel.type }} · {{ selectedModel.mode }}调用</strong><small>渠道:{{ selectedModel.provider }}</small></div></div>
|
<div class="drawer-model-head"><span class="model-icon" :class="selectedModel.accent"><component :is="selectedModel.icon" :size="22" /></span><div><small>{{ selectedModel.vendorName || '未标注厂商' }}</small><strong>{{ selectedModel.type }} · {{ selectedModel.mode }}调用</strong><small>渠道:{{ selectedModel.provider }}</small></div></div>
|
||||||
<p class="drawer-description">{{ selectedModel.description }}</p>
|
<p class="drawer-description">{{ selectedModel.description }}</p>
|
||||||
<span class="status-chip" :class="selectedModel.groups.length ? 'success' : 'muted'"><i></i>{{ selectedModel.availability }}</span>
|
<span class="status-chip" :class="hasCallableGroup(selectedModel) ? 'success' : 'muted'"><i></i>{{ selectedModel.availability }}</span>
|
||||||
<dl class="detail-list"><div><dt>模型标识</dt><dd><code>{{ selectedModel.modelKey || selectedModel.name }}</code></dd></div><div><dt>能力规格</dt><dd>{{ selectedModel.specification }}</dd></div></dl>
|
<dl class="detail-list"><div><dt>模型标识</dt><dd><code>{{ selectedModel.modelKey || selectedModel.name }}</code></dd></div><div><dt>能力规格</dt><dd>{{ selectedModel.specification }}</dd></div></dl>
|
||||||
<h3>可调用分组({{ selectedModel.groups.length }})</h3>
|
<h3>模型分组({{ selectedModel.groups.length }})</h3>
|
||||||
<p v-if="!selectedModel.groups.length" class="drawer-description">该模型已收录,尚无上线分组。管理员完成渠道、分组和计费配置后,即可授权 API Key 并调用。</p>
|
<p v-if="!selectedModel.groups.length" class="drawer-description">该模型已收录,尚无上线分组。管理员完成渠道、分组和计费配置后,即可授权 API Key 并调用。</p>
|
||||||
<section v-for="group in selectedModel.groups" :key="group.id" class="catalog-group-detail">
|
<section v-for="group in selectedModel.groups" :key="group.id" class="catalog-group-detail">
|
||||||
<strong>{{ group.sourceLabel || '默认分组' }}</strong><small>{{ group.provider }}</small>
|
<strong>{{ group.sourceLabel || '默认分组' }}</strong><small>{{ group.provider }}</small>
|
||||||
<label>调用模型 ID <code>{{ gatewayModelId(group) }}</code></label>
|
<label>调用模型 ID <code>{{ gatewayModelId(group) }}</code></label>
|
||||||
<button class="text-link" @click="copy(gatewayModelId(group), '调用模型 ID', gatewayModelId(group))"><Copy :size="14" />{{ copySucceeded(gatewayModelId(group)) ? '已复制' : '复制调用 ID' }}</button>
|
<button class="text-link" @click="copy(gatewayModelId(group), '调用模型 ID', gatewayModelId(group))"><Copy :size="14" />{{ copySucceeded(gatewayModelId(group)) ? '已复制' : '复制调用 ID' }}</button>
|
||||||
<small class="drawer-pricing">标准价:{{ groupStandardPriceLabel(group) }} · {{ groupPriceLabel(group) }} · 对外 {{ groupDiscountLabel(group) }}</small>
|
<small class="drawer-pricing">标准价:{{ groupStandardPriceLabel(group) }} · {{ groupPriceLabel(group) }} · 对外 {{ groupDiscountLabel(group) }}</small>
|
||||||
<p v-if="group.billingReason" class="request-unavailable">{{ group.billingReason }}</p>
|
<p v-if="routeReadinessReason(group)" class="request-unavailable">{{ routeReadinessReason(group) }}</p>
|
||||||
<button class="button secondary" :disabled="!group.pricingConfigured || group.billingReady === false || group.executionReady === false" @click="tryModel({ ...selectedModel, groups: [group] })">{{ group.integrationDeferred ? '暂不接入' : !group.pricingConfigured ? '报价待核实' : group.executionReady === false ? '执行接口待接入' : group.billingReady === false ? '用量计费待核实' : '试用此分组' }}</button>
|
<button class="button secondary" :disabled="routeReadinessLabel(group) !== '可调用'" @click="tryModel({ ...selectedModel, groups: [group] })">{{ routeReadinessLabel(group) === '可调用' ? '试用此分组' : routeReadinessLabel(group) }}</button>
|
||||||
</section>
|
</section>
|
||||||
<template #footer><button class="button primary full" :disabled="!hasCallableGroup(selectedModel)" @click="tryModel(selectedModel)"><Play :size="16" />{{ !selectedModel.groups.length ? '分组待上线' : hasCallableGroup(selectedModel) ? '在线试用' : modelUnavailableLabel(selectedModel) }}</button><button class="button secondary full" @click="selectedModel = null; emit('navigate', 'docs')"><BookOpen :size="16" />查看文档</button></template>
|
<template #footer><button class="button primary full" :disabled="!hasCallableGroup(selectedModel)" @click="tryModel(selectedModel)"><Play :size="16" />{{ !selectedModel.groups.length ? '分组待上线' : hasCallableGroup(selectedModel) ? '在线试用' : modelUnavailableLabel(selectedModel) }}</button><button class="button secondary full" @click="selectedModel = null; emit('navigate', 'docs')"><BookOpen :size="16" />查看文档</button></template>
|
||||||
</SlidePanel>
|
</SlidePanel>
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { nextTick, ref } from 'vue'
|
import { nextTick, ref } from 'vue'
|
||||||
import { buildModelCatalog, providerCapabilityLabel, setGroupSelection, summarizeModelCatalog } from '../src/services/model-catalog.ts'
|
import { buildModelCatalog, providerCapabilityLabel, routeReadinessLabel, routeReadinessReason, setGroupSelection, summarizeModelCatalog } from '../src/services/model-catalog.ts'
|
||||||
import { usePagination } from '../src/composables/usePagination.ts'
|
import { usePagination } from '../src/composables/usePagination.ts'
|
||||||
|
|
||||||
|
test('deferred integration overrides pricing and readiness across model entry points', () => {
|
||||||
|
const ready = {pricingConfigured:true,billingReady:true,executionReady:true}
|
||||||
|
const deferred = {...ready,integrationDeferred:true}
|
||||||
|
assert.equal(routeReadinessLabel(ready),'可调用')
|
||||||
|
assert.equal(routeReadinessLabel(deferred),'暂不接入')
|
||||||
|
assert.match(routeReadinessReason(deferred),/本期暂不接入/)
|
||||||
|
assert.equal(routeReadinessLabel({...ready,pricingConfigured:false}),'报价待核实')
|
||||||
|
assert.equal(routeReadinessLabel({...ready,billingReady:false}),'用量计费待核实')
|
||||||
|
assert.equal(routeReadinessLabel({...ready,executionReady:false}),'执行接口待接入')
|
||||||
|
assert.equal(routeReadinessLabel({...ready,status:'disabled'}),'已停用')
|
||||||
|
})
|
||||||
|
|
||||||
test('catalog summary distinguishes published models, ready models, ready routes, and missing prices', () => {
|
test('catalog summary distinguishes published models, ready models, ready routes, and missing prices', () => {
|
||||||
const definitions = [
|
const definitions = [
|
||||||
'available', 'legacy-ready', 'no-routes', 'pricing-only', 'billing-only',
|
'available', 'legacy-ready', 'no-routes', 'pricing-only', 'billing-only',
|
||||||
|
|||||||
@@ -1,6 +1,22 @@
|
|||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { calculateTokenRetailPricing, groupDiscountLabel, modelStandardPriceLabel, platformPriceLabel, standardPriceLabel } from '../src/services/pricing.ts'
|
import { calculateTokenRetailPricing, editRetailAmounts, groupDiscountLabel, modelStandardPriceLabel, platformPriceLabel, standardPriceLabel } from '../src/services/pricing.ts'
|
||||||
|
|
||||||
|
test('admin editing fixed prices preserves source and billing metadata without another discount or conversion', () => {
|
||||||
|
const original = {price:0.4032, unit:'CNY / image', discount:5.6, exchangeRate:7.2, standardPrice:{price:0.1,unit:'USD / image'}, taskBilling:{mode:'fixed'}, evidence:'confirmed'}
|
||||||
|
const saved = editRetailAmounts(original, original.unit, {price:0.48384,input:'',output:'',cachedInput:'',imageInput:''})
|
||||||
|
assert.deepEqual(saved, {...original,price:0.48384})
|
||||||
|
assert.equal(original.price,0.4032)
|
||||||
|
assert.equal(platformPriceLabel(saved),'平台售价 ¥0.48384 / 张(单张请求)')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('admin token editing preserves image-input rate and removes incompatible fixed price', () => {
|
||||||
|
const saved = editRetailAmounts({price:1,taskBilling:{mode:'openai-image-tokens'}}, 'CNY / 1M tokens', {price:'',input:20.16,output:'120.96',cachedInput:0,imageInput:'32.256'})
|
||||||
|
assert.deepEqual(saved, {unit:'CNY / 1M tokens',input:20.16,output:120.96,cachedInput:0,imageInput:32.256,taskBilling:{mode:'openai-image-tokens'}})
|
||||||
|
assert.equal(editRetailAmounts(undefined,'CNY / image',{price:1e-8,input:'',output:'',cachedInput:'',imageInput:''}).price,1e-8)
|
||||||
|
for (const price of [-1,NaN,Infinity,1000001,0.000000001]) assert.throws(()=>editRetailAmounts(undefined,'CNY / image',{price,input:'',output:'',cachedInput:'',imageInput:''}),/人民币价格/)
|
||||||
|
assert.throws(()=>editRetailAmounts(undefined,'USD / image',{price:1,input:'',output:'',cachedInput:'',imageInput:''}),/人民币计费单位/)
|
||||||
|
})
|
||||||
|
|
||||||
test('fixed-unit pricing shows platform task price without inventing a standard price or discount', () => {
|
test('fixed-unit pricing shows platform task price without inventing a standard price or discount', () => {
|
||||||
const tripo = { price: 1.44, unit: 'CNY / task', upstreamCredits: 20, exchangeRate: 7.2, priceSource: 'Tripo 官方', standardPrice: { price: 0.2, unit: 'USD / task', credits: 20 } }
|
const tripo = { price: 1.44, unit: 'CNY / task', upstreamCredits: 20, exchangeRate: 7.2, priceSource: 'Tripo 官方', standardPrice: { price: 0.2, unit: 'USD / task', credits: 20 } }
|
||||||
|
|||||||
Reference in new issue
Block a user