mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
refactor: move out metadata
This commit is contained in:
parent
13efb7fcce
commit
425d449445
|
@ -217,6 +217,13 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Include Metadata',
|
||||||
|
name: 'includeDocumentMetadata',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description: 'Whether or not to include document metadata',
|
||||||
|
},
|
||||||
// ID is always used for update operation
|
// ID is always used for update operation
|
||||||
{
|
{
|
||||||
displayName: 'ID',
|
displayName: 'ID',
|
||||||
|
@ -269,11 +276,16 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
topK,
|
topK,
|
||||||
filter,
|
filter,
|
||||||
);
|
);
|
||||||
|
const includeDocumentMetadata = this.getNodeParameter(
|
||||||
|
'includeDocumentMetadata',
|
||||||
|
itemIndex,
|
||||||
|
true,
|
||||||
|
) as boolean;
|
||||||
|
|
||||||
const serializedDocs = docs.map(([doc, score]) => {
|
const serializedDocs = docs.map(([doc, score]) => {
|
||||||
const document = {
|
const document = {
|
||||||
metadata: doc.metadata,
|
|
||||||
pageContent: doc.pageContent,
|
pageContent: doc.pageContent,
|
||||||
|
...(includeDocumentMetadata ? { metadata: doc.metadata } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -409,7 +421,7 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
const includeDocumentMetadata = this.getNodeParameter(
|
const includeDocumentMetadata = this.getNodeParameter(
|
||||||
'includeDocumentMetadata',
|
'includeDocumentMetadata',
|
||||||
itemIndex,
|
itemIndex,
|
||||||
false,
|
true,
|
||||||
) as boolean;
|
) as boolean;
|
||||||
|
|
||||||
const vectorStoreTool = new DynamicTool({
|
const vectorStoreTool = new DynamicTool({
|
||||||
|
@ -484,17 +496,6 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
// default: 'auto',
|
// default: 'auto',
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// todo move out
|
|
||||||
const metadataProp: INodeProperties = {
|
|
||||||
displayName: 'Include Metadata',
|
|
||||||
name: 'includeDocumentMetadata',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
description: 'Whether or not to include document metadata',
|
|
||||||
};
|
|
||||||
|
|
||||||
description.properties.unshift(metadataProp);
|
|
||||||
|
|
||||||
const descProp: INodeProperties = {
|
const descProp: INodeProperties = {
|
||||||
displayName: 'Description',
|
displayName: 'Description',
|
||||||
name: 'toolDescription',
|
name: 'toolDescription',
|
||||||
|
|
Loading…
Reference in a new issue