Compare commits
1
Commits
v0.5.1
..
78cc2aab56
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78cc2aab56 |
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)(版本段不记日期),版本号遵循语义化版本。
|
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)(版本段不记日期),版本号遵循语义化版本。
|
||||||
|
|
||||||
|
## [0.6.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- AI 网关渠道表格新增「模型数量」列(与模型列表同口径:排除黑名单、随「过滤弃用」开关)
|
||||||
|
- 渠道「模型列表」弹窗(替代原「同步模型」按钮,同步入口迁入弹窗):模型按能力分组展示(对话 / 向量 / 重排 / 语音),支持关键字过滤;每行可「测试」(通过即标记「验证模型」徽章并置渠道可用,后续探测优先使用)与「拉黑」(全局黑名单);弃用模型降灰标注,非对话模型不提供测试;操作按钮悬停行时着色,保持列表安静
|
||||||
|
|
||||||
## [0.5.1]
|
## [0.5.1]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -83,6 +83,15 @@ export function syncAiChannelModels(id: number): Promise<AiModelCacheItem[]> {
|
|||||||
}).then((r) => r.items)
|
}).then((r) => r.items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listAiChannelModels(id: number): Promise<AiModelCacheItem[]> {
|
||||||
|
return request<{ items: AiModelCacheItem[] }>(`/ai-channels/${id}/models`).then((r) => r.items)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单模型 max_tokens=16 试调;通过即设为该渠道探测验证模型并按需置渠道可用 */
|
||||||
|
export function testAiChannelModel(id: number, model: string): Promise<AiChannel> {
|
||||||
|
return request(`/ai-channels/${id}/test-model`, { method: 'POST', body: { model } })
|
||||||
|
}
|
||||||
|
|
||||||
// ---- 聚合模型与调用日志 ----
|
// ---- 聚合模型与调用日志 ----
|
||||||
|
|
||||||
export function listAiModels(): Promise<AiModel[]> {
|
export function listAiModels(): Promise<AiModel[]> {
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { NButton, NInput, NModal, useDialog } from 'naive-ui'
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import {
|
||||||
|
addAiBlacklist,
|
||||||
|
listAiChannelModels,
|
||||||
|
syncAiChannelModels,
|
||||||
|
testAiChannelModel,
|
||||||
|
} from '@/api/aigateway'
|
||||||
|
import { useToast } from '@/composables/useToast'
|
||||||
|
import type { AiChannel, AiModelCacheItem } from '@/types/api'
|
||||||
|
|
||||||
|
const props = defineProps<{ show: boolean; channel: AiChannel | null }>()
|
||||||
|
const emit = defineEmits<{ 'update:show': [boolean]; changed: [] }>()
|
||||||
|
|
||||||
|
const toast = useToast()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
const rows = ref<AiModelCacheItem[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const syncing = ref(false)
|
||||||
|
const testing = ref('')
|
||||||
|
const filter = ref('')
|
||||||
|
/** 本地镜像验证模型:测试通过即时高亮,不等父级刷新 */
|
||||||
|
const probeModel = ref('')
|
||||||
|
|
||||||
|
const CAP_ORDER = ['CHAT', 'EMBEDDING', 'RERANK', 'TTS']
|
||||||
|
const CAP_LABEL: Record<string, string> = { CHAT: '对话', EMBEDDING: '向量', RERANK: '重排', TTS: '语音' }
|
||||||
|
|
||||||
|
/** 按能力分组 + 关键字过滤;仅对话组提供「测试」入口 */
|
||||||
|
const groups = computed(() => {
|
||||||
|
const kw = filter.value.trim().toLowerCase()
|
||||||
|
const buckets = new Map<string, AiModelCacheItem[]>()
|
||||||
|
for (const r of rows.value) {
|
||||||
|
if (kw && !r.name.toLowerCase().includes(kw)) continue
|
||||||
|
const cap = r.capability || 'CHAT'
|
||||||
|
buckets.set(cap, [...(buckets.get(cap) ?? []), r])
|
||||||
|
}
|
||||||
|
const order = [...CAP_ORDER, ...[...buckets.keys()].filter((c) => !CAP_ORDER.includes(c))]
|
||||||
|
return order
|
||||||
|
.filter((cap) => buckets.has(cap))
|
||||||
|
.map((cap) => ({ cap, label: CAP_LABEL[cap] ?? cap, items: buckets.get(cap)! }))
|
||||||
|
})
|
||||||
|
|
||||||
|
const shownCount = computed(() => groups.value.reduce((n, g) => n + g.items.length, 0))
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.show,
|
||||||
|
(show) => {
|
||||||
|
if (show && props.channel) {
|
||||||
|
probeModel.value = props.channel.probeModel
|
||||||
|
filter.value = ''
|
||||||
|
void reload()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
async function reload() {
|
||||||
|
if (!props.channel) return
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
rows.value = await listAiChannelModels(props.channel.id)
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(e instanceof Error ? e.message : '加载失败')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doSync() {
|
||||||
|
if (!props.channel) return
|
||||||
|
syncing.value = true
|
||||||
|
try {
|
||||||
|
rows.value = await syncAiChannelModels(props.channel.id)
|
||||||
|
toast.success(`已同步 ${rows.value.length} 个模型`)
|
||||||
|
emit('changed')
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(e instanceof Error ? e.message : '同步失败')
|
||||||
|
} finally {
|
||||||
|
syncing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doTest(name: string) {
|
||||||
|
if (!props.channel || testing.value) return
|
||||||
|
testing.value = name
|
||||||
|
try {
|
||||||
|
const ch = await testAiChannelModel(props.channel.id, name)
|
||||||
|
probeModel.value = ch.probeModel
|
||||||
|
toast.success('测试通过', '已设为该渠道探测验证模型,后续探测优先使用')
|
||||||
|
emit('changed')
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(e instanceof Error ? e.message : '测试失败')
|
||||||
|
} finally {
|
||||||
|
testing.value = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmBlacklist(name: string) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '拉黑模型',
|
||||||
|
content: `「${name}」将从全部渠道剔除,同步与探测不再入库;可在模型黑名单中移出后重新同步恢复。`,
|
||||||
|
positiveText: '拉黑',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await addAiBlacklist(name)
|
||||||
|
toast.success('已拉黑')
|
||||||
|
void reload()
|
||||||
|
emit('changed')
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(e instanceof Error ? e.message : '拉黑失败')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NModal
|
||||||
|
:show="show"
|
||||||
|
preset="card"
|
||||||
|
:style="{ width: '640px', maxWidth: 'calc(100vw - 24px)' }"
|
||||||
|
@update:show="emit('update:show', $event)"
|
||||||
|
>
|
||||||
|
<template #header>
|
||||||
|
<div>
|
||||||
|
<div class="text-[15px] leading-tight font-semibold">模型列表</div>
|
||||||
|
<div class="mono mt-1 text-xs font-normal text-ink-3">{{ channel?.name ?? '' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2 pb-2">
|
||||||
|
<NInput v-model:value="filter" size="small" placeholder="过滤模型名…" clearable class="min-w-0 flex-1" />
|
||||||
|
<span class="flex-none text-xs whitespace-nowrap text-ink-3">
|
||||||
|
{{ filter ? `${shownCount} / ${rows.length}` : `${rows.length} 个模型` }}
|
||||||
|
</span>
|
||||||
|
<NButton size="small" :loading="syncing" @click="doSync">同步模型</NButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="-mx-2 max-h-[58vh] overflow-y-auto">
|
||||||
|
<div v-if="loading" class="py-10 text-center text-xs text-ink-3">加载中…</div>
|
||||||
|
<template v-else>
|
||||||
|
<template v-for="g in groups" :key="g.cap">
|
||||||
|
<div class="px-3 pt-3 pb-1 text-[11.5px] font-semibold tracking-wide text-ink-3">
|
||||||
|
{{ g.label }} <span class="font-normal">· {{ g.items.length }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="r in g.items"
|
||||||
|
:key="r.name"
|
||||||
|
class="group flex items-center gap-2 rounded-lg px-3 py-[5px] hover:bg-row-hover"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="mono min-w-0 truncate text-[13px]"
|
||||||
|
:class="r.deprecatedAt ? 'text-ink-3' : ''"
|
||||||
|
:title="r.modelOcid"
|
||||||
|
>
|
||||||
|
{{ r.name }}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="r.name === probeModel"
|
||||||
|
class="flex flex-none items-center gap-1 rounded-[5px] bg-info/15 px-1.5 py-px text-[10.5px] font-medium text-info"
|
||||||
|
>
|
||||||
|
<span class="h-[5px] w-[5px] rounded-full bg-info" />验证模型
|
||||||
|
</span>
|
||||||
|
<span v-if="r.deprecatedAt" class="flex-none text-[11px] text-warn">弃用</span>
|
||||||
|
<span class="min-w-0 flex-1" />
|
||||||
|
<button
|
||||||
|
v-if="g.cap === 'CHAT'"
|
||||||
|
type="button"
|
||||||
|
class="flex-none cursor-pointer rounded-[5px] px-1.5 py-0.5 text-xs hover:bg-accent/10"
|
||||||
|
:class="testing === r.name ? 'text-accent' : 'text-ink-3/70 group-hover:text-accent'"
|
||||||
|
:disabled="!!testing"
|
||||||
|
@click="doTest(r.name)"
|
||||||
|
>
|
||||||
|
{{ testing === r.name ? '测试中…' : '测试' }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex-none cursor-pointer rounded-[5px] px-1.5 py-0.5 text-xs text-ink-3/70 group-hover:text-err hover:bg-err/10"
|
||||||
|
@click="confirmBlacklist(r.name)"
|
||||||
|
>
|
||||||
|
拉黑
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div v-if="!shownCount" class="py-10 text-center text-xs text-ink-3">
|
||||||
|
{{ rows.length ? '无匹配模型' : '暂无模型缓存,点击右上「同步模型」拉取' }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-1 border-t border-line-soft pt-2.5 text-[11.5px] leading-relaxed text-ink-3">
|
||||||
|
<span class="font-medium text-ink-2">测试</span>:发 max_tokens=16
|
||||||
|
试调,通过即设为该渠道探测验证模型(后续探测优先使用)并置渠道可用 ·
|
||||||
|
<span class="font-medium text-ink-2">拉黑</span>:全局生效,从全部渠道剔除 ·
|
||||||
|
非对话模型不提供测试
|
||||||
|
</div>
|
||||||
|
</NModal>
|
||||||
|
</template>
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
import { NButton, NDataTable, NInput, NSelect, NTooltip, useDialog, type DataTableColumns } from 'naive-ui'
|
import { NButton, NDataTable, NInput, NSelect, NTooltip, useDialog, type DataTableColumns } from 'naive-ui'
|
||||||
import { computed, h, reactive, ref } from 'vue'
|
import { computed, h, reactive, ref } from 'vue'
|
||||||
|
|
||||||
import { createAiChannel, deleteAiChannel, probeAiChannel, syncAiChannelModels, updateAiChannel } from '@/api/aigateway'
|
import { createAiChannel, deleteAiChannel, probeAiChannel, updateAiChannel } from '@/api/aigateway'
|
||||||
import { listCachedRegions } from '@/api/configs'
|
import { listCachedRegions } from '@/api/configs'
|
||||||
|
import AiChannelModelsModal from '@/components/ai/AiChannelModelsModal.vue'
|
||||||
import GroupChips from '@/components/ai/GroupChips.vue'
|
import GroupChips from '@/components/ai/GroupChips.vue'
|
||||||
import AppInputNumber from '@/components/AppInputNumber.vue'
|
import AppInputNumber from '@/components/AppInputNumber.vue'
|
||||||
import FormField from '@/components/FormField.vue'
|
import FormField from '@/components/FormField.vue'
|
||||||
@@ -109,14 +110,13 @@ async function doProbe(id: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doSync(id: number) {
|
// ---- 模型列表弹窗 ----
|
||||||
try {
|
const showModels = ref(false)
|
||||||
const models = await syncAiChannelModels(id)
|
const modelsChannel = ref<AiChannel | null>(null)
|
||||||
toast.success(`已同步 ${models.length} 个模型`)
|
|
||||||
emit('changed')
|
function openModels(ch: AiChannel) {
|
||||||
} catch (e) {
|
modelsChannel.value = ch
|
||||||
toast.error(e instanceof Error ? e.message : '同步失败')
|
showModels.value = true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggle(ch: AiChannel) {
|
async function toggle(ch: AiChannel) {
|
||||||
@@ -178,12 +178,16 @@ const columns = computed<DataTableColumns<AiChannel>>(() => [
|
|||||||
},
|
},
|
||||||
{ title: '优先级', key: 'priority', width: 76, render: (r) => h('span', { class: 'mono text-[13px]' }, String(r.priority)) },
|
{ title: '优先级', key: 'priority', width: 76, render: (r) => h('span', { class: 'mono text-[13px]' }, String(r.priority)) },
|
||||||
{ title: '权重', key: 'weight', width: 66, render: (r) => h('span', { class: 'mono text-[13px]' }, String(r.weight)) },
|
{ title: '权重', key: 'weight', width: 66, render: (r) => h('span', { class: 'mono text-[13px]' }, String(r.weight)) },
|
||||||
|
{
|
||||||
|
title: '模型数量', key: 'modelCount', width: 86,
|
||||||
|
render: (r) => h('span', { class: r.modelCount ? 'mono text-[13px]' : 'text-xs text-ink-3' }, String(r.modelCount ?? 0)),
|
||||||
|
},
|
||||||
{ title: '探测状态', key: 'probeStatus', width: 120, render: probeCell },
|
{ title: '探测状态', key: 'probeStatus', width: 120, render: probeCell },
|
||||||
{
|
{
|
||||||
title: '操作', key: 'actions', width: 250,
|
title: '操作', key: 'actions', width: 250,
|
||||||
render: (r) => h('div', { class: 'flex items-center gap-0.5' }, [
|
render: (r) => h('div', { class: 'flex items-center gap-0.5' }, [
|
||||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', loading: probing.value.has(r.id), onClick: () => doProbe(r.id) }, { default: () => '探测' }),
|
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', loading: probing.value.has(r.id), onClick: () => doProbe(r.id) }, { default: () => '探测' }),
|
||||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => doSync(r.id) }, { default: () => '同步模型' }),
|
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => openModels(r) }, { default: () => '模型列表' }),
|
||||||
h(NButton, { size: 'tiny', quaternary: true, onClick: () => toggle(r) }, { default: () => (r.enabled ? '停用' : '启用') }),
|
h(NButton, { size: 'tiny', quaternary: true, onClick: () => toggle(r) }, { default: () => (r.enabled ? '停用' : '启用') }),
|
||||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => openEdit(r) }, { default: () => '编辑' }),
|
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => openEdit(r) }, { default: () => '编辑' }),
|
||||||
h(NButton, { size: 'tiny', quaternary: true, type: 'error', onClick: () => confirmRemove(r) }, { default: () => '删除' }),
|
h(NButton, { size: 'tiny', quaternary: true, type: 'error', onClick: () => confirmRemove(r) }, { default: () => '删除' }),
|
||||||
@@ -205,10 +209,16 @@ const columns = computed<DataTableColumns<AiChannel>>(() => [
|
|||||||
</div>
|
</div>
|
||||||
<NDataTable :columns="columns" :data="channels" :loading="loading" :bordered="false" size="small" />
|
<NDataTable :columns="columns" :data="channels" :loading="loading" :bordered="false" size="small" />
|
||||||
<div class="border-t border-line-soft bg-wash px-4.5 py-2.5 text-xs leading-relaxed text-ink-3">
|
<div class="border-t border-line-soft bg-wash px-4.5 py-2.5 text-xs leading-relaxed text-ink-3">
|
||||||
探测三步:列模型(服务可见性)→ 同步模型缓存 → max_tokens=1 试调(配额)· 探测成功自动复位熔断 ·
|
探测三步:列模型(服务可见性)→ 同步模型缓存 → max_tokens=16 试调(配额)· 探测成功自动复位熔断 ·
|
||||||
有渠道时系统自动维护「AI渠道探测」后台任务(每天 00:00 逐渠道探测,渠道清空自动暂停)
|
有渠道时系统自动维护「AI渠道探测」后台任务(每天 00:00 逐渠道探测,渠道清空自动暂停)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<AiChannelModelsModal
|
||||||
|
v-model:show="showModels"
|
||||||
|
:channel="modelsChannel"
|
||||||
|
@changed="emit('changed')"
|
||||||
|
/>
|
||||||
|
|
||||||
<FormModal
|
<FormModal
|
||||||
v-model:show="showForm"
|
v-model:show="showForm"
|
||||||
:title="editing ? '编辑渠道' : '添加渠道'"
|
:title="editing ? '编辑渠道' : '添加渠道'"
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const exact: Record<string, string> = {
|
|||||||
'DELETE /api/v1/ai-channels/:id': '删除网关渠道',
|
'DELETE /api/v1/ai-channels/:id': '删除网关渠道',
|
||||||
'POST /api/v1/ai-channels/:id/probe': '探测网关渠道',
|
'POST /api/v1/ai-channels/:id/probe': '探测网关渠道',
|
||||||
'POST /api/v1/ai-channels/:id/sync-models': '同步渠道模型',
|
'POST /api/v1/ai-channels/:id/sync-models': '同步渠道模型',
|
||||||
|
'POST /api/v1/ai-channels/:id/test-model': '测试渠道模型',
|
||||||
'POST /api/v1/ai-blacklist': '拉黑模型',
|
'POST /api/v1/ai-blacklist': '拉黑模型',
|
||||||
'DELETE /api/v1/ai-blacklist/:id': '移出模型黑名单',
|
'DELETE /api/v1/ai-blacklist/:id': '移出模型黑名单',
|
||||||
'PUT /api/v1/ai-settings': '保存网关设置',
|
'PUT /api/v1/ai-settings': '保存网关设置',
|
||||||
|
|||||||
@@ -946,8 +946,12 @@ export interface AiChannel {
|
|||||||
lastProbeAt: string | null
|
lastProbeAt: string | null
|
||||||
probeStatus: AiProbeStatus
|
probeStatus: AiProbeStatus
|
||||||
probeError: string
|
probeError: string
|
||||||
|
/** 用户测试通过后固定的探测验证模型;探测时置于候选首位 */
|
||||||
|
probeModel: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
|
/** 渠道模型缓存计数(列表查询回填) */
|
||||||
|
modelCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 聚合可用模型(OpenAI /models 形态) */
|
/** 聚合可用模型(OpenAI /models 形态) */
|
||||||
@@ -964,7 +968,10 @@ export interface AiModelCacheItem {
|
|||||||
modelOcid: string
|
modelOcid: string
|
||||||
name: string
|
name: string
|
||||||
vendor: string
|
vendor: string
|
||||||
|
capability: string
|
||||||
syncedAt: string
|
syncedAt: string
|
||||||
|
deprecatedAt: string | null
|
||||||
|
retiredAt: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 模型黑名单条目:拉黑即全渠道剔除,同步 / 探测不再入库 */
|
/** 模型黑名单条目:拉黑即全渠道剔除,同步 / 探测不再入库 */
|
||||||
|
|||||||
Reference in New Issue
Block a user