feat: distinguish model vendors and reuse playground keys
This commit is contained in:
1 parent
0a44a0802b
commit
281849ceb8
13 files changed
+222
-46
No files matched your search
@@ -134,10 +134,14 @@ async function copyText(value: string) {
|
||||
.account-search { max-width: 420px; }
|
||||
.account-secondary { display: block; margin-top: 5px; color: #687378; }
|
||||
.wallet-entry { border-bottom: 1px solid #dce3e5; padding: 16px 0; overflow-wrap: anywhere; }
|
||||
.invitation-panel { margin-top: 24px; }
|
||||
.invitation-panel { margin-top: 24px; padding: 24px 28px 28px; }
|
||||
.invitation-panel .panel-header { margin: 0 0 18px; padding: 0; }
|
||||
.invitation-panel .responsive-table { overflow-x: auto; }
|
||||
.invitation-panel th, .invitation-panel td { padding-left: 14px; padding-right: 14px; }
|
||||
.invitation-panel code { overflow-wrap: anywhere; }
|
||||
.invitation-panel .icon-button { margin-left: 8px; vertical-align: middle; }
|
||||
.form-hint { color: #687378; font-size: 13px; }
|
||||
.credit-error { color: #b44837; }
|
||||
@media(max-width: 700px) { .heading-actions { flex-wrap: wrap; } }
|
||||
@media(max-width: 700px) { .invitation-panel { padding: 18px 16px 20px; } .invitation-panel .panel-header { margin-bottom: 14px; } }
|
||||
</style>
|
||||
@@ -28,9 +28,9 @@ async function remove() {
|
||||
finally { saving.value = false }
|
||||
}
|
||||
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: '', 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', priority: '100', maxConcurrency: '1', status: 'active' as CatalogModel['status'] })
|
||||
const shownModels = computed(() => models.value.filter(item => `${item.publicName} ${item.modelKey || ''}`.toLowerCase().includes(query.value.toLowerCase())))
|
||||
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', priority: '100', maxConcurrency: '4', status: 'active' as CatalogModel['status'] })
|
||||
const shownModels = computed(() => models.value.filter(item => `${item.publicName} ${item.vendorName || ''} ${item.modelKey || ''}`.toLowerCase().includes(query.value.toLowerCase())))
|
||||
const shownChannels = computed(() => channels.value.filter(item => `${item.name} ${item.code}`.toLowerCase().includes(query.value.toLowerCase())))
|
||||
const { page: modelPage, pageSize: modelPageSize, pagedItems: pagedModels } = usePagination(shownModels)
|
||||
const { page: channelPage, pageSize: channelPageSize, pagedItems: pagedChannels } = usePagination(shownChannels)
|
||||
@@ -59,12 +59,12 @@ function editChannel(item?: CatalogProvider) {
|
||||
}
|
||||
function editModel(item?: LogicalModel) {
|
||||
editingId.value = item?.id
|
||||
Object.assign(model, { publicName: '', modelKey: '', type: 'text', mode: 'sync', description: '', status: 'active' }, item || {}, { inputTypes: item?.inputTypes.join(', ') || 'text', outputTypes: item?.outputTypes.join(', ') || 'text' })
|
||||
Object.assign(model, { publicName: '', modelKey: '', vendorName: '', type: 'text', mode: 'sync', description: '', status: 'active' }, item || {}, { inputTypes: item?.inputTypes.join(', ') || 'text', outputTypes: item?.outputTypes.join(', ') || 'text' })
|
||||
editor.value = 'model'
|
||||
}
|
||||
function editGroup(parent: LogicalModel, item?: CatalogModel) {
|
||||
editingId.value = item?.id
|
||||
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', priority: String(item?.priority ?? 100), maxConcurrency: String(item?.maxConcurrency ?? 1), 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', priority: String(item?.priority ?? 100), maxConcurrency: String(item?.maxConcurrency ?? 4), status: item?.status || 'active' })
|
||||
editor.value = 'group'
|
||||
}
|
||||
async function save() {
|
||||
@@ -108,13 +108,13 @@ async function toggle(kind: 'channel' | 'model' | 'group', item: CatalogProvider
|
||||
<section class="page-heading"><h1>{{ props.section === 'channels' ? '渠道管理' : '模型与分组' }}</h1><div class="heading-actions"><button class="icon-button" title="刷新" :disabled="loading" @click="refresh"><RefreshCcw :size="18" /></button><button class="button primary" @click="props.section === 'channels' ? editChannel() : editModel()"><Plus :size="16" />{{ props.section === 'channels' ? '添加渠道' : '添加模型' }}</button></div></section>
|
||||
<label class="search-input catalog-search"><Search :size="16" /><input v-model="query" :placeholder="props.section === 'channels' ? '搜索渠道名称或 Code' : '搜索模型名称或标识'" /></label>
|
||||
<p v-if="error" role="alert">{{ error }}</p>
|
||||
<p v-if="props.section === 'models'" class="catalog-secondary">启用模型后会显示在用户端模型广场。分组与所属渠道也启用后,用户才能为 API Key 选择该分组;调用前还需完成凭据和计费配置。</p>
|
||||
<p v-if="props.section === 'models'" class="catalog-secondary">启用模型后会显示在用户端模型广场。模型厂商表示模型的实际研发方,渠道表示请求经过的中转站或官方接口;分组与所属渠道也启用后,用户才能为 API Key 选择该分组。并发上限按分组生效,填 1 才是串行,填 4 表示同一分组最多同时处理 4 个请求。</p>
|
||||
<p v-if="loading">加载中…</p>
|
||||
<div v-if="props.section === 'channels'" class="responsive-table"><table><thead><tr><th>渠道</th><th>来源 / 协议</th><th>Base URL</th><th>凭据</th><th>状态</th><th>操作</th></tr></thead><tbody><tr v-for="item in pagedChannels" :key="item.id"><td><strong>{{ item.name }}</strong><small class="catalog-secondary">{{ item.code }}</small></td><td>{{ item.sourceType }}<small class="catalog-secondary">{{ item.protocol }}</small></td><td class="catalog-url">{{ item.baseUrl || '未配置' }}</td><td>{{ item.credentialMasked || '未配置' }}</td><td><label class="catalog-toggle"><input type="checkbox" :checked="item.status === 'active'" :disabled="saving" :aria-label="`${item.name} 启用`" @change="toggle('channel', item)" />{{ item.status === 'active' ? '已启用' : '已停用' }}</label></td><td><button class="icon-button" :title="`编辑渠道 ${item.name}`" @click="editChannel(item)"><Pencil :size="16" /></button><button class="icon-button" :title="`删除渠道 ${item.name}`" :disabled="saving" @click="confirmDelete('channel', item.id, item.name)"><Trash2 :size="16" /></button></td></tr><tr v-if="!shownChannels.length && !loading"><td colspan="6">暂无渠道</td></tr></tbody></table></div>
|
||||
<ListPagination v-if="props.section === 'channels'" v-model:page="channelPage" v-model:page-size="channelPageSize" :total="shownChannels.length" label="渠道分页" />
|
||||
<template v-if="props.section === 'models'">
|
||||
<section v-for="item in pagedModels" :key="item.id" class="model-definition-section">
|
||||
<header class="panel-header"><div><h3>{{ item.publicName }}</h3><small>{{ 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>
|
||||
<div class="responsive-table"><table><thead><tr><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.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="7">暂无分组</td></tr></tbody></table></div>
|
||||
</section>
|
||||
@@ -136,6 +136,7 @@ async function toggle(kind: 'channel' | 'model' | 'group', item: CatalogProvider
|
||||
</template>
|
||||
<template v-else-if="editor === 'model'">
|
||||
<label class="form-label" for="logical-name">模型名称</label><input id="logical-name" v-model="model.publicName" class="text-input" required maxlength="160" />
|
||||
<label class="form-label" for="logical-vendor">模型厂商</label><input id="logical-vendor" v-model="model.vendorName" class="text-input" required maxlength="120" placeholder="例如:OpenAI、智谱 AI、月之暗面、字节跳动" />
|
||||
<label class="form-label" for="logical-key">统一模型标识</label><input id="logical-key" v-model="model.modelKey" class="text-input" maxlength="160" />
|
||||
<label class="form-label" for="logical-type">模型类型</label><select id="logical-type" v-model="model.type" class="text-input"><option value="text">文本</option><option value="code">代码</option><option value="multimodal">多模态</option><option value="image">图像</option><option value="audio">音频</option><option value="video">视频</option><option value="embedding">向量</option><option value="3d">3D</option></select>
|
||||
<label class="form-label" for="logical-mode">调用模式</label><select id="logical-mode" v-model="model.mode" class="text-input"><option value="sync">同步</option><option value="stream">流式</option><option value="async">异步</option></select>
|
||||
@@ -152,7 +153,7 @@ async function toggle(kind: 'channel' | 'model' | 'group', item: CatalogProvider
|
||||
<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 />
|
||||
<small>文本聊天自动扣费仅支持 CNY / 1M tokens(元/百万 Token)。输入、输出均需填写;填 0 表示免费,留空则禁止调用。请填写平台对用户的售价。</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">并发上限</span><input v-model="group.maxConcurrency" class="text-input" type="number" min="1" step="1" required /></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">并发上限</span><input v-model="group.maxConcurrency" class="text-input" type="number" min="1" step="1" required /><small>1 为串行;建议按该渠道限额填写,4 表示最多同时处理 4 个请求。</small></label></div>
|
||||
</template>
|
||||
</form>
|
||||
<template #footer><button class="button secondary" :disabled="saving" @click="editor = ''">取消</button><button class="button primary" form="catalog-editor" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存' }}</button></template>
|
||||
|
||||
@@ -11,14 +11,14 @@ const query = ref('')
|
||||
const onlySelected = ref(false)
|
||||
const expanded = ref<string[]>([])
|
||||
const models = computed(() => [...new Map(props.groups.map(group => [group.logicalModelId || group.id, group])).entries()].map(([id, model]) => ({
|
||||
id, name: model.name, modelKey: model.modelKey,
|
||||
id, name: model.name, vendorName: model.vendorName, modelKey: model.modelKey,
|
||||
groups: props.groups.filter(group => (group.logicalModelId || group.id) === id),
|
||||
})))
|
||||
const selectedGroups = computed(() => props.groups.filter(group => props.modelValue.includes(group.id)))
|
||||
const selectedCount = computed(() => models.value.filter(model => model.groups.some(group => props.modelValue.includes(group.id))).length)
|
||||
const unavailable = computed(() => props.modelValue.filter(id => !props.groups.some(group => group.id === id)))
|
||||
const filtered = computed(() => models.value.filter(model => {
|
||||
const text = `${model.name} ${model.modelKey || ''} ${model.groups.map(group => `${group.provider} ${group.sourceLabel}`).join(' ')}`.toLowerCase()
|
||||
const text = `${model.name} ${model.vendorName || ''} ${model.modelKey || ''} ${model.groups.map(group => `${group.provider} ${group.sourceLabel}`).join(' ')}`.toLowerCase()
|
||||
return text.includes(query.value.trim().toLowerCase()) && (!onlySelected.value || model.groups.some(group => props.modelValue.includes(group.id)))
|
||||
}))
|
||||
const { page, pageSize, pagedItems } = usePagination(filtered, 8)
|
||||
@@ -41,11 +41,11 @@ function clear() { expanded.value = []; emit('update:modelValue', []) }
|
||||
<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>
|
||||
</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>
|
||||
<label class="selected-filter"><input v-model="onlySelected" type="checkbox" :disabled="disabled" />仅看已授权模型</label>
|
||||
<div class="permission-list">
|
||||
<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.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>
|
||||
<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">
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface CatalogModel {
|
||||
logicalModelId: string
|
||||
providerId: string
|
||||
modelKey?: string
|
||||
vendorName?: string
|
||||
sourceLabel?: string
|
||||
publicName: string
|
||||
upstreamModel: string
|
||||
@@ -38,6 +39,7 @@ export interface LogicalModel {
|
||||
id: string
|
||||
publicName: string
|
||||
modelKey?: string
|
||||
vendorName?: string
|
||||
type: CatalogModelType
|
||||
mode: CatalogCallMode
|
||||
description: string
|
||||
@@ -298,6 +300,14 @@ class HttpCatalogClient {
|
||||
})
|
||||
}
|
||||
|
||||
async playgroundChatCompletion(keyId: string, input: { model: string; prompt: string; maxTokens?: number }) {
|
||||
return this.request<ChatCompletionResult>(`/api/playground/keys/${encodeURIComponent(keyId)}/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: { 'X-Moyi-Source': 'playground', 'Idempotency-Key': crypto.randomUUID() },
|
||||
body: JSON.stringify({ model: input.model, messages: [{ role: 'user', content: input.prompt }], max_tokens: input.maxTokens || 4096 }),
|
||||
})
|
||||
}
|
||||
|
||||
async streamChat(apiKey: string, input: { model: string; prompt: string; maxTokens: number }, onDelta: (content: string, reasoning: string) => void, signal: AbortSignal) {
|
||||
const response = await fetch(`${this.baseUrl}/v1/chat/completions`, {
|
||||
method: 'POST', credentials: 'include', signal,
|
||||
@@ -313,6 +323,21 @@ class HttpCatalogClient {
|
||||
await readChatStream(response.body, onDelta)
|
||||
}
|
||||
|
||||
async playgroundStreamChat(keyId: string, input: { model: string; prompt: string; maxTokens: number }, onDelta: (content: string, reasoning: string) => void, signal: AbortSignal) {
|
||||
const response = await fetch(`${this.baseUrl}/api/playground/keys/${encodeURIComponent(keyId)}/chat/completions`, {
|
||||
method: 'POST', credentials: 'include', signal,
|
||||
headers: { 'Content-Type': 'application/json', 'X-Moyi-Source': 'playground', 'Idempotency-Key': crypto.randomUUID() },
|
||||
body: JSON.stringify({ model: input.model, messages: [{ role: 'user', content: input.prompt }], stream: true, max_tokens: input.maxTokens }),
|
||||
})
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({}))
|
||||
throw new Error(error.error?.message || `调用失败 (${response.status})`)
|
||||
}
|
||||
if (!response.body || !response.headers.get('content-type')?.includes('text/event-stream')) throw new Error('服务未返回流式响应')
|
||||
const { readChatStream } = await import('./chat-stream')
|
||||
await readChatStream(response.body, onDelta)
|
||||
}
|
||||
|
||||
async createMediaTask(apiKey: string, input: { model: string; prompt: string; mediaType: '3d' | 'video' }) {
|
||||
const payload = await this.request<{ task: AsyncTaskResult }>(input.mediaType === 'video' ? '/v1/video/tasks' : '/v1/3d/tasks', {
|
||||
method: 'POST',
|
||||
@@ -322,6 +347,13 @@ class HttpCatalogClient {
|
||||
return payload.task
|
||||
}
|
||||
|
||||
async playgroundCreateMediaTask(keyId: string, input: { model: string; prompt: string; mediaType: '3d' | 'video' }) {
|
||||
const payload = await this.request<{ task: AsyncTaskResult }>(`/api/playground/keys/${encodeURIComponent(keyId)}/${input.mediaType === 'video' ? 'video' : '3d'}/tasks`, {
|
||||
method: 'POST', headers: { 'X-Moyi-Source': 'playground' }, body: JSON.stringify({ model: input.model, prompt: input.prompt }),
|
||||
})
|
||||
return payload.task
|
||||
}
|
||||
|
||||
async getTask(apiKey: string, taskId: string) {
|
||||
const payload = await this.request<{ task: AsyncTaskResult }>(`/v1/tasks/${encodeURIComponent(taskId)}`, {
|
||||
headers: { Authorization: `Bearer ${apiKey}` },
|
||||
@@ -329,6 +361,11 @@ class HttpCatalogClient {
|
||||
return payload.task
|
||||
}
|
||||
|
||||
async playgroundGetTask(keyId: string, taskId: string) {
|
||||
const payload = await this.request<{ task: AsyncTaskResult }>(`/api/playground/keys/${encodeURIComponent(keyId)}/tasks/${encodeURIComponent(taskId)}`, { headers: { 'X-Moyi-Source': 'playground' } })
|
||||
return payload.task
|
||||
}
|
||||
|
||||
async listTasks(apiKey: string, limit = 50) {
|
||||
const payload = await this.request<{ tasks: AsyncTaskResult[] }>(`/v1/tasks?limit=${Math.max(1, Math.min(limit, 100))}`, {
|
||||
headers: { Authorization: `Bearer ${apiKey}` },
|
||||
|
||||
@@ -173,6 +173,11 @@ td strong{font-size:12px}
|
||||
.playground-connection>div{min-width:0;display:flex;flex:1;flex-direction:column;gap:4px}
|
||||
.playground-connection strong{color:var(--text);font-size:12px}
|
||||
.playground-connection small{color:var(--muted);font-size:10px;line-height:1.5}
|
||||
.playground-key-picker{display:flex;align-items:center;gap:6px;min-width:300px}
|
||||
.playground-key-picker span{color:var(--muted);font-size:11px;white-space:nowrap}
|
||||
.playground-key-picker select,.playground-key-picker input{min-width:0;height:34px;padding:0 9px;border:1px solid #dce3ed;border-radius:8px;background:#fff;color:var(--text);font:inherit;font-size:11px}
|
||||
.playground-key-picker select{flex:1;max-width:190px}
|
||||
.playground-key-picker input{flex:1;max-width:220px}
|
||||
.playground-connection.ready{border-color:#cce9df;background:#f8fcfa}
|
||||
.playground-connection.ready>span{color:var(--green);background:var(--green-soft)}
|
||||
.playground-connection.offline>span{color:var(--orange);background:var(--orange-soft)}
|
||||
@@ -197,12 +202,14 @@ td strong{font-size:12px}
|
||||
.drawer-task-preview img{width:100%;height:100%;object-fit:contain}
|
||||
.drawer-task-preview video{width:100%;height:100%;object-fit:contain;background:#080b1c}
|
||||
|
||||
@media(max-width:900px){.playground-connection{align-items:flex-start;flex-wrap:wrap}.playground-connection>div{min-width:calc(100% - 52px)}.playground-connection>.button{margin-left:48px}.task-preview{height:210px}}
|
||||
@media(max-width:520px){.playground-connection>.button{width:100%;margin-left:0}.task-preview{height:190px}.live-task-head{align-items:flex-start;flex-direction:column}.live-task-actions{align-items:stretch;flex-wrap:wrap}.live-task-actions .button{flex:1}.request-panel,.response-panel{min-height:520px;padding:16px}}
|
||||
@media(max-width:900px){.playground-connection{align-items:flex-start;flex-wrap:wrap}.playground-connection>div{min-width:calc(100% - 52px)}.playground-key-picker{width:100%;margin-left:48px;min-width:0}.playground-key-picker select,.playground-key-picker input{max-width:none}.playground-connection>.button{margin-left:48px}.task-preview{height:210px}}
|
||||
@media(max-width:520px){.playground-connection>.button{width:100%;margin-left:0}.playground-key-picker{margin-left:0;flex-direction:column;align-items:stretch}.playground-key-picker select,.playground-key-picker input{width:100%}.task-preview{height:190px}.live-task-head{align-items:flex-start;flex-direction:column}.live-task-actions{align-items:stretch;flex-wrap:wrap}.live-task-actions .button{flex:1}.request-panel,.response-panel{min-height:520px;padding:16px}}
|
||||
|
||||
.model-permission-summary{display:inline-flex;align-items:center;gap:7px;padding:6px 9px;border:1px solid #dfe4ee;border-radius:7px;color:#5c4ade;background:#faf9ff;font-size:11px;cursor:pointer}.model-permission-summary:hover:not(:disabled){border-color:#b8acf9;background:#f3f0ff}.model-permission-summary:disabled{color:#98a2b3;background:#f7f8fa;cursor:not-allowed}.permission-hint{display:flex;align-items:flex-start;gap:8px;margin-top:18px;padding:11px 12px;border:1px solid #e4e0ff;border-radius:9px;color:#6252d7;background:#faf9ff;font-size:11px;line-height:1.5}.permission-hint svg{flex:0 0 auto;margin-top:1px}.permission-all-toggle,.permission-model-button{width:100%;display:flex;align-items:center;gap:10px;padding:12px 13px;border:1px solid #e4e7ef;border-radius:10px;background:#fff;color:var(--text);text-align:left;cursor:pointer}.permission-all-toggle{justify-content:space-between;margin-bottom:10px}.permission-all-toggle>span,.permission-model-button>span:nth-child(2){min-width:0;display:flex;flex:1;flex-direction:column;gap:3px}.permission-all-toggle strong,.permission-model-button strong{font-size:12px}.permission-all-toggle small,.permission-model-button small{overflow:hidden;color:var(--muted);font-size:10px;text-overflow:ellipsis;white-space:nowrap}.permission-all-toggle>span:first-child,.permission-model-button>span:first-child{display:flex;align-items:center;gap:8px}.permission-all-toggle i,.permission-model-button i{width:15px;height:15px;display:block;border:1.5px solid #cbd2df;border-radius:50%;background:#fff}.permission-all-toggle.active,.permission-model-button.active{border-color:#c7bcff;color:#5541d5;background:#faf9ff}.permission-all-toggle.active i,.permission-model-button.active i{border-color:#654de4;box-shadow:inset 0 0 0 4px #fff;background:#654de4}.permission-model-list{display:flex;max-height:290px;overflow:auto;flex-direction:column;gap:8px;padding-right:3px}.permission-model-button:hover{border-color:#b8acf9}.permission-model-button .model-icon{width:29px;height:29px;flex:0 0 29px}.modal-textarea{min-height:76px;resize:vertical}.modal-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:13px}@media(max-width:600px){.modal-form-grid{grid-template-columns:1fr}.permission-model-list{max-height:240px}}
|
||||
.model-filter-panel{display:flex;flex-direction:column;gap:13px;padding:16px;border:1px solid var(--border);border-radius:12px;background:#fff;box-shadow:var(--shadow)}.model-filter-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.model-filter-head>div{display:flex;align-items:baseline;gap:10px}.model-filter-head strong{color:var(--text);font-size:13px}.model-filter-head span{color:var(--muted);font-size:11px}.model-filter-grid{display:grid;grid-template-columns:minmax(220px,1.7fr) repeat(4,minmax(125px,1fr));gap:9px}.model-filter-search{width:auto;height:42px}.select-filter{display:flex;min-width:0;flex-direction:column;gap:5px}.select-filter span{color:var(--muted);font-size:10px}.select-filter select{width:100%;height:42px;padding:0 11px;border:1px solid var(--border);border-radius:8px;color:var(--text-soft);font-size:11px;background:var(--soft)}.select-filter select:focus{outline:0;border-color:#bdb2f2;box-shadow:0 0 0 3px rgba(104,72,232,.07)}.filter-summary{display:flex;align-items:center;gap:12px;color:var(--muted);font-size:10px}.filter-summary span+span{padding-left:12px;border-left:1px solid var(--border);color:var(--primary)}
|
||||
.provider-source-tag{display:inline-flex;align-items:center;gap:4px;padding:4px 7px;border-radius:5px;color:#5d54b8;font-size:10px;background:#f2efff}.provider-source-tag.relay{color:#176f91;background:#e9f9fd}.provider-source-tag.self-hosted{color:#317a5d;background:#ebf9f0}.provider-source-tag.custom{color:#6d7583;background:#f1f3f6}.provider-meta{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-top:5px}.provider-endpoint{overflow:hidden;max-width:250px;color:var(--muted);font-family:"DM Mono",monospace;font-size:10px;text-overflow:ellipsis;white-space:nowrap}.provider-credential{color:#5f6b7c;font-size:10px}.admin-model-grid article{position:relative}.admin-model-grid article .model-source-line{display:flex;align-items:center;gap:7px;margin-top:8px;color:var(--muted);font-size:10px}.model-route-meta{display:flex;align-items:center;flex-wrap:wrap;gap:7px;margin-top:10px}.model-route-meta span{padding:4px 6px;border-radius:5px;color:#596579;font-size:10px;background:var(--soft)}.model-route-meta span strong{color:var(--text);font-weight:700}.admin-config-section{margin-top:16px}.admin-config-section .section-title{margin-bottom:11px}
|
||||
@media(max-width:1150px){.model-filter-grid{grid-template-columns:1fr 1fr 1fr}.model-filter-search{grid-column:1/-1}}@media(max-width:720px){.model-filter-grid{grid-template-columns:1fr 1fr}.model-filter-search{grid-column:1/-1}.model-filter-head>div{align-items:flex-start;flex-direction:column;gap:4px}.filter-summary{align-items:flex-start;flex-direction:column;gap:5px}.filter-summary span+span{padding:0;border:0}}@media(max-width:480px){.model-filter-grid{grid-template-columns:1fr}.model-filter-search{grid-column:auto}}
|
||||
/* Keep the marketplace filter row wide enough for vendor and channel selectors. */
|
||||
@media(min-width:1151px){.model-filter-grid{grid-template-columns:minmax(220px,1.7fr) repeat(5,minmax(125px,1fr))}}
|
||||
/* Usage audit console */
|
||||
.usage-filter{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.usage-filter .search-input{min-width:260px;flex:1}.usage-filter select{min-width:120px}.button.danger{color:#fff;border-color:#d94b62;background:#d94b62}.button.danger:hover{background:#bd354d}.danger-icon{color:#c43d55}.usage-table th:first-child,.usage-table td:first-child{width:36px}.usage-table input[type=checkbox]{width:15px;height:15px;accent-color:#6351df}.usage-table code{font-size:10px}.usage-detail-list{margin-bottom:18px}.usage-payload{max-height:180px;overflow:auto;margin:6px 0 15px;padding:11px;border:1px solid var(--border);border-radius:8px;color:#344054;font:11px/1.55 "DM Mono",monospace;white-space:pre-wrap;word-break:break-word;background:#f7f8fb}.table-pagination{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-top:1px solid var(--border);color:var(--muted);font-size:11px}.table-pagination>div{display:flex;gap:6px}.rotate-90{transform:rotate(90deg)}.rotate--90{transform:rotate(-90deg)}
|
||||
@@ -23,6 +23,7 @@ export interface ModelItem {
|
||||
id: string
|
||||
name: string
|
||||
provider: string
|
||||
vendorName?: string
|
||||
type: ModelType
|
||||
mode: CallMode
|
||||
description: string
|
||||
|
||||
@@ -53,6 +53,7 @@ const emit = defineEmits<{ navigate: [view: string]; notify: [message: string];
|
||||
const modelQuery = ref('')
|
||||
const modelType = ref<'全部' | ModelType>('全部')
|
||||
const modelProvider = ref('全部')
|
||||
const modelVendor = ref('全部')
|
||||
const modelMode = ref<'全部' | CallMode>('全部')
|
||||
const modelAvailability = ref<'全部' | '在线' | '待上线'>('全部')
|
||||
type GalleryModel = ModelItem & { groups: ModelItem[]; providerNames: string[] }
|
||||
@@ -120,7 +121,10 @@ const savingPermissions = ref(false)
|
||||
const projects = ref<CatalogProject[]>([])
|
||||
const keyScopeType = ref<'personal' | 'project'>('personal')
|
||||
const selectedProjectId = ref('')
|
||||
const remoteApiKey = ref('')
|
||||
const selectedApiKeyId = ref('')
|
||||
const activeDebugKeys = computed(() => keys.value.filter((key) => key.status === '正常'))
|
||||
const selectedDebugKey = computed(() => activeDebugKeys.value.find((key) => String(key.id) === selectedApiKeyId.value))
|
||||
const debugKeyCanInvoke = computed(() => !!selectedDebugKey.value?.modelIds.includes(activeModel.value.id))
|
||||
const catalogConnected = ref(false)
|
||||
const overviewLoaded = ref(false)
|
||||
const overview = ref<PlatformOverview>({ generatedAt: '', callsToday: 0, callsThisMonth: 0, asyncTasks: 0, tasks: { queued: 0, running: 0, succeeded: 0, failed: 0 }, series: [], ledger: [] })
|
||||
@@ -129,6 +133,10 @@ const taskPollers = new Map<string, number>()
|
||||
const copyTimers = new Map<string, number>()
|
||||
const copyStates = ref<Record<string, CopyResult | undefined>>({})
|
||||
|
||||
function selectDebugApiKey(id: string) {
|
||||
selectedApiKeyId.value = id
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const [catalog, keyResult, projectResult, overviewResult] = await Promise.all([catalogClient.listModels(), catalogClient.listKeys(), catalogClient.listProjects(), catalogClient.getOverview()])
|
||||
@@ -137,6 +145,7 @@ onMounted(async () => {
|
||||
catalogRoutes.value = catalog.models
|
||||
if (catalogModels.value[0]) selectPlaygroundGroup(catalogModels.value[0].id)
|
||||
keys.value = keyResult.keys.map((key) => mapCatalogKey(key))
|
||||
selectedApiKeyId.value = String(keys.value.find((key) => key.status === '正常')?.id || '')
|
||||
projects.value = projectResult.projects
|
||||
overview.value = overviewResult
|
||||
emit('balance', overviewResult.availableCredit)
|
||||
@@ -173,17 +182,20 @@ const filteredModels = computed(() => {
|
||||
return galleryModels.value.filter((model) =>
|
||||
(modelType.value === '全部' || model.type === modelType.value)
|
||||
&& (modelProvider.value === '全部' || model.providerNames.includes(modelProvider.value))
|
||||
&& (modelVendor.value === '全部' || model.vendorName === modelVendor.value)
|
||||
&& (modelMode.value === '全部' || model.mode === modelMode.value)
|
||||
&& (modelAvailability.value === '全部' || model.availability === modelAvailability.value)
|
||||
&& (!query || `${model.name} ${model.description} ${model.provider} ${model.sourceLabel || ''} ${model.modelKey || ''}`.toLowerCase().includes(query)),
|
||||
&& (!query || `${model.name} ${model.vendorName || ''} ${model.description} ${model.provider} ${model.sourceLabel || ''} ${model.modelKey || ''}`.toLowerCase().includes(query)),
|
||||
)
|
||||
})
|
||||
const { page: modelPage, pageSize: modelPageSize, pagedItems: pagedModels } = usePagination(filteredModels)
|
||||
watch([modelQuery, modelType, modelProvider, modelMode, modelAvailability], () => { modelPage.value = 1 })
|
||||
watch([modelQuery, modelType, modelProvider, modelVendor, modelMode, modelAvailability], () => { modelPage.value = 1 })
|
||||
const modelProviders = computed(() => [...new Set(catalogModels.value.map((model) => model.provider))].sort((left, right) => left.localeCompare(right)))
|
||||
const modelVendors = computed(() => [...new Set(galleryModels.value.map((model) => model.vendorName).filter((vendor): vendor is string => !!vendor && vendor !== '未标注'))].sort((left, right) => left.localeCompare(right)))
|
||||
const activeModelFilters = computed(() => [
|
||||
modelType.value !== '全部' ? modelType.value : '',
|
||||
modelProvider.value !== '全部' ? modelProvider.value : '',
|
||||
modelVendor.value !== '全部' ? modelVendor.value : '',
|
||||
modelMode.value !== '全部' ? modelMode.value : '',
|
||||
modelAvailability.value !== '全部' ? modelAvailability.value : '',
|
||||
].filter(Boolean))
|
||||
@@ -222,6 +234,7 @@ function resetModelFilters() {
|
||||
modelQuery.value = ''
|
||||
modelType.value = '全部'
|
||||
modelProvider.value = '全部'
|
||||
modelVendor.value = '全部'
|
||||
modelMode.value = '全部'
|
||||
modelAvailability.value = '全部'
|
||||
}
|
||||
@@ -250,12 +263,12 @@ async function runModel() {
|
||||
if (running.value) return
|
||||
if (callMode.value !== '异步' && (!Number.isInteger(maxOutputTokens.value) || maxOutputTokens.value < 1 || maxOutputTokens.value > 32768)) return emit('notify', '最大输出 Token 须为 1–32768 的整数')
|
||||
if (!catalogConnected.value) return emit('notify', 'Control Plane 未连接,无法提交真实调用')
|
||||
if (!remoteApiKey.value) {
|
||||
emit('notify', '请先创建一个临时 API Key,再进行真实接口调用')
|
||||
emit('navigate', 'keys')
|
||||
createKeyOpen.value = true
|
||||
const apiKey = selectedApiKeyId.value
|
||||
if (!selectedDebugKey.value) {
|
||||
emit('notify', '请选择一个启用中的 API Key')
|
||||
return
|
||||
}
|
||||
if (!debugKeyCanInvoke.value) return emit('notify', '该 Key 尚未授权当前模型分组,请切换 Key 或修改模型权限')
|
||||
running.value = true
|
||||
response.value = ''
|
||||
responseError.value = ''
|
||||
@@ -263,17 +276,17 @@ async function runModel() {
|
||||
const selectedMode = callMode.value
|
||||
try {
|
||||
if (callMode.value === '异步') {
|
||||
const task = await catalogClient.createMediaTask(remoteApiKey.value, { model: activeModel.value.id, prompt: prompt.value, mediaType: activeModel.value.type === '视频' ? 'video' : '3d' })
|
||||
const task = await catalogClient.playgroundCreateMediaTask(apiKey, { model: activeModel.value.id, prompt: prompt.value, mediaType: activeModel.value.type === '视频' ? 'video' : '3d' })
|
||||
const taskItem = mapAsyncTask(task, activeModel.value, prompt.value)
|
||||
tasks.value.unshift(taskItem)
|
||||
activeTaskId.value = task.id
|
||||
response.value = `任务 ${task.id} 已进入队列,可前往任务中心查看进度。`
|
||||
scheduleTaskPoll(task.id, remoteApiKey.value)
|
||||
scheduleTaskPoll(task.id, apiKey)
|
||||
} else if (selectedMode === '流式') {
|
||||
streamAbort = new AbortController()
|
||||
await catalogClient.streamChat(remoteApiKey.value, { model: activeModel.value.id, prompt: prompt.value, maxTokens: maxOutputTokens.value }, (text, reasoning) => { response.value += text; reasoningOutput.value += reasoning }, streamAbort.signal)
|
||||
await catalogClient.playgroundStreamChat(apiKey, { model: activeModel.value.id, prompt: prompt.value, maxTokens: maxOutputTokens.value }, (text, reasoning) => { response.value += text; reasoningOutput.value += reasoning }, streamAbort.signal)
|
||||
} else {
|
||||
const result = await catalogClient.chatCompletion(remoteApiKey.value, { model: activeModel.value.id, prompt: prompt.value, maxTokens: maxOutputTokens.value })
|
||||
const result = await catalogClient.playgroundChatCompletion(apiKey, { model: activeModel.value.id, prompt: prompt.value, maxTokens: maxOutputTokens.value })
|
||||
response.value = result.choices[0]?.message.content || '模型未返回内容'
|
||||
}
|
||||
emit('notify', callMode.value === '异步' ? '异步任务提交成功' : '模型调用完成')
|
||||
@@ -332,7 +345,7 @@ function scheduleTaskPoll(taskId: string, apiKey: string, delay = 1200) {
|
||||
|
||||
async function pollTask(taskId: string, apiKey: string) {
|
||||
try {
|
||||
const latest = await catalogClient.getTask(apiKey, taskId)
|
||||
const latest = await catalogClient.playgroundGetTask(apiKey, taskId)
|
||||
const index = tasks.value.findIndex((task) => task.id === taskId)
|
||||
if (index < 0) return
|
||||
const previous = tasks.value[index]!
|
||||
@@ -363,7 +376,7 @@ async function createKey() {
|
||||
if (!catalogConnected.value) return emit('notify', 'Control Plane 未连接,无法创建真实 Key')
|
||||
try {
|
||||
const result = await catalogClient.createKey({ name: keyName.value.trim() || '默认开发 Key', ...(keyScopeType.value === 'project' ? { projectId: selectedProjectId.value } : {}) })
|
||||
remoteApiKey.value = result.key
|
||||
selectedApiKeyId.value = String(result.apiKey.id)
|
||||
keys.value.unshift(mapCatalogKey(result.apiKey, result.key))
|
||||
createdSecret.value = result.key
|
||||
createdKeyId.value = result.apiKey.id
|
||||
@@ -383,6 +396,7 @@ function mapCatalogModels(items: CatalogModel[], providers: Array<{ id: string;
|
||||
return items.map(item => ({
|
||||
...mapCatalogModel(item), logicalModelId: item.logicalModelId,
|
||||
provider: providerNames.get(item.providerId) || item.providerId,
|
||||
vendorName: item.vendorName,
|
||||
sourceLabel: item.sourceLabel, pricing: item.pricing, priority: item.priority, maxConcurrency: item.maxConcurrency,
|
||||
}))
|
||||
}
|
||||
@@ -394,6 +408,7 @@ function mapCatalogModel(item: LogicalModel): ModelItem {
|
||||
id: item.id,
|
||||
name: item.publicName,
|
||||
provider: '',
|
||||
vendorName: item.vendorName,
|
||||
type: typeLabels[item.type] || '文本',
|
||||
mode: modeLabels[item.mode] || '同步',
|
||||
description: item.description,
|
||||
@@ -474,6 +489,9 @@ async function toggleKey(key: ApiKeyItem) {
|
||||
const enabled = key.status !== '正常'
|
||||
await catalogClient.setKeyStatus(String(key.id), enabled ? 'active' : 'disabled')
|
||||
key.status = enabled ? '正常' : '已停用'
|
||||
if (!enabled && String(key.id) === selectedApiKeyId.value) {
|
||||
selectedApiKeyId.value = ''
|
||||
}
|
||||
emit('notify', `${key.name} ${enabled ? '已重新启用' : '已停用'}`)
|
||||
} catch (error) { emit('notify', error instanceof Error ? error.message : '更新 Key 状态失败') }
|
||||
finally { keyBusy.value = false }
|
||||
@@ -485,7 +503,8 @@ async function deleteKey() {
|
||||
const id = deleteKeyTarget.value.id
|
||||
await catalogClient.deleteKey(String(id))
|
||||
keys.value = keys.value.filter(key => key.id !== id)
|
||||
if (id === createdKeyId.value) { remoteApiKey.value = ''; createdSecret.value = ''; createdKeyId.value = '' }
|
||||
if (id === createdKeyId.value) { createdSecret.value = ''; createdKeyId.value = '' }
|
||||
if (String(id) === selectedApiKeyId.value) selectedApiKeyId.value = ''
|
||||
deleteKeyTarget.value = undefined
|
||||
emit('notify', 'API Key 已删除,使用记录已保留')
|
||||
} catch (error) { emit('notify', error instanceof Error ? error.message : '删除 Key 失败') }
|
||||
@@ -543,17 +562,19 @@ async function createProject() {
|
||||
|
||||
<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="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="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-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: !model.groups.length }"><i></i>{{ model.availability }}</span></div><div class="model-title"><h3>{{ model.name }}</h3><span>{{ model.type }}</span></div><small class="provider">{{ model.provider }}<span v-if="model.sourceLabel"> · {{ model.sourceLabel }}</span></small><p>{{ model.description }}</p><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="!model.groups.length" @click.stop="tryModel(model)">{{ model.groups.length ? `在线试用 · ${model.groups.length} 个分组` : '分组待上线' }}<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-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-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: !model.groups.length }"><i></i>{{ model.availability }}</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-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="!model.groups.length" @click.stop="tryModel(model)">{{ model.groups.length ? `在线试用 · ${model.groups.length} 个分组` : '分组待上线' }}<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="模型广场分页" />
|
||||
</template>
|
||||
|
||||
<template v-else-if="view === 'playground'">
|
||||
<section class="page-heading"><div><span>MODEL PLAYGROUND</span><h1>在线调试</h1><p>在正式接入前验证模型效果和返回格式。</p></div><span class="health-badge" :class="{ offline: !catalogConnected }"><i></i>{{ catalogConnected ? 'API 已连接' : 'API 未连接' }}</span></section>
|
||||
<section class="playground-connection" :class="{ ready: remoteApiKey, offline: !catalogConnected }">
|
||||
<span><CheckCircle2 v-if="remoteApiKey" :size="17" /><KeyRound v-else :size="17" /></span>
|
||||
<div><strong>{{ !catalogConnected ? 'Control Plane 未连接' : remoteApiKey ? '真实接口调用已就绪' : '还需要一个临时 API Key' }}</strong><small>{{ !catalogConnected ? '当前不会生成本地模拟调用或伪任务' : remoteApiKey ? 'Key 仅保存在当前页面内存,刷新后自动清除' : '平台不会自动恢复已经关闭页面的明文 Key' }}</small></div>
|
||||
<button v-if="catalogConnected && !remoteApiKey" class="button secondary" @click="emit('navigate', 'keys'); createKeyOpen = true"><Plus :size="15" />创建 Key</button>
|
||||
<section class="playground-connection" :class="{ ready: debugKeyCanInvoke, offline: !catalogConnected }">
|
||||
<span><CheckCircle2 v-if="debugKeyCanInvoke" :size="17" /><KeyRound v-else :size="17" /></span>
|
||||
<div><strong>{{ !catalogConnected ? 'Control Plane 未连接' : debugKeyCanInvoke ? '已选择 API Key,可真实调用' : selectedDebugKey ? '该 Key 未授权当前分组' : '请选择已有 API Key' }}</strong><small>{{ !catalogConnected ? '当前不会生成本地模拟调用或伪任务' : '调用使用所选 Key 的模型权限、限流和计费规则,无需重新创建或粘贴密钥。' }}</small></div>
|
||||
<label class="playground-key-picker"><span>使用 Key</span><select :value="selectedApiKeyId" :disabled="!catalogConnected || !activeDebugKeys.length || running" aria-label="选择调试 API Key" @change="selectDebugApiKey(($event.target as HTMLSelectElement).value)"><option value="" disabled>请选择已启用的 Key</option><option v-for="key in activeDebugKeys" :key="key.id" :value="String(key.id)">{{ key.name }} · {{ key.value }}{{ key.modelIds.includes(activeModel.id) ? '' : '(未授权当前分组)' }}</option></select></label>
|
||||
<button v-if="selectedDebugKey && !debugKeyCanInvoke" class="button secondary" :disabled="running" @click="openModelPermissions(selectedDebugKey)">修改模型权限</button>
|
||||
<button v-if="catalogConnected && !activeDebugKeys.length" class="button secondary" @click="emit('navigate', 'keys'); createKeyOpen = true"><Plus :size="15" />创建 Key</button>
|
||||
</section>
|
||||
<section class="playground-grid">
|
||||
<article class="panel request-panel">
|
||||
@@ -622,7 +643,7 @@ MOYI_MODEL=<model-id></code></pre></div></section><section><b>02</b><div><
|
||||
</template>
|
||||
|
||||
<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.provider }}</small><strong>{{ selectedModel.type }} · {{ selectedModel.mode }}调用</strong></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>
|
||||
<span class="status-chip" :class="selectedModel.groups.length ? '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>
|
||||
|
||||
Reference in new issue
Block a user