@n8n/n8n-nodes-langchain
Version:
136 lines (131 loc) • 4.15 kB
text/typescript
/**
* Postgres PGVector Store Node - Version 1
* Discriminator: mode=retrieve
*/
interface Credentials {
postgres: CredentialReference;
}
/** Retrieve documents from vector store to be used as vector store with AI nodes */
export type LcVectorStorePGVectorV1RetrieveParams = {
/**
* Exposes the store as an `ai_vectorStore` subnode for another node (e.g. `toolVectorStore`). Declare with `vectorStore({...})`. Required subnodes: `embedding`. For RAG with an AI Agent directly, prefer `mode: 'retrieve-as-tool'`.
* <patterns>
* <pattern title="retrieve mode — feed another node as a subnode (generic)">
* // Substitute the type literal and provider-specific parameters — see the rest of this file.
* const store = vectorStore({
* type: '@n8n/n8n-nodes-langchain.vectorStoreXxx',
* config: {
* name: 'Knowledge Base',
* parameters: { mode: 'retrieve' /* + provider-specific parameters *\/ },
* subnodes: { embedding: embeddingsOpenAi }
* }
* });
*
* const retrieverTool = tool({
* type: '@n8n/n8n-nodes-langchain.toolVectorStore',
* config: {
* name: 'KB Retriever',
* parameters: { description: 'Search the product knowledge base' },
* subnodes: { vectorStore: store, model: openAiModel }
* }
* });
* </pattern>
* </patterns>
*/
mode: 'retrieve';
/**
* The table name to store the vectors in. If table does not exist, it will be created.
* @default n8n_vectors
*/
tableName?: string | Expression<string>;
/**
* 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 LcVectorStorePGVectorV1RetrieveSubnodeConfig {
embedding: EmbeddingInstance | EmbeddingInstance[];
/**
* @displayOptions.show { useReranker: [true] }
*/
reranker: RerankerInstance;
}
export type LcVectorStorePGVectorV1RetrieveNode = {
type: '@n8n/n8n-nodes-langchain.vectorStorePGVector';
version: 1;
config: NodeConfig<LcVectorStorePGVectorV1RetrieveParams> & { credentials?: Credentials } & { subnodes: LcVectorStorePGVectorV1RetrieveSubnodeConfig };
};