@@ -256,7 +324,8 @@ export default {
newKB: {
name: '',
emoji: '🙂',
- description: ''
+ description: '',
+ embedding_provider_id: ''
},
snackbar: {
show: false,
@@ -296,6 +365,8 @@ export default {
},
activeTab: 'upload',
selectedFile: null,
+ chunkSize: null,
+ overlap: null,
uploading: false,
searchQuery: '',
searchResults: [],
@@ -306,13 +377,21 @@ export default {
deleteTarget: {
collection_name: ''
},
- deleting: false
+ deleting: false,
+ embeddingProviderConfigs: []
}
},
mounted() {
this.checkPlugin();
+ this.getEmbeddingProviderList();
},
methods: {
+ embeddingModelProps(providerConfig) {
+ return {
+ title: providerConfig.embedding_model,
+ subtitle: `提供商 ID: ${providerConfig.id} | 嵌入模型维度: ${providerConfig.embedding_dimensions}`,
+ }
+ },
checkPlugin() {
axios.get('/api/plugin/get?name=astrbot_plugin_knowledge_base')
.then(response => {
@@ -335,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 => {
@@ -365,10 +444,15 @@ export default {
},
createCollection(name, emoji, description) {
+ // 如果 this.newKB.embedding_provider_id 是 Object
+ if (typeof this.newKB.embedding_provider_id === 'object') {
+ this.newKB.embedding_provider_id = this.newKB.embedding_provider_id.id || '';
+ }
axios.post('/api/plug/alkaid/kb/create_collection', {
collection_name: name,
emoji: emoji,
- description: description
+ description: description,
+ embedding_provider_id: this.newKB.embedding_provider_id || ''
})
.then(response => {
if (response.data.status === 'ok') {
@@ -394,7 +478,8 @@ export default {
this.createCollection(
this.newKB.name,
this.newKB.emoji || '🙂',
- this.newKB.description
+ this.newKB.description,
+ this.newKB.embedding_provider_id || ''
);
},
@@ -402,7 +487,8 @@ export default {
this.newKB = {
name: '',
emoji: '🙂',
- description: ''
+ description: '',
+ embedding_provider: ''
};
},
@@ -419,6 +505,9 @@ export default {
this.searchQuery = '';
this.searchResults = [];
this.searchPerformed = false;
+ // 重置分片长度和重叠长度参数
+ this.chunkSize = null;
+ this.overlap = null;
},
triggerFileInput() {
@@ -472,6 +561,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: {
@@ -480,7 +578,7 @@ export default {
})
.then(response => {
if (response.data.status === 'ok') {
- this.showSnackbar('文件上传成功');
+ this.showSnackbar('操作成功: ' + response.data.message);
this.selectedFile = null;
// 刷新知识库列表,获取更新的数量
@@ -582,6 +680,31 @@ export default {
this.deleting = false;
});
},
+
+ getEmbeddingProviderList() {
+ axios.get('/api/config/provider/list', {
+ params: {
+ provider_type: 'embedding'
+ }
+ })
+ .then(response => {
+ if (response.data.status === 'ok') {
+ this.embeddingProviderConfigs = response.data.data || [];
+ } else {
+ this.showSnackbar(response.data.message || '获取嵌入模型列表失败', 'error');
+ return [];
+ }
+ })
+ .catch(error => {
+ console.error('Error fetching embedding providers:', error);
+ this.showSnackbar('获取嵌入模型列表失败', 'error');
+ return [];
+ });
+ },
+
+ openUrl(url) {
+ window.open(url, '_blank');
+ }
}
}
@@ -751,4 +874,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;
+}
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 {