@@ -301,6 +363,8 @@ export default {
},
activeTab: 'upload',
selectedFile: null,
+ chunkSize: null,
+ overlap: null,
uploading: false,
searchQuery: '',
searchResults: [],
@@ -323,7 +387,7 @@ export default {
embeddingModelProps(providerConfig) {
return {
title: providerConfig.embedding_model,
- subtitle: `提供商 ID: ${providerConfig.id}`,
+ subtitle: `提供商 ID: ${providerConfig.id} | 嵌入模型维度: ${providerConfig.embedding_dimensions}`,
}
},
checkPlugin() {
@@ -439,6 +503,9 @@ export default {
this.searchQuery = '';
this.searchResults = [];
this.searchPerformed = false;
+ // 重置分片长度和重叠长度参数
+ this.chunkSize = null;
+ this.overlap = null;
},
triggerFileInput() {
@@ -492,6 +559,15 @@ export default {
const formData = new FormData();
formData.append('file', this.selectedFile);
formData.append('collection_name', this.currentKB.collection_name);
+
+ // 添加可选的分片长度和重叠长度参数
+ if (this.chunkSize && this.chunkSize > 0) {
+ formData.append('chunk_size', this.chunkSize);
+ }
+
+ if (this.overlap && this.overlap >= 0) {
+ formData.append('chunk_overlap', this.overlap);
+ }
axios.post('/api/plug/alkaid/kb/collection/add_file', formData, {
headers: {
@@ -500,7 +576,7 @@ export default {
})
.then(response => {
if (response.data.status === 'ok') {
- this.showSnackbar('文件上传成功');
+ this.showSnackbar('操作成功: ' + response.data.message);
this.selectedFile = null;
// 刷新知识库列表,获取更新的数量
@@ -792,4 +868,28 @@ export default {
.kb-card:hover .kb-actions {
opacity: 1;
}
+
+.chunk-settings-card {
+ border: 1px solid rgba(92, 107, 192, 0.2) !important;
+ transition: all 0.3s ease;
+}
+
+.chunk-settings-card:hover {
+ border-color: rgba(92, 107, 192, 0.4) !important;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07) !important;
+}
+
+.chunk-field :deep(.v-field__input) {
+ padding-top: 8px;
+ padding-bottom: 8px;
+}
+
+.chunk-field :deep(.v-field__prepend-inner) {
+ padding-right: 8px;
+ opacity: 0.7;
+}
+
+.chunk-field:focus-within :deep(.v-field__prepend-inner) {
+ opacity: 1;
+}
From 40c27d87f5989e94c48ee772d3e32e07ed9ae4bb Mon Sep 17 00:00:00 2001
From: Soulter <905617992@qq.com>
Date: Fri, 30 May 2025 23:18:19 +0800
Subject: [PATCH 3/4] feat: knowledge-base
---
.../full/vertical-sidebar/sidebarItem.ts | 10 +-
dashboard/src/views/alkaid/KnowledgeBase.vue | 8 +-
dashboard/src/views/alkaid/LongTermMemory.vue | 111 +++++++-----------
3 files changed, 53 insertions(+), 76 deletions(-)
diff --git a/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts b/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts
index f541d1d91..e8f49c741 100644
--- a/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts
+++ b/dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts
@@ -65,11 +65,11 @@ const sidebarItem: menu[] = [
icon: 'mdi-console',
to: '/console'
},
- // {
- // title: 'Alkaid',
- // icon: 'mdi-test-tube',
- // to: '/alkaid'
- // },
+ {
+ title: 'Alkaid',
+ icon: 'mdi-test-tube',
+ to: '/alkaid'
+ },
{
title: '关于',
icon: 'mdi-information',
diff --git a/dashboard/src/views/alkaid/KnowledgeBase.vue b/dashboard/src/views/alkaid/KnowledgeBase.vue
index e31644e47..29889f41f 100644
--- a/dashboard/src/views/alkaid/KnowledgeBase.vue
+++ b/dashboard/src/views/alkaid/KnowledgeBase.vue
@@ -18,7 +18,9 @@
-
知识库列表
+
知识库列表
+ mdi-information-outline
+
创建知识库
@@ -698,6 +700,10 @@ export default {
this.showSnackbar('获取嵌入模型列表失败', 'error');
return [];
});
+ },
+
+ openUrl(url) {
+ window.open(url, '_blank');
}
}
}
diff --git a/dashboard/src/views/alkaid/LongTermMemory.vue b/dashboard/src/views/alkaid/LongTermMemory.vue
index 45d687fec..e534c70d8 100644
--- a/dashboard/src/views/alkaid/LongTermMemory.vue
+++ b/dashboard/src/views/alkaid/LongTermMemory.vue
@@ -1,6 +1,11 @@
-
+
+
+ 加速开发中...
@@ -31,42 +36,27 @@
搜索记忆
-
-
-
+
+
+
mdi-text-search
搜索
-
+
搜索结果 ({{ searchResults.length }})
-
+
- {{ result.text.substring(0, 30) }}...
+ {{ result.text.substring(0, 30)
+ }}...
(相关度: {{ (result.score * 100).toFixed(1) }}%)
@@ -86,42 +76,21 @@
-
+
添加记忆数据
-
-
-
-
-
-
-
+
+
+
+
+
+
+
mdi-plus
添加数据
@@ -249,26 +218,26 @@ export default {
this.$toast.warning('请输入搜索关键词');
return;
}
-
+
this.isSearching = true;
this.hasSearched = true;
this.searchResults = [];
-
+
// 构建查询参数
const params = {
query: this.searchQuery
};
-
+
// 如果有选择用户ID,也加入查询参数
if (this.searchMemoryUserId) {
params.user_id = this.searchMemoryUserId;
}
-
+
axios.get('/api/plug/alkaid/ltm/graph/search', { params })
.then(response => {
if (response.data.status === 'ok') {
const data = response.data.data;
-
+
// 处理返回的文档数组
this.searchResults = Object.keys(data).map(doc_id => {
return {
@@ -277,7 +246,7 @@ export default {
score: data[doc_id].score || 0
};
});
-
+
if (this.searchResults.length === 0) {
this.$toast.info('未找到相关记忆内容');
} else {
@@ -295,7 +264,7 @@ export default {
this.isSearching = false;
});
},
-
+
// 添加新方法,用于提交记忆数据
addMemoryData() {
if (!this.newMemoryText || !this.newMemoryUserId) {
@@ -303,23 +272,23 @@ export default {
}
this.isSubmitting = true;
-
+
// 准备提交数据
const payload = {
text: this.newMemoryText,
user_id: this.newMemoryUserId,
need_summarize: this.needSummarize
};
-
+
axios.post('/api/plug/alkaid/ltm/graph/add', payload)
.then(response => {
// 成功添加后刷新图表
this.refreshGraph();
-
+
// 重置表单
// this.newMemoryText = '';
// this.needSummarize = false;
-
+
// 显示成功消息
this.$toast.success('记忆数据添加成功!');
})
@@ -331,7 +300,7 @@ export default {
this.isSubmitting = false;
});
},
-
+
ltmGetGraph(userId = null) {
this.isLoading = true;
const params = userId ? { user_id: userId } : {};
@@ -571,6 +540,7 @@ export default {
From e68173b451244e562ab6538c8911d4be07f0a002 Mon Sep 17 00:00:00 2001
From: Soulter <905617992@qq.com>
Date: Fri, 30 May 2025 23:18:48 +0800
Subject: [PATCH 4/4] feat: knowledge-base
---
dashboard/src/views/alkaid/KnowledgeBase.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dashboard/src/views/alkaid/KnowledgeBase.vue b/dashboard/src/views/alkaid/KnowledgeBase.vue
index 29889f41f..4dc683f59 100644
--- a/dashboard/src/views/alkaid/KnowledgeBase.vue
+++ b/dashboard/src/views/alkaid/KnowledgeBase.vue
@@ -414,7 +414,7 @@ export default {
installPlugin() {
this.installing = true;
axios.post('/api/plugin/install', {
- url: "https://github.com/soulter/astrbot_plugin_knowledge_base",
+ url: "https://github.com/lxfight/astrbot_plugin_knowledge_base",
proxy: localStorage.getItem('selectedGitHubProxy') || ""
})
.then(response => {