fix: remove repeated full-table scans from knowledge and activity paths
Binding checks loaded and parsed every external knowledge binding to answer a single-row question. requireLibrary did this on more than thirty call sites including one inside a task reconciliation loop, and the knowledge snapshot scanned the table twice per library across its seven callers. Add keyed store lookups (getBinding, hasBinding, getBindingsForInstance) that use the existing primary key, build the snapshot's bindings once into a Map, and count bindings per instance in a single pass. Memoize the conversation activity index in the renderer. It was rebuilt on every render, including once per streaming token, which discarded half the benefit of the memoized activity summary directly above it. Release note: 知识库页面、对话预检索和跨项目活动列表在绑定较多时响应更快,流式回答期间的 界面开销降低。
This commit is contained in:
@@ -926,7 +926,7 @@ export class KnowledgeDatabase {
|
||||
input: UpdateKnowledgeBaseInput
|
||||
): KnowledgeBase {
|
||||
const current = this.requiredKnowledgeBase(id)
|
||||
if (this.externalStore.listBindings().some(item => item.knowledgeBaseId === id) &&
|
||||
if (this.externalStore.hasBinding(id) &&
|
||||
(input.graphEnabled !== undefined || input.graphStrategy !== undefined || input.storageMode !== undefined)) {
|
||||
throw new Error('EXTERNAL_KB_READ_ONLY')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user