fix(rag): default search to keyword and rebuild saved roots

This commit is contained in:
lix-2026
2026-06-09 09:32:36 +08:00
parent 8e3be8b0b7
commit 516121e6f9
4 changed files with 50 additions and 10 deletions
@@ -670,7 +670,7 @@ export function createSidebarPageSettingsRuntime(context) {
'</div>' +
'<div class="wolai-page-settings-index-actions">' +
'<button type="button" data-knowledge-rag-action="refresh">刷新状态</button>' +
'<button type="button" data-knowledge-rag-action="ingest">索引来源</button>' +
'<button type="button" data-knowledge-rag-action="ingest">索引/重建来源</button>' +
'<button type="button" data-knowledge-rag-action="prune">清除失效记录</button>' +
'<button type="button" data-knowledge-rag-action="open-dashboard">打开 LightRAG</button>' +
'</div>' +
@@ -1058,6 +1058,17 @@ export function createSidebarPageSettingsRuntime(context) {
});
}
function knowledgeRagIndexedRootValues() {
var status = currentKnowledgeRagSummary().status || {};
var registry = status.registry && typeof status.registry === 'object' ? status.registry : {};
var roots = Array.isArray(registry.indexedRoots) ? registry.indexedRoots : [];
return roots.map(function(root) {
return String(root && (root.rootRelativePath || root.root_relative_path) || '').trim();
}).filter(Boolean).filter(function(value, index, list) {
return list.indexOf(value) === index;
});
}
function knowledgeRagCurrentFilter() {
return pageUiState.knowledgeRagSourceFilter || 'attention';
}
@@ -1503,11 +1514,12 @@ export function createSidebarPageSettingsRuntime(context) {
async function ingestKnowledgeRagSources() {
if (!knowledgeRagIsAvailable()) return;
var sources = knowledgeRagSourceInputValues();
if (!sources.length) sources = knowledgeRagIndexedRootValues();
if (!sources.length) {
pageUiState.knowledgeRagSummary = Object.assign({}, currentKnowledgeRagSummary(), {
scopeKey: knowledgeRagScopeKey(),
loading: false,
error: '请先填写要索引的资料路径'
error: '请先填写要索引的资料路径,或保留至少一个已保存的索引范围'
});
renderKnowledgeRagSettings();
return;