feat(editor): Use resource locator at Simple Vector Store memory key, allow cross workflow use (#15421)

Remove workflow isolation from in-memory Simple Vector Store, making it possible to use vector stores created on other workflows. Display all current in-memory vector stores with a resource locator at Memory Key picker.

Note that these vector stores are still intended for non-production development use. Any users of an instance can access data in all in-memory vector stores as they aren't bound to workflows.
This commit is contained in:
Jaakko Husso
2025-05-22 23:34:59 +03:00
committed by GitHub
parent a86bc43f50
commit e5c2aea6fe
16 changed files with 392 additions and 36 deletions

View File

@@ -124,6 +124,10 @@ export class MemoryVectorStoreManager {
}
}
getMemoryKeysList(): string[] {
return Array.from(this.vectorStoreBuffer.keys());
}
/**
* Get or create a vector store by key
*/

View File

@@ -246,4 +246,34 @@ describe('MemoryVectorStoreManager', () => {
expect(stats.stores.store1.vectors).toBe(50);
expect(stats.stores.store2.vectors).toBe(30);
});
it('should list all vector stores', async () => {
const embeddings = mock<OpenAIEmbeddings>();
const instance = MemoryVectorStoreManager.getInstance(embeddings, logger);
const mockVectorStore1 = mock<MemoryVectorStore>();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
mockVectorStore1.memoryVectors = new Array(50).fill({
embedding: createTestEmbedding(),
content: 'test1',
metadata: {},
});
const mockVectorStore2 = mock<MemoryVectorStore>();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
mockVectorStore2.memoryVectors = new Array(30).fill({
embedding: createTestEmbedding(),
content: 'test2',
metadata: {},
});
// Mock internal state
instance['vectorStoreBuffer'].set('store1', mockVectorStore1);
instance['vectorStoreBuffer'].set('store2', mockVectorStore2);
const list = instance.getMemoryKeysList();
expect(list).toHaveLength(2);
expect(list[0]).toBe('store1');
expect(list[1]).toBe('store2');
});
});

View File

@@ -253,6 +253,7 @@ exports[`createVectorStoreNode retrieve mode supplies vector store as data 1`] =
"version": [
1,
1.1,
1.2,
],
}
`;

View File

@@ -43,7 +43,8 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
icon: args.meta.icon,
iconColor: args.meta.iconColor,
group: ['transform'],
version: [1, 1.1],
// 1.2 has changes to VectorStoreInMemory node.
version: [1, 1.1, 1.2],
defaults: {
name: args.meta.displayName,
},

View File

@@ -10,6 +10,8 @@ import type {
Icon,
ISupplyDataFunctions,
ThemeIconColor,
IDataObject,
NodeParameterValueType,
} from 'n8n-workflow';
export type NodeOperationMode = 'insert' | 'load' | 'retrieve' | 'update' | 'retrieve-as-tool';
@@ -35,6 +37,12 @@ export interface VectorStoreNodeConstructorArgs<T extends VectorStore = VectorSt
paginationToken?: string,
) => Promise<INodeListSearchResult>;
};
actionHandler?: {
[functionName: string]: (
this: ILoadOptionsFunctions,
payload: IDataObject | string | undefined,
) => Promise<NodeParameterValueType>;
};
};
sharedFields: INodeProperties[];