feat: add VectorStore management UI settings page
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { get, post, put, del } from '@/utils/request'
|
||||
|
||||
// ===== Types =====
|
||||
|
||||
export interface VectorStoreEntity {
|
||||
id?: string
|
||||
name: string
|
||||
engine_type: string
|
||||
connection_config: Record<string, any>
|
||||
index_config: Record<string, any>
|
||||
source: 'env' | 'user'
|
||||
readonly: boolean
|
||||
tenant_id?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
export interface VectorStoreTypeInfo {
|
||||
type: string
|
||||
display_name: string
|
||||
connection_fields: FieldSchema[]
|
||||
index_fields: FieldSchema[]
|
||||
}
|
||||
|
||||
export interface FieldSchema {
|
||||
name: string
|
||||
type: 'string' | 'number' | 'boolean'
|
||||
required: boolean
|
||||
sensitive?: boolean
|
||||
description?: string
|
||||
default?: any
|
||||
}
|
||||
|
||||
// ===== API Functions =====
|
||||
|
||||
export function listVectorStoreTypes(): Promise<VectorStoreTypeInfo[]> {
|
||||
return get('/api/v1/vector-stores/types').then((res: any) => {
|
||||
return res.success && res.data ? res.data : []
|
||||
})
|
||||
}
|
||||
|
||||
export function listVectorStores(): Promise<{ success: boolean; data: VectorStoreEntity[] }> {
|
||||
return get('/api/v1/vector-stores')
|
||||
}
|
||||
|
||||
export function createVectorStore(data: Partial<VectorStoreEntity>) {
|
||||
return post('/api/v1/vector-stores', data)
|
||||
}
|
||||
|
||||
export function updateVectorStore(id: string, data: Partial<VectorStoreEntity>) {
|
||||
return put(`/api/v1/vector-stores/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteVectorStore(id: string) {
|
||||
return del(`/api/v1/vector-stores/${id}`)
|
||||
}
|
||||
|
||||
export function testVectorStoreRaw(data: { engine_type: string; connection_config: any }): Promise<any> {
|
||||
return post('/api/v1/vector-stores/test', data)
|
||||
}
|
||||
|
||||
export function testVectorStoreById(id: string): Promise<any> {
|
||||
return post(`/api/v1/vector-stores/${id}/test`, {})
|
||||
}
|
||||
@@ -573,6 +573,7 @@ export default {
|
||||
autoCheckUpdateDesc: 'When enabled, automatically check and download the latest version in the background.',
|
||||
memoryRequiresNeo4j: 'Memory feature requires Neo4j graph database. Please configure and enable Neo4j (set NEO4J_ENABLE=true) before enabling this feature.',
|
||||
memoryHowToEnable: 'View Neo4j Configuration Guide',
|
||||
vectorStoreEngine: 'Vector DB Engine',
|
||||
parserEngine: 'Parser Engine',
|
||||
storageEngine: 'Storage Engine',
|
||||
mcpService: 'MCP Service',
|
||||
@@ -807,6 +808,61 @@ export default {
|
||||
testFailed: 'Connection test failed',
|
||||
}
|
||||
},
|
||||
vectorStoreSettings: {
|
||||
title: 'Vector Database Engine',
|
||||
description: 'Register and manage vector database instances for knowledge base search.',
|
||||
storesTitle: 'Vector Databases',
|
||||
addStore: 'Add Database',
|
||||
editStore: 'Edit Database',
|
||||
deleteConfirm: 'Are you sure you want to delete this vector database?',
|
||||
emptyDesc: 'No vector databases configured. Click "Add Database" to get started.',
|
||||
engineTypeLabel: 'Engine Type',
|
||||
nameLabel: 'Name',
|
||||
namePlaceholder: 'e.g., my-vector-store',
|
||||
connectionInfo: 'Connection Info',
|
||||
advancedIndexConfig: 'Advanced Settings',
|
||||
fields: {
|
||||
addr: 'URL',
|
||||
host: 'Host',
|
||||
port: 'Port',
|
||||
username: 'Username',
|
||||
password: 'Password',
|
||||
api_key: 'API Key',
|
||||
use_tls: 'Use TLS',
|
||||
scheme: 'Scheme',
|
||||
grpc_address: 'gRPC Address',
|
||||
use_default_connection: 'Use Default Connection',
|
||||
index_name: 'Index Name',
|
||||
number_of_shards: 'Shards',
|
||||
number_of_replicas: 'Replicas',
|
||||
collection_prefix: 'Collection Prefix',
|
||||
collection_name: 'Collection Name',
|
||||
shard_number: 'Shard Number',
|
||||
replication_factor: 'Replication Factor',
|
||||
shards_num: 'Shards',
|
||||
replica_number: 'In-memory Replicas',
|
||||
desired_shard_count: 'Shard Count',
|
||||
},
|
||||
envTag: 'DEFAULT',
|
||||
testConnection: 'Test Connection',
|
||||
testing: 'Testing...',
|
||||
immutableNotice: 'Engine type, connection, and index settings cannot be changed after creation.\nTo change these, delete and recreate.',
|
||||
validation: {
|
||||
nameRequired: 'Name is required',
|
||||
engineTypeRequired: 'Engine type is required',
|
||||
fieldRequired: '{field} is required',
|
||||
indexNamePattern: 'Must start with a letter. Only letters, numbers, underscore, and hyphen allowed (max 128)',
|
||||
},
|
||||
toasts: {
|
||||
storeCreated: 'Vector database created',
|
||||
storeUpdated: 'Vector database updated',
|
||||
storeDeleted: 'Vector database deleted',
|
||||
testSuccess: 'Connection test succeeded',
|
||||
testFailed: 'Connection test failed',
|
||||
duplicateName: 'A vector database with this name already exists',
|
||||
errorGeneric: 'An error occurred. Please try again.',
|
||||
},
|
||||
},
|
||||
chatHistorySettings: {
|
||||
title: 'Message Management',
|
||||
description: 'Configure chat history knowledge base to automatically index conversation messages for semantic search',
|
||||
|
||||
@@ -435,6 +435,7 @@ export default {
|
||||
autoCheckUpdateDesc: '활성화하면 시작 시 최신 버전을 자동으로 확인하고 백그라운드에서 다운로드합니다.',
|
||||
memoryRequiresNeo4j: "기억 기능은 Neo4j 그래프 데이터베이스가 필요합니다. 이 기능을 활성화하기 전에 Neo4j를 구성하고 활성화해 주세요 (NEO4J_ENABLE=true 설정).",
|
||||
memoryHowToEnable: "Neo4j 구성 가이드 보기",
|
||||
vectorStoreEngine: "벡터 DB 엔진",
|
||||
parserEngine: "파싱 엔진",
|
||||
storageEngine: "스토리지 엔진",
|
||||
mcpService: "MCP 서비스",
|
||||
@@ -666,6 +667,61 @@ export default {
|
||||
providerDeleted: "검색 엔진 프로바이더가 삭제되었습니다",
|
||||
},
|
||||
},
|
||||
vectorStoreSettings: {
|
||||
title: "벡터 데이터베이스 엔진",
|
||||
description: "지식 베이스 검색을 위한 벡터 데이터베이스 인스턴스를 등록하고 관리합니다.",
|
||||
storesTitle: "벡터 데이터베이스",
|
||||
addStore: "데이터베이스 추가",
|
||||
editStore: "데이터베이스 수정",
|
||||
deleteConfirm: "이 벡터 데이터베이스를 삭제하시겠습니까?",
|
||||
emptyDesc: "구성된 벡터 데이터베이스가 없습니다. '데이터베이스 추가'를 클릭하여 시작하세요.",
|
||||
engineTypeLabel: "엔진 타입",
|
||||
nameLabel: "이름",
|
||||
namePlaceholder: "예: my-vector-store",
|
||||
connectionInfo: "연결 정보",
|
||||
advancedIndexConfig: "고급 설정",
|
||||
fields: {
|
||||
addr: "URL",
|
||||
host: "호스트",
|
||||
port: "포트",
|
||||
username: "사용자명",
|
||||
password: "비밀번호",
|
||||
api_key: "API 키",
|
||||
use_tls: "TLS 사용",
|
||||
scheme: "프로토콜",
|
||||
grpc_address: "gRPC 주소",
|
||||
use_default_connection: "기본 연결 사용",
|
||||
index_name: "인덱스 이름",
|
||||
number_of_shards: "샤드 수",
|
||||
number_of_replicas: "레플리카 수",
|
||||
collection_prefix: "컬렉션 접두사",
|
||||
collection_name: "컬렉션 이름",
|
||||
shard_number: "샤드 수",
|
||||
replication_factor: "레플리카 팩터",
|
||||
shards_num: "샤드 수",
|
||||
replica_number: "인메모리 레플리카",
|
||||
desired_shard_count: "샤드 수",
|
||||
},
|
||||
envTag: "DEFAULT",
|
||||
testConnection: "연결 테스트",
|
||||
testing: "테스트 중...",
|
||||
immutableNotice: "엔진 타입, 연결 정보, 인덱스 설정은 생성 후 변경할 수 없습니다.\n변경이 필요하면 삭제 후 다시 생성하세요.",
|
||||
validation: {
|
||||
nameRequired: "이름은 필수입니다",
|
||||
engineTypeRequired: "엔진 타입은 필수입니다",
|
||||
fieldRequired: "{field}은(는) 필수입니다",
|
||||
indexNamePattern: "영문자로 시작해야 합니다. 영문, 숫자, 밑줄, 하이픈만 허용 (최대 128자)",
|
||||
},
|
||||
toasts: {
|
||||
storeCreated: "벡터 데이터베이스가 생성되었습니다",
|
||||
storeUpdated: "벡터 데이터베이스가 수정되었습니다",
|
||||
storeDeleted: "벡터 데이터베이스가 삭제되었습니다",
|
||||
testSuccess: "연결 테스트 성공",
|
||||
testFailed: "연결 테스트 실패",
|
||||
duplicateName: "동일한 이름의 벡터 데이터베이스가 이미 존재합니다",
|
||||
errorGeneric: "오류가 발생했습니다. 다시 시도해 주세요.",
|
||||
},
|
||||
},
|
||||
chatHistorySettings: {
|
||||
title: "메시지 관리",
|
||||
description: "채팅 기록 지식베이스를 구성하여 대화 메시지를 자동으로 벡터화 인덱싱하여 시맨틱 검색을 지원합니다",
|
||||
|
||||
@@ -552,6 +552,7 @@ export default {
|
||||
autoCheckUpdateDesc: 'При включении автоматически проверять и скачивать последнюю версию в фоновом режиме при запуске.',
|
||||
memoryRequiresNeo4j: 'Функция памяти требует графовую базу данных Neo4j. Пожалуйста, настройте и включите Neo4j (установите NEO4J_ENABLE=true) перед активацией этой функции.',
|
||||
memoryHowToEnable: 'Руководство по настройке Neo4j',
|
||||
vectorStoreEngine: 'Движок векторной БД',
|
||||
parserEngine: 'Движок парсинга',
|
||||
storageEngine: 'Движок хранения',
|
||||
mcpService: 'Сервис MCP',
|
||||
@@ -785,6 +786,61 @@ export default {
|
||||
providerDeleted: 'Поисковый провайдер удалён',
|
||||
}
|
||||
},
|
||||
vectorStoreSettings: {
|
||||
title: 'Движок векторной базы данных',
|
||||
description: 'Регистрация и управление экземплярами векторных баз данных для поиска по базе знаний.',
|
||||
storesTitle: 'Векторные базы данных',
|
||||
addStore: 'Добавить базу данных',
|
||||
editStore: 'Редактировать базу данных',
|
||||
deleteConfirm: 'Вы уверены, что хотите удалить эту векторную базу данных?',
|
||||
emptyDesc: 'Векторные базы данных не настроены. Нажмите "Добавить базу данных", чтобы начать.',
|
||||
engineTypeLabel: 'Тип движка',
|
||||
nameLabel: 'Название',
|
||||
namePlaceholder: 'например, my-vector-store',
|
||||
connectionInfo: 'Информация о подключении',
|
||||
advancedIndexConfig: 'Расширенные настройки',
|
||||
fields: {
|
||||
addr: 'URL',
|
||||
host: 'Хост',
|
||||
port: 'Порт',
|
||||
username: 'Имя пользователя',
|
||||
password: 'Пароль',
|
||||
api_key: 'API ключ',
|
||||
use_tls: 'Использовать TLS',
|
||||
scheme: 'Схема',
|
||||
grpc_address: 'gRPC адрес',
|
||||
use_default_connection: 'Использовать подключение по умолчанию',
|
||||
index_name: 'Имя индекса',
|
||||
number_of_shards: 'Шарды',
|
||||
number_of_replicas: 'Реплики',
|
||||
collection_prefix: 'Префикс коллекции',
|
||||
collection_name: 'Имя коллекции',
|
||||
shard_number: 'Количество шардов',
|
||||
replication_factor: 'Фактор репликации',
|
||||
shards_num: 'Шарды',
|
||||
replica_number: 'Реплики в памяти',
|
||||
desired_shard_count: 'Количество шардов',
|
||||
},
|
||||
envTag: 'DEFAULT',
|
||||
testConnection: 'Тест подключения',
|
||||
testing: 'Тестирование...',
|
||||
immutableNotice: 'Тип движка, подключение и настройки индекса нельзя изменить после создания.\nДля изменения удалите и создайте заново.',
|
||||
validation: {
|
||||
nameRequired: 'Название обязательно',
|
||||
engineTypeRequired: 'Тип движка обязателен',
|
||||
fieldRequired: '{field} обязательно',
|
||||
indexNamePattern: 'Должно начинаться с буквы. Допускаются только буквы, цифры, подчёркивание и дефис (макс. 128)',
|
||||
},
|
||||
toasts: {
|
||||
storeCreated: 'Векторная база данных создана',
|
||||
storeUpdated: 'Векторная база данных обновлена',
|
||||
storeDeleted: 'Векторная база данных удалена',
|
||||
testSuccess: 'Тест подключения успешен',
|
||||
testFailed: 'Тест подключения не удался',
|
||||
duplicateName: 'Векторная база данных с таким именем уже существует',
|
||||
errorGeneric: 'Произошла ошибка. Попробуйте снова.',
|
||||
},
|
||||
},
|
||||
chatHistorySettings: {
|
||||
title: 'Управление сообщениями',
|
||||
description: 'Настройте базу знаний истории чата для автоматической индексации сообщений и семантического поиска',
|
||||
|
||||
@@ -432,6 +432,7 @@ export default {
|
||||
autoCheckUpdateDesc: '开启后自动检查并在后台下载最新版本安装包。',
|
||||
memoryRequiresNeo4j: "记忆功能依赖 Neo4j 图数据库,请先配置并启用 Neo4j(设置环境变量 NEO4J_ENABLE=true)后再开启此功能。",
|
||||
memoryHowToEnable: "查看 Neo4j 配置指南",
|
||||
vectorStoreEngine: "向量数据库引擎",
|
||||
parserEngine: "解析引擎",
|
||||
storageEngine: "存储引擎",
|
||||
mcpService: "MCP服务",
|
||||
@@ -668,6 +669,61 @@ export default {
|
||||
testFailed: "连接测试失败",
|
||||
},
|
||||
},
|
||||
vectorStoreSettings: {
|
||||
title: "向量数据库引擎",
|
||||
description: "注册和管理用于知识库搜索的向量数据库实例。",
|
||||
storesTitle: "向量数据库",
|
||||
addStore: "添加数据库",
|
||||
editStore: "编辑数据库",
|
||||
deleteConfirm: "确定要删除此向量数据库吗?",
|
||||
emptyDesc: '尚未配置向量数据库。点击"添加数据库"开始设置。',
|
||||
engineTypeLabel: "引擎类型",
|
||||
nameLabel: "名称",
|
||||
namePlaceholder: "例如:my-vector-store",
|
||||
connectionInfo: "连接信息",
|
||||
advancedIndexConfig: "高级设置",
|
||||
fields: {
|
||||
addr: "URL",
|
||||
host: "主机",
|
||||
port: "端口",
|
||||
username: "用户名",
|
||||
password: "密码",
|
||||
api_key: "API 密钥",
|
||||
use_tls: "使用 TLS",
|
||||
scheme: "协议",
|
||||
grpc_address: "gRPC 地址",
|
||||
use_default_connection: "使用默认连接",
|
||||
index_name: "索引名称",
|
||||
number_of_shards: "分片数",
|
||||
number_of_replicas: "副本数",
|
||||
collection_prefix: "集合前缀",
|
||||
collection_name: "集合名称",
|
||||
shard_number: "分片数",
|
||||
replication_factor: "副本因子",
|
||||
shards_num: "分片数",
|
||||
replica_number: "内存副本数",
|
||||
desired_shard_count: "分片数",
|
||||
},
|
||||
envTag: "DEFAULT",
|
||||
testConnection: "测试连接",
|
||||
testing: "测试中...",
|
||||
immutableNotice: "创建后无法更改引擎类型、连接和索引设置。\n如需更改,请删除后重新创建。",
|
||||
validation: {
|
||||
nameRequired: "名称为必填项",
|
||||
engineTypeRequired: "引擎类型为必填项",
|
||||
fieldRequired: "{field}为必填项",
|
||||
indexNamePattern: "必须以字母开头,仅允许字母、数字、下划线和连字符(最多128个字符)",
|
||||
},
|
||||
toasts: {
|
||||
storeCreated: "向量数据库已创建",
|
||||
storeUpdated: "向量数据库已更新",
|
||||
storeDeleted: "向量数据库已删除",
|
||||
testSuccess: "连接测试成功",
|
||||
testFailed: "连接测试失败",
|
||||
duplicateName: "同名向量数据库已存在",
|
||||
errorGeneric: "发生错误,请重试。",
|
||||
},
|
||||
},
|
||||
chatHistorySettings: {
|
||||
title: "消息管理",
|
||||
description: "配置聊天历史知识库,将对话消息自动向量化索引,实现语义搜索",
|
||||
|
||||
@@ -117,6 +117,11 @@
|
||||
<ChatHistorySettings />
|
||||
</div>
|
||||
|
||||
<!-- 向量数据库引擎 -->
|
||||
<div v-if="currentSection === 'vectorstore'" class="section">
|
||||
<VectorStoreSettings />
|
||||
</div>
|
||||
|
||||
<!-- 解析引擎 -->
|
||||
<div v-if="currentSection === 'parser'" class="section">
|
||||
<ParserEngineSettings />
|
||||
@@ -169,6 +174,7 @@ import OllamaSettings from './OllamaSettings.vue'
|
||||
import McpSettings from './McpSettings.vue'
|
||||
import WebSearchSettings from './WebSearchSettings.vue'
|
||||
import ChatHistorySettings from './ChatHistorySettings.vue'
|
||||
import VectorStoreSettings from './VectorStoreSettings.vue'
|
||||
import ParserEngineSettings from './ParserEngineSettings.vue'
|
||||
import StorageEngineSettings from './StorageEngineSettings.vue'
|
||||
import WeKnoraCloudSettings from './WeKnoraCloudSettings.vue'
|
||||
@@ -189,6 +195,7 @@ const navItems = computed(() => [
|
||||
{ key: 'models', icon: 'control-platform', label: t('settings.modelManagement') },
|
||||
{ key: 'websearch', icon: 'search', label: t('settings.webSearchConfig') },
|
||||
{ key: 'chathistory', icon: 'chat', label: t('chatHistorySettings.title') },
|
||||
{ key: 'vectorstore', icon: 'data-base', label: t('settings.vectorStoreEngine') },
|
||||
{ key: 'parser', icon: 'file-search', label: t('settings.parserEngine') },
|
||||
{ key: 'storage', icon: 'cloud', label: t('settings.storageEngine') },
|
||||
{ key: 'mcp', icon: 'tools', label: t('settings.mcpService') },
|
||||
|
||||
@@ -0,0 +1,812 @@
|
||||
<template>
|
||||
<div class="vectorstore-settings">
|
||||
<div class="section-header">
|
||||
<h2>{{ t('vectorStoreSettings.title') }}</h2>
|
||||
<p class="section-description">{{ t('vectorStoreSettings.description') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Loading -->
|
||||
<div v-if="loading" class="loading-container">
|
||||
<t-loading size="small" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="settings-group">
|
||||
<div class="section-subheader">
|
||||
<h3>{{ t('vectorStoreSettings.storesTitle') }}</h3>
|
||||
<t-button theme="primary" size="small" @click="openAddDialog">
|
||||
<template #icon><add-icon /></template>
|
||||
{{ t('vectorStoreSettings.addStore') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- Store List -->
|
||||
<div v-if="stores.length > 0" class="store-list">
|
||||
<!-- Env Stores -->
|
||||
<div v-for="store in envStores" :key="store.id" class="store-item store-item--env">
|
||||
<div class="item-row">
|
||||
<div class="item-info">
|
||||
<div class="item-header">
|
||||
<t-icon name="lock-on" size="14px" />
|
||||
<span class="item-name">{{ store.name }}</span>
|
||||
<t-tag theme="warning" size="small" variant="light">{{ t('vectorStoreSettings.envTag') }}</t-tag>
|
||||
<t-tag size="small" variant="outline">{{ store.engine_type }}</t-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-actions">
|
||||
<t-button
|
||||
theme="default" variant="outline" size="small"
|
||||
:loading="testingId === store.id"
|
||||
@click="testExisting(store)"
|
||||
>
|
||||
{{ t('vectorStoreSettings.testConnection') }}
|
||||
</t-button>
|
||||
<t-button theme="default" variant="text" size="small" shape="square" style="visibility: hidden;">
|
||||
<template #icon><t-icon name="more" /></template>
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="getTestResult(store)" :class="['test-result-bar', getTestResult(store)!.success ? 'success' : 'error']">
|
||||
<span class="test-result-message">{{ getTestResult(store)!.message }}</span>
|
||||
<t-icon name="close" size="14px" class="test-result-close" @click="clearTestResult(store)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- User Stores -->
|
||||
<div v-for="store in userStores" :key="store.id" class="store-item">
|
||||
<div class="item-row">
|
||||
<div class="item-info">
|
||||
<div class="item-header">
|
||||
<span class="item-name">{{ store.name }}</span>
|
||||
<t-tag size="small" variant="outline">{{ store.engine_type }}</t-tag>
|
||||
</div>
|
||||
<div class="item-desc">{{ getStoreEndpoint(store) }}</div>
|
||||
</div>
|
||||
<div class="item-actions">
|
||||
<t-button
|
||||
theme="default" variant="outline" size="small"
|
||||
:loading="testingId === store.id"
|
||||
@click="testExisting(store)"
|
||||
>
|
||||
{{ t('vectorStoreSettings.testConnection') }}
|
||||
</t-button>
|
||||
<t-dropdown :options="storeActions" trigger="click" @click="(action: any) => handleAction(action, store)">
|
||||
<t-button theme="default" variant="text" size="small" shape="square">
|
||||
<template #icon><t-icon name="more" /></template>
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="getTestResult(store)" :class="['test-result-bar', getTestResult(store)!.success ? 'success' : 'error']">
|
||||
<span class="test-result-message">{{ getTestResult(store)!.message }}</span>
|
||||
<t-icon name="close" size="14px" class="test-result-close" @click="clearTestResult(store)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-else class="empty-stores">
|
||||
<p>{{ t('vectorStoreSettings.emptyDesc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Add/Edit Dialog -->
|
||||
<t-dialog
|
||||
v-model:visible="showDialog"
|
||||
:header="editingStore ? t('vectorStoreSettings.editStore') : t('vectorStoreSettings.addStore')"
|
||||
width="580px"
|
||||
placement="center"
|
||||
:footer="false"
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dialog-form-container">
|
||||
<!-- Edit Mode: immutable info banner + readonly fields -->
|
||||
<template v-if="editingStore">
|
||||
<div class="immutable-notice">
|
||||
<t-icon name="info-circle" size="14px" />
|
||||
<span>{{ t('vectorStoreSettings.immutableNotice') }}</span>
|
||||
</div>
|
||||
<div class="readonly-fields">
|
||||
<div class="readonly-row">
|
||||
<span class="readonly-label">{{ t('vectorStoreSettings.engineTypeLabel') }}</span>
|
||||
<span class="readonly-value">{{ selectedType?.display_name || editingStore.engine_type }}</span>
|
||||
</div>
|
||||
<template v-if="selectedType">
|
||||
<template v-for="field in selectedType.connection_fields" :key="field.name">
|
||||
<div v-if="field.sensitive || form.connection_config[field.name]" class="readonly-row">
|
||||
<span class="readonly-label">{{ fieldLabel(field.name) }}</span>
|
||||
<span class="readonly-value">{{ field.sensitive ? '********' : form.connection_config[field.name] }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="selectedType?.index_fields?.length">
|
||||
<template v-for="field in selectedType.index_fields" :key="field.name">
|
||||
<div v-if="form.index_config[field.name]" class="readonly-row">
|
||||
<span class="readonly-label">{{ fieldLabel(field.name) }}</span>
|
||||
<span class="readonly-value">{{ form.index_config[field.name] }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
<div class="form-divider"></div>
|
||||
</template>
|
||||
|
||||
<t-form :data="form" :rules="formRules" label-align="top" @submit="saveStore" class="store-form">
|
||||
<div class="form-scroll-area">
|
||||
<!-- Create Mode: engine type + connection fields -->
|
||||
<template v-if="!editingStore">
|
||||
<t-form-item :label="t('vectorStoreSettings.engineTypeLabel')" name="engine_type">
|
||||
<t-select v-model="form.engine_type" @change="onEngineTypeChange">
|
||||
<t-option
|
||||
v-for="st in storeTypes"
|
||||
:key="st.type"
|
||||
:value="st.type"
|
||||
:label="st.display_name"
|
||||
/>
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
</template>
|
||||
|
||||
<!-- Name (always editable) -->
|
||||
<t-form-item :label="t('vectorStoreSettings.nameLabel')" name="name">
|
||||
<t-input v-model="form.name" :placeholder="t('vectorStoreSettings.namePlaceholder')" />
|
||||
</t-form-item>
|
||||
|
||||
<!-- Create Mode: connection fields -->
|
||||
<template v-if="!editingStore && selectedType">
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-section-label">{{ t('vectorStoreSettings.connectionInfo') }}</div>
|
||||
|
||||
<template v-for="field in selectedType.connection_fields" :key="field.name">
|
||||
<t-form-item
|
||||
:label="fieldLabel(field.name)"
|
||||
:name="`connection_config.${field.name}`"
|
||||
>
|
||||
<t-switch
|
||||
v-if="field.type === 'boolean'"
|
||||
v-model="form.connection_config[field.name]"
|
||||
/>
|
||||
<t-input
|
||||
v-else-if="field.type === 'string' && field.sensitive"
|
||||
v-model="form.connection_config[field.name]"
|
||||
type="password"
|
||||
placeholder="********"
|
||||
/>
|
||||
<t-input-number
|
||||
v-else-if="field.type === 'number'"
|
||||
v-model="form.connection_config[field.name]"
|
||||
:placeholder="field.default != null ? String(field.default) : ' '"
|
||||
theme="normal"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<t-input
|
||||
v-else
|
||||
v-model="form.connection_config[field.name]"
|
||||
:placeholder="field.default?.toString() || ''"
|
||||
/>
|
||||
</t-form-item>
|
||||
</template>
|
||||
|
||||
<!-- Advanced: index fields -->
|
||||
<template v-if="selectedType.index_fields?.length">
|
||||
<div class="form-divider"></div>
|
||||
<div class="advanced-toggle" @click="showAdvanced = !showAdvanced">
|
||||
<t-icon :name="showAdvanced ? 'chevron-down' : 'chevron-right'" size="14px" />
|
||||
<span>{{ t('vectorStoreSettings.advancedIndexConfig') }}</span>
|
||||
</div>
|
||||
|
||||
<template v-if="showAdvanced">
|
||||
<template v-for="field in selectedType.index_fields" :key="field.name">
|
||||
<t-form-item :label="fieldLabel(field.name)" :name="`index_config.${field.name}`">
|
||||
<t-input-number
|
||||
v-if="field.type === 'number'"
|
||||
v-model="form.index_config[field.name]"
|
||||
:placeholder="field.default?.toString()"
|
||||
:min="1"
|
||||
:max="isReplicaField(field.name) ? 10 : 64"
|
||||
theme="normal"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<t-input
|
||||
v-else
|
||||
v-model="form.index_config[field.name]"
|
||||
:placeholder="field.default?.toString() || ''"
|
||||
:maxlength="128"
|
||||
/>
|
||||
</t-form-item>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
</div><!-- /.form-scroll-area -->
|
||||
|
||||
<!-- Dialog Footer (outside scroll area) -->
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-left">
|
||||
<t-button
|
||||
v-if="!editingStore"
|
||||
theme="default"
|
||||
variant="outline"
|
||||
:loading="testing"
|
||||
@click="testFromDialog"
|
||||
>
|
||||
{{ testing ? t('vectorStoreSettings.testing') : t('vectorStoreSettings.testConnection') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<div class="footer-right">
|
||||
<t-button theme="default" variant="base" @click="showDialog = false">{{ t('common.cancel') }}</t-button>
|
||||
<t-button theme="primary" type="submit" :loading="saving">{{ t('common.save') }}</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</t-form>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { AddIcon } from 'tdesign-icons-vue-next'
|
||||
import {
|
||||
listVectorStores,
|
||||
listVectorStoreTypes,
|
||||
createVectorStore,
|
||||
updateVectorStore,
|
||||
deleteVectorStore as deleteVectorStoreAPI,
|
||||
testVectorStoreRaw,
|
||||
testVectorStoreById,
|
||||
type VectorStoreEntity,
|
||||
type VectorStoreTypeInfo,
|
||||
} from '@/api/vector-store'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// ===== State =====
|
||||
const stores = ref<VectorStoreEntity[]>([])
|
||||
const storeTypes = ref<VectorStoreTypeInfo[]>([])
|
||||
const loading = ref(false)
|
||||
const showDialog = ref(false)
|
||||
const editingStore = ref<VectorStoreEntity | null>(null)
|
||||
const testing = ref(false)
|
||||
const testingId = ref<string | null>(null)
|
||||
const saving = ref(false)
|
||||
const showAdvanced = ref(false)
|
||||
const testResults = ref<Record<string, { success: boolean; message: string } | null>>({})
|
||||
|
||||
const form = ref<{
|
||||
name: string
|
||||
engine_type: string
|
||||
connection_config: Record<string, any>
|
||||
index_config: Record<string, any>
|
||||
}>({
|
||||
name: '',
|
||||
engine_type: '',
|
||||
connection_config: {},
|
||||
index_config: {},
|
||||
})
|
||||
|
||||
// ===== Computed =====
|
||||
const envStores = computed(() => stores.value.filter(s => s.source === 'env'))
|
||||
const userStores = computed(() => stores.value.filter(s => s.source === 'user'))
|
||||
const selectedType = computed(() => storeTypes.value.find(st => st.type === form.value.engine_type))
|
||||
|
||||
const storeActions = computed(() => [
|
||||
{ content: t('common.edit'), value: 'edit' },
|
||||
{ content: t('common.delete'), value: 'delete', theme: 'error' as const },
|
||||
])
|
||||
|
||||
const formRules = computed(() => {
|
||||
const rules: Record<string, any[]> = {
|
||||
name: [{ required: true, message: t('vectorStoreSettings.validation.nameRequired') }],
|
||||
}
|
||||
if (!editingStore.value) {
|
||||
rules.engine_type = [{ required: true, message: t('vectorStoreSettings.validation.engineTypeRequired') }]
|
||||
if (selectedType.value) {
|
||||
for (const field of selectedType.value.connection_fields) {
|
||||
if (field.required) {
|
||||
rules[`connection_config.${field.name}`] = [
|
||||
{ required: true, message: t('vectorStoreSettings.validation.fieldRequired', { field: fieldLabel(field.name) }) },
|
||||
]
|
||||
}
|
||||
}
|
||||
// Index name/collection string fields: pattern validation (optional — empty is allowed)
|
||||
for (const field of (selectedType.value.index_fields || [])) {
|
||||
if (field.type === 'string') {
|
||||
rules[`index_config.${field.name}`] = [
|
||||
{
|
||||
validator: (val: string) => !val || indexNamePattern.test(val),
|
||||
message: t('vectorStoreSettings.validation.indexNamePattern'),
|
||||
trigger: 'blur',
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rules
|
||||
})
|
||||
|
||||
// Index/collection name pattern: must start with letter, alphanumeric + _ + - only, max 128
|
||||
const indexNamePattern = /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/
|
||||
|
||||
// ===== Methods =====
|
||||
const fieldLabel = (name: string): string => {
|
||||
const key = `vectorStoreSettings.fields.${name}`
|
||||
const translated = t(key)
|
||||
// If i18n key not found, vue-i18n returns the key itself — fall back to field name
|
||||
return translated === key ? name : translated
|
||||
}
|
||||
|
||||
// Distinguish replica fields (max 10) from shard fields (max 64) for input bounds
|
||||
const replicaFieldNames = ['number_of_replicas', 'replication_factor', 'replica_number']
|
||||
const isReplicaField = (name: string): boolean => replicaFieldNames.includes(name)
|
||||
|
||||
const getTestResult = (store: VectorStoreEntity) => {
|
||||
return store.id ? testResults.value[store.id] ?? null : null
|
||||
}
|
||||
|
||||
const getStoreEndpoint = (store: VectorStoreEntity): string => {
|
||||
const cc = store.connection_config || {}
|
||||
return cc.addr || cc.host || ''
|
||||
}
|
||||
|
||||
const onEngineTypeChange = () => {
|
||||
form.value.connection_config = {}
|
||||
form.value.index_config = {}
|
||||
showAdvanced.value = false
|
||||
}
|
||||
|
||||
const loadStores = async () => {
|
||||
try {
|
||||
const response = await listVectorStores()
|
||||
if (response.data && Array.isArray(response.data)) {
|
||||
stores.value = response.data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load vector stores:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const loadStoreTypes = async () => {
|
||||
try {
|
||||
storeTypes.value = await listVectorStoreTypes()
|
||||
} catch (error) {
|
||||
console.error('Failed to load vector store types:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const openAddDialog = () => {
|
||||
editingStore.value = null
|
||||
showAdvanced.value = false
|
||||
form.value = {
|
||||
name: '',
|
||||
engine_type: storeTypes.value[0]?.type || '',
|
||||
connection_config: {},
|
||||
index_config: {},
|
||||
}
|
||||
showDialog.value = true
|
||||
}
|
||||
|
||||
const editStore = (store: VectorStoreEntity) => {
|
||||
editingStore.value = store
|
||||
showAdvanced.value = false
|
||||
form.value = {
|
||||
name: store.name,
|
||||
engine_type: store.engine_type,
|
||||
connection_config: { ...store.connection_config },
|
||||
index_config: { ...store.index_config },
|
||||
}
|
||||
showDialog.value = true
|
||||
}
|
||||
|
||||
const saveStore = async ({ validateResult, firstError }: any) => {
|
||||
if (validateResult !== true && validateResult !== undefined) {
|
||||
MessagePlugin.warning(firstError || t('vectorStoreSettings.toasts.errorGeneric'))
|
||||
return
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
if (editingStore.value) {
|
||||
await updateVectorStore(editingStore.value.id!, { name: form.value.name.trim() })
|
||||
MessagePlugin.success(t('vectorStoreSettings.toasts.storeUpdated'))
|
||||
} else {
|
||||
const data: Partial<VectorStoreEntity> = {
|
||||
name: form.value.name.trim(),
|
||||
engine_type: form.value.engine_type,
|
||||
connection_config: { ...form.value.connection_config },
|
||||
index_config: showAdvanced.value ? { ...form.value.index_config } : {},
|
||||
}
|
||||
await createVectorStore(data)
|
||||
MessagePlugin.success(t('vectorStoreSettings.toasts.storeCreated'))
|
||||
}
|
||||
showDialog.value = false
|
||||
await loadStores()
|
||||
} catch (error: any) {
|
||||
const msg = error?.message || t('vectorStoreSettings.toasts.errorGeneric')
|
||||
if (msg.toLowerCase().includes('already exists') || msg.toLowerCase().includes('duplicate')) {
|
||||
MessagePlugin.error(t('vectorStoreSettings.toasts.duplicateName'))
|
||||
} else {
|
||||
MessagePlugin.error(msg)
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleAction = (action: { value: string }, store: VectorStoreEntity) => {
|
||||
if (action.value === 'edit') {
|
||||
editStore(store)
|
||||
} else if (action.value === 'delete') {
|
||||
confirmDelete(store)
|
||||
}
|
||||
}
|
||||
|
||||
const confirmDelete = (store: VectorStoreEntity) => {
|
||||
const dialog = DialogPlugin.confirm({
|
||||
header: t('vectorStoreSettings.deleteConfirm'),
|
||||
confirmBtn: t('common.delete'),
|
||||
cancelBtn: t('common.cancel'),
|
||||
theme: 'warning',
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await deleteVectorStoreAPI(store.id!)
|
||||
MessagePlugin.success(t('vectorStoreSettings.toasts.storeDeleted'))
|
||||
await loadStores()
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('vectorStoreSettings.toasts.errorGeneric'))
|
||||
}
|
||||
dialog.destroy()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const clearTestResult = (store: VectorStoreEntity) => {
|
||||
if (store.id) {
|
||||
const { [store.id]: _, ...rest } = testResults.value
|
||||
testResults.value = rest
|
||||
}
|
||||
}
|
||||
|
||||
const testExisting = async (store: VectorStoreEntity) => {
|
||||
testingId.value = store.id!
|
||||
testResults.value = { ...testResults.value, [store.id!]: null }
|
||||
try {
|
||||
const res = await testVectorStoreById(store.id!)
|
||||
testResults.value = {
|
||||
...testResults.value,
|
||||
[store.id!]: {
|
||||
success: res.success,
|
||||
message: res.success
|
||||
? t('vectorStoreSettings.toasts.testSuccess')
|
||||
: (res.error || t('vectorStoreSettings.toasts.testFailed')),
|
||||
},
|
||||
}
|
||||
} catch (error: any) {
|
||||
testResults.value = {
|
||||
...testResults.value,
|
||||
[store.id!]: {
|
||||
success: false,
|
||||
message: error?.message || t('vectorStoreSettings.toasts.testFailed'),
|
||||
},
|
||||
}
|
||||
} finally {
|
||||
testingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const testFromDialog = async () => {
|
||||
testing.value = true
|
||||
try {
|
||||
const data = {
|
||||
engine_type: form.value.engine_type,
|
||||
connection_config: { ...form.value.connection_config },
|
||||
}
|
||||
const res = await testVectorStoreRaw(data)
|
||||
if (res.success) {
|
||||
MessagePlugin.success(t('vectorStoreSettings.toasts.testSuccess'))
|
||||
} else {
|
||||
MessagePlugin.error(res.error || t('vectorStoreSettings.toasts.testFailed'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('vectorStoreSettings.toasts.testFailed'))
|
||||
} finally {
|
||||
testing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ===== Init =====
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
await Promise.all([loadStoreTypes(), loadStores()])
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.vectorstore-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.section-subheader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.store-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.store-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 14px 16px;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
&--env {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.item-desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.item-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.test-result-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
word-break: break-word;
|
||||
|
||||
&.success {
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
&.error {
|
||||
background: var(--td-error-color-1, rgba(227, 77, 89, 0.1));
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
|
||||
.test-result-message {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.test-result-close {
|
||||
flex-shrink: 0;
|
||||
margin-left: 8px;
|
||||
cursor: pointer;
|
||||
opacity: 0.6;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-stores {
|
||||
padding: 48px 32px;
|
||||
text-align: center;
|
||||
color: var(--td-text-color-placeholder);
|
||||
border: 1px dashed var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
// Dialog
|
||||
.dialog-form-container {
|
||||
margin-top: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 70vh;
|
||||
}
|
||||
|
||||
.store-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.form-scroll-area {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.immutable-notice {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
margin-bottom: 16px;
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-brand-color);
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.readonly-fields {
|
||||
padding: 10px 14px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.readonly-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
padding: 3px 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.readonly-label {
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
min-width: 60px;
|
||||
}
|
||||
|
||||
.readonly-value {
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 12px;
|
||||
font-family: 'SF Mono', Monaco, Menlo, monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.form-divider {
|
||||
height: 1px;
|
||||
background: var(--td-component-border);
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.form-section-label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.advanced-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
margin-bottom: 12px;
|
||||
|
||||
&:hover {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 32px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid var(--td-component-border);
|
||||
|
||||
.footer-right {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -484,79 +484,65 @@ func GetVectorStoreTypes() []VectorStoreTypeInfo {
|
||||
return []VectorStoreTypeInfo{
|
||||
{
|
||||
Type: "elasticsearch",
|
||||
DisplayName: "Elasticsearch (Keywords + Vector)",
|
||||
DisplayName: "Elasticsearch",
|
||||
ConnectionFields: []VectorStoreFieldInfo{
|
||||
{Name: "addr", Type: "string", Required: true, Description: "Elasticsearch URL (e.g., http://localhost:9200)"},
|
||||
{Name: "username", Type: "string", Required: false},
|
||||
{Name: "password", Type: "string", Required: false, Sensitive: true},
|
||||
{Name: "addr", Type: "string", Required: true, Description: "URL", Default: "http://localhost:9200"},
|
||||
{Name: "username", Type: "string", Required: false, Description: "Username", Default: "elastic"},
|
||||
{Name: "password", Type: "string", Required: false, Sensitive: true, Description: "Password"},
|
||||
},
|
||||
IndexFields: []VectorStoreFieldInfo{
|
||||
{Name: "index_name", Type: "string", Required: false, Default: "xwrag_default"},
|
||||
{Name: "number_of_shards", Type: "number", Required: false},
|
||||
{Name: "number_of_replicas", Type: "number", Required: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "postgres",
|
||||
DisplayName: "PostgreSQL (Keywords + Vector)",
|
||||
ConnectionFields: []VectorStoreFieldInfo{
|
||||
{Name: "use_default_connection", Type: "boolean", Required: false, Default: true,
|
||||
Description: "Use the application's default database connection"},
|
||||
{Name: "addr", Type: "string", Required: false,
|
||||
Description: "PostgreSQL connection string (required if use_default_connection is false)"},
|
||||
{Name: "username", Type: "string", Required: false},
|
||||
{Name: "password", Type: "string", Required: false, Sensitive: true},
|
||||
{Name: "index_name", Type: "string", Required: false, Description: "Index Name", Default: "weknora"},
|
||||
{Name: "number_of_shards", Type: "number", Required: false, Description: "Shards", Default: 4},
|
||||
{Name: "number_of_replicas", Type: "number", Required: false, Description: "Replicas", Default: 1},
|
||||
},
|
||||
},
|
||||
// PostgreSQL and SQLite are excluded from the type list because they only support
|
||||
// the app's default DB connection (UseDefaultConnection=true). They appear as
|
||||
// env stores when configured via RETRIEVE_DRIVER but cannot be added as DB stores.
|
||||
{
|
||||
Type: "qdrant",
|
||||
DisplayName: "Qdrant (Keywords + Vector)",
|
||||
DisplayName: "Qdrant",
|
||||
ConnectionFields: []VectorStoreFieldInfo{
|
||||
{Name: "host", Type: "string", Required: true, Description: "Qdrant host"},
|
||||
{Name: "port", Type: "number", Required: false, Default: 6334},
|
||||
{Name: "api_key", Type: "string", Required: false, Sensitive: true},
|
||||
{Name: "use_tls", Type: "boolean", Required: false, Default: false},
|
||||
{Name: "host", Type: "string", Required: true, Description: "Host", Default: "localhost"},
|
||||
{Name: "port", Type: "number", Required: false, Description: "Port", Default: 6334},
|
||||
{Name: "api_key", Type: "string", Required: false, Sensitive: true, Description: "API Key"},
|
||||
{Name: "use_tls", Type: "boolean", Required: false, Description: "Use TLS", Default: false},
|
||||
},
|
||||
IndexFields: []VectorStoreFieldInfo{
|
||||
{Name: "collection_prefix", Type: "string", Required: false, Default: "weknora_embeddings", Description: "Collection Prefix"},
|
||||
{Name: "shard_number", Type: "number", Required: false, Default: 1, Description: "Shard Number"},
|
||||
{Name: "replication_factor", Type: "number", Required: false, Default: 1, Description: "Replication Factor"},
|
||||
{Name: "collection_prefix", Type: "string", Required: false, Description: "Collection Prefix", Default: "weknora_embeddings"},
|
||||
{Name: "shard_number", Type: "number", Required: false, Description: "Shard Number", Default: 1},
|
||||
{Name: "replication_factor", Type: "number", Required: false, Description: "Replication Factor", Default: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "milvus",
|
||||
DisplayName: "Milvus (Keywords + Vector)",
|
||||
DisplayName: "Milvus",
|
||||
ConnectionFields: []VectorStoreFieldInfo{
|
||||
{Name: "addr", Type: "string", Required: true, Description: "Milvus address (e.g., localhost:19530)"},
|
||||
{Name: "username", Type: "string", Required: false},
|
||||
{Name: "password", Type: "string", Required: false, Sensitive: true},
|
||||
{Name: "addr", Type: "string", Required: true, Description: "Address", Default: "localhost:19530"},
|
||||
{Name: "username", Type: "string", Required: false, Description: "Username", Default: "root"},
|
||||
{Name: "password", Type: "string", Required: false, Sensitive: true, Description: "Password"},
|
||||
},
|
||||
IndexFields: []VectorStoreFieldInfo{
|
||||
{Name: "collection_name", Type: "string", Required: false, Default: "weknora_embeddings", Description: "Collection Name"},
|
||||
{Name: "shards_num", Type: "number", Required: false, Default: 1, Description: "Shards (write parallelism)"},
|
||||
{Name: "replica_number", Type: "number", Required: false, Default: 1, Description: "In-memory Replicas (read HA)"},
|
||||
{Name: "collection_name", Type: "string", Required: false, Description: "Collection Name", Default: "weknora_embeddings"},
|
||||
{Name: "shards_num", Type: "number", Required: false, Description: "Shards (write parallelism)", Default: 1},
|
||||
{Name: "replica_number", Type: "number", Required: false, Description: "In-memory Replicas (read HA)", Default: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "weaviate",
|
||||
DisplayName: "Weaviate (Keywords + Vector)",
|
||||
DisplayName: "Weaviate",
|
||||
ConnectionFields: []VectorStoreFieldInfo{
|
||||
{Name: "host", Type: "string", Required: true, Description: "Weaviate host (e.g., weaviate:8080)"},
|
||||
{Name: "grpc_address", Type: "string", Required: false, Default: "weaviate:50051"},
|
||||
{Name: "scheme", Type: "string", Required: false, Default: "http"},
|
||||
{Name: "api_key", Type: "string", Required: false, Sensitive: true},
|
||||
{Name: "host", Type: "string", Required: true, Description: "Host", Default: "weaviate:8080"},
|
||||
{Name: "grpc_address", Type: "string", Required: false, Description: "gRPC Address", Default: "weaviate:50051"},
|
||||
{Name: "scheme", Type: "string", Required: false, Description: "Scheme", Default: "http"},
|
||||
{Name: "api_key", Type: "string", Required: false, Sensitive: true, Description: "API Key"},
|
||||
},
|
||||
IndexFields: []VectorStoreFieldInfo{
|
||||
{Name: "collection_prefix", Type: "string", Required: false, Default: "Weknora_embeddings", Description: "Collection Prefix"},
|
||||
{Name: "desired_shard_count", Type: "number", Required: false, Default: 1, Description: "Shard Count"},
|
||||
{Name: "replication_factor", Type: "number", Required: false, Default: 1, Description: "Replication Factor"},
|
||||
{Name: "collection_prefix", Type: "string", Required: false, Description: "Collection Prefix", Default: "Weknora_embeddings"},
|
||||
{Name: "desired_shard_count", Type: "number", Required: false, Description: "Shard Count", Default: 1},
|
||||
{Name: "replication_factor", Type: "number", Required: false, Description: "Replication Factor", Default: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "sqlite",
|
||||
DisplayName: "SQLite (Keywords + Vector)",
|
||||
ConnectionFields: []VectorStoreFieldInfo{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +597,7 @@ func buildEnvStoreForDriver(driver string, envLookup EnvLookupFunc) *VectorStore
|
||||
case "postgres":
|
||||
return &VectorStore{
|
||||
ID: "__env_postgres__",
|
||||
Name: "postgres (env)",
|
||||
Name: "PostgreSQL",
|
||||
EngineType: PostgresRetrieverEngineType,
|
||||
ConnectionConfig: ConnectionConfig{
|
||||
UseDefaultConnection: true,
|
||||
@@ -620,13 +606,13 @@ func buildEnvStoreForDriver(driver string, envLookup EnvLookupFunc) *VectorStore
|
||||
case "sqlite":
|
||||
return &VectorStore{
|
||||
ID: "__env_sqlite__",
|
||||
Name: "sqlite (env)",
|
||||
Name: "SQLite",
|
||||
EngineType: SQLiteRetrieverEngineType,
|
||||
}
|
||||
case "elasticsearch_v8":
|
||||
return &VectorStore{
|
||||
ID: "__env_elasticsearch_v8__",
|
||||
Name: "elasticsearch v8 (env)",
|
||||
Name: "Elasticsearch v8",
|
||||
EngineType: ElasticsearchRetrieverEngineType,
|
||||
ConnectionConfig: ConnectionConfig{
|
||||
Addr: envLookup("ELASTICSEARCH_ADDR"),
|
||||
@@ -640,7 +626,7 @@ func buildEnvStoreForDriver(driver string, envLookup EnvLookupFunc) *VectorStore
|
||||
case "elasticsearch_v7":
|
||||
return &VectorStore{
|
||||
ID: "__env_elasticsearch_v7__",
|
||||
Name: "elasticsearch v7 (env)",
|
||||
Name: "Elasticsearch v7",
|
||||
EngineType: ElasticsearchRetrieverEngineType,
|
||||
ConnectionConfig: ConnectionConfig{
|
||||
Addr: envLookup("ELASTICSEARCH_ADDR"),
|
||||
@@ -654,7 +640,7 @@ func buildEnvStoreForDriver(driver string, envLookup EnvLookupFunc) *VectorStore
|
||||
case "qdrant":
|
||||
return &VectorStore{
|
||||
ID: "__env_qdrant__",
|
||||
Name: "qdrant (env)",
|
||||
Name: "Qdrant",
|
||||
EngineType: QdrantRetrieverEngineType,
|
||||
ConnectionConfig: ConnectionConfig{
|
||||
Host: envLookup("QDRANT_HOST"),
|
||||
@@ -664,7 +650,7 @@ func buildEnvStoreForDriver(driver string, envLookup EnvLookupFunc) *VectorStore
|
||||
case "milvus":
|
||||
return &VectorStore{
|
||||
ID: "__env_milvus__",
|
||||
Name: "milvus (env)",
|
||||
Name: "Milvus",
|
||||
EngineType: MilvusRetrieverEngineType,
|
||||
ConnectionConfig: ConnectionConfig{
|
||||
Addr: envLookup("MILVUS_ADDRESS"),
|
||||
@@ -675,7 +661,7 @@ func buildEnvStoreForDriver(driver string, envLookup EnvLookupFunc) *VectorStore
|
||||
case "weaviate":
|
||||
return &VectorStore{
|
||||
ID: "__env_weaviate__",
|
||||
Name: "weaviate (env)",
|
||||
Name: "Weaviate",
|
||||
EngineType: WeaviateRetrieverEngineType,
|
||||
ConnectionConfig: ConnectionConfig{
|
||||
Host: envLookup("WEAVIATE_HOST"),
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestBuildEnvVectorStores(t *testing.T) {
|
||||
stores := BuildEnvVectorStores("postgres", lookup)
|
||||
require.Len(t, stores, 1)
|
||||
assert.Equal(t, "__env_postgres__", stores[0].ID)
|
||||
assert.Equal(t, "postgres (env)", stores[0].Name)
|
||||
assert.Equal(t, "PostgreSQL", stores[0].Name)
|
||||
assert.Equal(t, PostgresRetrieverEngineType, stores[0].EngineType)
|
||||
assert.True(t, stores[0].ConnectionConfig.UseDefaultConnection)
|
||||
})
|
||||
@@ -198,8 +198,8 @@ func TestNewVectorStoreResponse(t *testing.T) {
|
||||
func TestGetVectorStoreTypes(t *testing.T) {
|
||||
types := GetVectorStoreTypes()
|
||||
|
||||
t.Run("returns 6 engine types", func(t *testing.T) {
|
||||
assert.Len(t, types, 6)
|
||||
t.Run("returns 4 engine types (excludes postgres and sqlite)", func(t *testing.T) {
|
||||
assert.Len(t, types, 4)
|
||||
})
|
||||
|
||||
t.Run("type names match engine constants", func(t *testing.T) {
|
||||
@@ -208,11 +208,11 @@ func TestGetVectorStoreTypes(t *testing.T) {
|
||||
typeNames[i] = typ.Type
|
||||
}
|
||||
assert.Contains(t, typeNames, "elasticsearch")
|
||||
assert.Contains(t, typeNames, "postgres")
|
||||
assert.Contains(t, typeNames, "qdrant")
|
||||
assert.Contains(t, typeNames, "milvus")
|
||||
assert.Contains(t, typeNames, "weaviate")
|
||||
assert.Contains(t, typeNames, "sqlite")
|
||||
assert.NotContains(t, typeNames, "postgres")
|
||||
assert.NotContains(t, typeNames, "sqlite")
|
||||
})
|
||||
|
||||
t.Run("elasticsearch has connection and index fields", func(t *testing.T) {
|
||||
@@ -237,15 +237,10 @@ func TestGetVectorStoreTypes(t *testing.T) {
|
||||
assert.True(t, passwordField.Sensitive)
|
||||
})
|
||||
|
||||
t.Run("sqlite has no connection fields", func(t *testing.T) {
|
||||
var sqliteType VectorStoreTypeInfo
|
||||
t.Run("display names have no parenthetical suffix", func(t *testing.T) {
|
||||
for _, typ := range types {
|
||||
if typ.Type == "sqlite" {
|
||||
sqliteType = typ
|
||||
break
|
||||
}
|
||||
assert.NotContains(t, typ.DisplayName, "(", "display_name should not contain parenthetical suffix: %s", typ.DisplayName)
|
||||
}
|
||||
assert.Empty(t, sqliteType.ConnectionFields)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -295,7 +295,7 @@ start_app() {
|
||||
log_warning "提示: 安装 Air 可以实现代码修改后自动重启"
|
||||
log_info "安装命令: go install github.com/air-verse/air@latest"
|
||||
LDFLAGS="$(./scripts/get_version.sh ldflags) -X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'"
|
||||
go run -ldflags="$LDFLAGS" cmd/server/main.go
|
||||
go run -ldflags="$LDFLAGS" ./cmd/server/
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user