2026-01-15 06:01:34 +08:00
|
|
|
|
import { Database, Waypoints, DatabaseZap } from 'lucide-vue-next'
|
2026-01-15 02:38:02 +08:00
|
|
|
|
|
2025-08-05 18:00:45 +08:00
|
|
|
|
export const getKbTypeLabel = (type) => {
|
|
|
|
|
|
const labels = {
|
|
|
|
|
|
lightrag: 'LightRAG',
|
2026-02-24 12:12:02 +08:00
|
|
|
|
milvus: 'CommonRAG',
|
|
|
|
|
|
dify: 'Dify'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
return labels[type] || type
|
|
|
|
|
|
}
|
2025-08-05 18:00:45 +08:00
|
|
|
|
|
2026-01-15 02:38:02 +08:00
|
|
|
|
export const getKbTypeIcon = (type) => {
|
|
|
|
|
|
const icons = {
|
|
|
|
|
|
lightrag: Waypoints,
|
2026-02-24 12:12:02 +08:00
|
|
|
|
milvus: DatabaseZap,
|
|
|
|
|
|
dify: Database
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
return icons[type] || Database
|
|
|
|
|
|
}
|
2026-01-15 02:38:02 +08:00
|
|
|
|
|
2025-08-05 18:00:45 +08:00
|
|
|
|
export const getKbTypeColor = (type) => {
|
|
|
|
|
|
const colors = {
|
|
|
|
|
|
lightrag: 'purple',
|
2026-02-24 12:12:02 +08:00
|
|
|
|
milvus: 'red',
|
|
|
|
|
|
dify: 'gold'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
return colors[type] || 'blue'
|
|
|
|
|
|
}
|
2026-05-02 01:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
// 解析模型 spec 为 { model_spec, provider, model_name }
|
|
|
|
|
|
// V2 格式: provider_id:model_id(冒号分隔)
|
|
|
|
|
|
// V1 格式: provider/model_name(斜杠分隔)
|
|
|
|
|
|
export const parseModelSpec = (spec) => {
|
|
|
|
|
|
if (typeof spec !== 'string' || !spec) return null
|
|
|
|
|
|
const sep = spec.includes(':') ? ':' : '/'
|
|
|
|
|
|
const index = spec.indexOf(sep)
|
|
|
|
|
|
return {
|
|
|
|
|
|
model_spec: spec,
|
|
|
|
|
|
provider: index !== -1 ? spec.slice(0, index) : '',
|
|
|
|
|
|
model_name: index !== -1 ? spec.slice(index + 1) : ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 从 llm_info 构造显示用的 spec 字符串
|
|
|
|
|
|
export const buildDisplaySpec = (llmInfo) => {
|
|
|
|
|
|
if (llmInfo?.model_spec) return llmInfo.model_spec
|
|
|
|
|
|
const provider = llmInfo?.provider || ''
|
|
|
|
|
|
const modelName = llmInfo?.model_name || ''
|
|
|
|
|
|
return provider && modelName ? `${provider}/${modelName}` : ''
|
|
|
|
|
|
}
|