mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-12 17:21:01 +08:00
feat: 逻辑优化
This commit is contained in:
@@ -26,7 +26,6 @@ const editingConfig = ref<EmbeddingServiceConfigDisplay | null>(null)
|
||||
const isLoading = computed(() => embeddingStore.isLoading)
|
||||
const configs = computed(() => embeddingStore.configs)
|
||||
const activeConfigId = computed(() => embeddingStore.activeConfigId)
|
||||
const enabled = computed(() => embeddingStore.enabled)
|
||||
const hasConfig = computed(() => embeddingStore.hasConfig)
|
||||
const isMaxConfigs = computed(() => embeddingStore.isMaxConfigs)
|
||||
const vectorStoreStats = computed(() => embeddingStore.vectorStoreStats)
|
||||
@@ -51,12 +50,6 @@ async function handleSaved() {
|
||||
emit('config-changed')
|
||||
}
|
||||
|
||||
async function handleToggleEnabled() {
|
||||
const newValue = !enabled.value
|
||||
await embeddingStore.setEnabled(newValue)
|
||||
emit('config-changed')
|
||||
}
|
||||
|
||||
async function handleSetActive(id: string) {
|
||||
await embeddingStore.setActiveConfig(id)
|
||||
emit('config-changed')
|
||||
@@ -90,14 +83,11 @@ onMounted(() => {
|
||||
|
||||
<!-- 配置内容 -->
|
||||
<div v-else class="space-y-6">
|
||||
<!-- 标题和启用开关 -->
|
||||
<div class="flex items-center justify-between">
|
||||
<h4 class="flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white">
|
||||
<UIcon name="i-heroicons-magnifying-glass-circle" class="h-4 w-4 text-emerald-500" />
|
||||
{{ t('settings.embedding.title') }}
|
||||
</h4>
|
||||
<USwitch :model-value="enabled" @update:model-value="handleToggleEnabled" />
|
||||
</div>
|
||||
<!-- 标题 -->
|
||||
<h4 class="flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white">
|
||||
<UIcon name="i-heroicons-magnifying-glass-circle" class="h-4 w-4 text-emerald-500" />
|
||||
{{ t('settings.embedding.title') }}
|
||||
</h4>
|
||||
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('settings.embedding.description') }}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"tabs": {
|
||||
"basic": "General",
|
||||
"ai": "AI Settings",
|
||||
"aiConfig": "AI Models",
|
||||
"aiRAG": "Semantic Search",
|
||||
"aiConfig": "Chat Model",
|
||||
"aiRAG": "Vector Model",
|
||||
"aiPrompt": "Chat Config",
|
||||
"aiPreset": "Prompts",
|
||||
"storage": "Data & Storage",
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
},
|
||||
"aiConfig": {
|
||||
"title": "Model Configuration",
|
||||
"title": "Chat Model",
|
||||
"loading": "Loading...",
|
||||
"inUse": "Active",
|
||||
"defaultModel": "Default Model",
|
||||
@@ -211,8 +211,8 @@
|
||||
}
|
||||
},
|
||||
"embedding": {
|
||||
"title": "Semantic Search",
|
||||
"description": "Uses embedding vectors to understand question meaning, suitable for analyzing relationships, emotions, and abstract topics",
|
||||
"title": "Vector Model",
|
||||
"description": "Uses embedding vectors to understand question meaning, enables AI to perform semantic search",
|
||||
"configList": "Embedding Configs",
|
||||
"addConfig": "Add Config",
|
||||
"editConfig": "Edit Config",
|
||||
@@ -223,8 +223,8 @@
|
||||
"configName": "Config Name",
|
||||
"configNamePlaceholder": "e.g. Ollama Embedding",
|
||||
"apiSource": "API Source",
|
||||
"apiSourceHint": "\"Reuse AI Config\" will use the endpoint and key from the active AI model config",
|
||||
"reuseLLM": "Reuse AI Config",
|
||||
"apiSourceHint": "\"Reuse Chat Model\" will use the endpoint and key from the active chat model",
|
||||
"reuseLLM": "Reuse Chat Model",
|
||||
"customAPI": "Custom API",
|
||||
"model": "Model Name",
|
||||
"modelPlaceholder": "e.g. nomic-embed-text",
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"tabs": {
|
||||
"basic": "基础设置",
|
||||
"ai": "AI 设置",
|
||||
"aiConfig": "模型配置",
|
||||
"aiRAG": "语义搜索",
|
||||
"aiConfig": "对话模型",
|
||||
"aiRAG": "向量模型",
|
||||
"aiPrompt": "对话配置",
|
||||
"aiPreset": "提示词配置",
|
||||
"storage": "数据和存储",
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
},
|
||||
"aiConfig": {
|
||||
"title": "模型配置",
|
||||
"title": "对话模型",
|
||||
"loading": "加载中...",
|
||||
"inUse": "使用中",
|
||||
"defaultModel": "默认模型",
|
||||
@@ -211,8 +211,8 @@
|
||||
}
|
||||
},
|
||||
"embedding": {
|
||||
"title": "语义搜索",
|
||||
"description": "通过 Embedding 向量相似度理解问题含义,适合分析关系、情感、抽象话题等场景",
|
||||
"title": "向量模型",
|
||||
"description": "通过 Embedding 向量相似度理解问题含义,启用后 AI 可进行语义搜索",
|
||||
"configList": "Embedding 配置",
|
||||
"addConfig": "添加配置",
|
||||
"editConfig": "编辑配置",
|
||||
@@ -223,8 +223,8 @@
|
||||
"configName": "配置名称",
|
||||
"configNamePlaceholder": "如:Ollama Embedding",
|
||||
"apiSource": "API 来源",
|
||||
"apiSourceHint": "「复用 AI 配置」将使用当前激活的 AI 模型配置的端点和密钥",
|
||||
"reuseLLM": "复用 AI 配置",
|
||||
"apiSourceHint": "「复用对话模型」将使用当前激活的对话模型的端点和密钥",
|
||||
"reuseLLM": "复用对话模型",
|
||||
"customAPI": "自定义 API",
|
||||
"model": "模型名称",
|
||||
"modelPlaceholder": "如 nomic-embed-text",
|
||||
|
||||
@@ -15,9 +15,6 @@ export const useEmbeddingStore = defineStore('embedding', () => {
|
||||
/** 当前激活配置 ID */
|
||||
const activeConfigId = ref<string | null>(null)
|
||||
|
||||
/** 是否启用语义搜索 */
|
||||
const enabled = ref(false)
|
||||
|
||||
/** 是否正在加载 */
|
||||
const isLoading = ref(false)
|
||||
|
||||
@@ -77,7 +74,6 @@ export const useEmbeddingStore = defineStore('embedding', () => {
|
||||
])
|
||||
configs.value = configsData
|
||||
activeConfigId.value = activeId
|
||||
enabled.value = isEnabled
|
||||
vectorStoreStats.value = stats
|
||||
} catch (error) {
|
||||
console.error('[Embedding Store] 加载配置失败:', error)
|
||||
@@ -86,23 +82,6 @@ export const useEmbeddingStore = defineStore('embedding', () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置语义搜索启用状态
|
||||
*/
|
||||
async function setEnabled(value: boolean): Promise<boolean> {
|
||||
try {
|
||||
const result = await window.embeddingApi.setEnabled(value)
|
||||
if (result.success) {
|
||||
enabled.value = value
|
||||
return true
|
||||
}
|
||||
console.error('[Embedding Store] 设置启用状态失败:', result.error)
|
||||
return false
|
||||
} catch (error) {
|
||||
console.error('[Embedding Store] 设置启用状态失败:', error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换激活配置
|
||||
@@ -170,7 +149,6 @@ export const useEmbeddingStore = defineStore('embedding', () => {
|
||||
// 状态
|
||||
configs,
|
||||
activeConfigId,
|
||||
enabled,
|
||||
isLoading,
|
||||
isInitialized,
|
||||
vectorStoreStats,
|
||||
@@ -182,7 +160,6 @@ export const useEmbeddingStore = defineStore('embedding', () => {
|
||||
// 方法
|
||||
init,
|
||||
loadConfigs,
|
||||
setEnabled,
|
||||
setActiveConfig,
|
||||
deleteConfig,
|
||||
clearVectorStore,
|
||||
|
||||
Reference in New Issue
Block a user