Skip to content

Commit 622febd

Browse files
committed
update-data-store-name
1 parent 791c1e3 commit 622febd

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

packages/components/nodes/agentflow/Agent/Agent.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ class Agent_Agentflow implements INode {
433433
for (const store of stores) {
434434
if (store.status === 'UPSERTED') {
435435
const obj = {
436-
name: `${store.id}:${store.name}`,
437-
label: store.name,
436+
name: store.id, // Store only the ID, not the name
437+
label: store.name, // Display the current name
438438
description: store.description
439439
}
440440
returnData.push(obj)
@@ -547,7 +547,22 @@ class Agent_Agentflow implements INode {
547547
const nodeInstanceFilePath = options.componentNodes['retrieverTool'].filePath as string
548548
const nodeModule = await import(nodeInstanceFilePath)
549549
const newRetrieverToolNodeInstance = new nodeModule.nodeClass()
550-
const [storeId, storeName] = knowledgeBase.documentStore.split(':')
550+
551+
// Handle both old format (id:name) and new format (id only)
552+
let storeId = knowledgeBase.documentStore
553+
let storeName = ''
554+
555+
if (knowledgeBase.documentStore.includes(':')) {
556+
// Old format - split to get ID and name
557+
;[storeId, storeName] = knowledgeBase.documentStore.split(':')
558+
} else {
559+
// New format - only ID is stored, need to look up current name
560+
storeId = knowledgeBase.documentStore
561+
const appDataSource = options.appDataSource as DataSource
562+
const databaseEntities = options.databaseEntities as IDatabaseEntity
563+
const store = await appDataSource.getRepository(databaseEntities['DocumentStore']).findOneBy({ id: storeId })
564+
storeName = store?.name || storeId // Fallback to ID if store not found
565+
}
551566

552567
const docStoreVectorInstanceFilePath = options.componentNodes['documentStoreVS'].filePath as string
553568
const docStoreVectorModule = await import(docStoreVectorInstanceFilePath)

packages/components/nodes/agentflow/Retriever/Retriever.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ class Retriever_Agentflow implements INode {
124124
for (const store of stores) {
125125
if (store.status === 'UPSERTED') {
126126
const obj = {
127-
name: `${store.id}:${store.name}`,
128-
label: store.name,
127+
name: store.id, // please store only the ID, not the name
128+
label: store.name, // display the current name
129129
description: store.description
130130
}
131131
returnData.push(obj)
@@ -152,7 +152,16 @@ class Retriever_Agentflow implements INode {
152152
const knowledgeBases = nodeData.inputs?.retrieverKnowledgeDocumentStores as IKnowledgeBase[]
153153
if (knowledgeBases && knowledgeBases.length > 0) {
154154
for (const knowledgeBase of knowledgeBases) {
155-
const [storeId, _] = knowledgeBase.documentStore.split(':')
155+
// Handle both old format (id:name) and new format (id only)
156+
let storeId = knowledgeBase.documentStore
157+
158+
if (knowledgeBase.documentStore.includes(':')) {
159+
// Old format - split to get ID
160+
;[storeId] = knowledgeBase.documentStore.split(':')
161+
} else {
162+
// New format - only ID is stored
163+
storeId = knowledgeBase.documentStore
164+
}
156165

157166
const docStoreVectorInstanceFilePath = options.componentNodes['documentStoreVS'].filePath as string
158167
const docStoreVectorModule = await import(docStoreVectorInstanceFilePath)

0 commit comments

Comments
 (0)