UNPKG

@n8n/n8n-nodes-langchain

Version:
145 lines (140 loc) 4.24 kB
/** * Postgres PGVector Store Node - Version 1 * Discriminator: mode=load */ interface Credentials { postgres: CredentialReference; } /** Get many ranked documents from vector store for query */ export type LcVectorStorePGVectorV1LoadParams = { /** * One-shot similarity search on the main flow using the `prompt` parameter. Declare with `vectorStore({...})`. Required subnodes: `embedding`. For LLM-driven querying (RAG), use `mode: 'retrieve-as-tool'` instead. * <patterns> * <pattern title="load mode — one-shot similarity search (generic)"> * // Substitute the type literal and provider-specific parameters — see the rest of this file. * const lookup = vectorStore({ * type: '@n8n/n8n-nodes-langchain.vectorStoreXxx', * config: { * name: 'Knowledge Base', * parameters: { * mode: 'load', * prompt: expr('{{ $json.query }}'), * // ...provider-specific parameters * }, * subnodes: { embedding: embeddingsOpenAi } * } * }); * </pattern> * </patterns> */ mode: 'load'; /** * The table name to store the vectors in. If table does not exist, it will be created. * @default n8n_vectors */ tableName?: string | Expression<string>; /** * Search prompt to retrieve matching documents from the vector store using similarity-based ranking */ prompt: string | Expression<string>; /** * Number of top results to fetch from vector store * @default 4 */ topK?: number | Expression<number>; /** * Whether or not to include document metadata * @default true */ includeDocumentMetadata?: boolean | Expression<boolean>; /** * Whether or not to rerank results * @default false */ useReranker?: boolean | Expression<boolean>; /** * Options * @default {} */ options?: { /** The method to calculate the distance between two vectors * @default cosine */ distanceStrategy?: 'cosine' | 'innerProduct' | 'euclidean' | Expression<string>; /** Collection of vectors * @default {"values":{"useCollection":false,"collectionName":"n8n","collectionTable":"n8n_vector_collections"}} */ collection?: { /** Collection Settings */ values?: { /** Use Collection * @default false */ useCollection?: boolean | Expression<boolean>; /** Collection Name * @displayOptions.show { useCollection: [true] } * @default n8n */ collectionName?: string | Expression<string>; /** Collection Table Name * @displayOptions.show { useCollection: [true] } * @default n8n_vector_collections */ collectionTableName?: string | Expression<string>; }; }; /** The names of the columns in the PGVector table * @default {"values":{"idColumnName":"id","vectorColumnName":"embedding","contentColumnName":"text","metadataColumnName":"metadata"}} */ columnNames?: { /** Column Name Settings */ values?: { /** ID Column Name * @default id */ idColumnName?: string | Expression<string>; /** Vector Column Name * @default embedding */ vectorColumnName?: string | Expression<string>; /** Content Column Name * @default text */ contentColumnName?: string | Expression<string>; /** Metadata Column Name * @default metadata */ metadataColumnName?: string | Expression<string>; }; }; /** Metadata to filter the document by * @default {} */ metadata?: { /** Fields to Set */ metadataValues?: Array<{ /** Name */ name?: string | Expression<string>; /** Value */ value?: string | Expression<string>; }>; }; }; }; export interface LcVectorStorePGVectorV1LoadSubnodeConfig { embedding: EmbeddingInstance | EmbeddingInstance[]; /** * @displayOptions.show { useReranker: [true] } */ reranker: RerankerInstance; } export type LcVectorStorePGVectorV1LoadNode = { type: '@n8n/n8n-nodes-langchain.vectorStorePGVector'; version: 1; config: NodeConfig<LcVectorStorePGVectorV1LoadParams> & { credentials?: Credentials } & { subnodes: LcVectorStorePGVectorV1LoadSubnodeConfig }; };