@n8n/n8n-nodes-langchain
Version:
105 lines (100 loc) • 3.5 kB
text/typescript
/**
* MongoDB Atlas Vector Store Node - Version 1
* Discriminator: mode=retrieve
*/
interface Credentials {
mongoDb: CredentialReference;
}
/** Retrieve documents from vector store to be used as vector store with AI nodes */
export type LcVectorStoreMongoDBAtlasV1RetrieveParams = {
/**
* 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';
mongoCollection?: { __rl: true; mode: 'list' | 'name'; value: string; cachedResultName?: string };
/**
* The field with the embedding array
* @default embedding
*/
embedding?: string | Expression<string>;
/**
* The text field of the raw data
* @default text
*/
metadata_field?: string | Expression<string>;
/**
* The name of the vector index
*/
vectorIndexName: string | Expression<string>;
/**
* Whether or not to rerank results
* @default false
*/
useReranker?: boolean | Expression<boolean>;
/**
* Options
* @default {}
*/
options?: {
/** Logical partition for documents. Uses metadata.namespace field for filtering.
*/
namespace?: 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>;
}>;
};
/** MongoDB Atlas Vector Search pre-filter
* @hint This is a filter applied in the $vectorSearch stage <a href="https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#atlas-vector-search-pre-filter">here</a>
*/
preFilter?: IDataObject | string | Expression<string>;
/** MongoDB aggregation pipeline in JSON format
* @hint Learn more about aggregation pipeline <a href="https://docs.mongodb.com/manual/core/aggregation-pipeline/">here</a>
*/
postFilterPipeline?: IDataObject | string | Expression<string>;
};
};
export interface LcVectorStoreMongoDBAtlasV1RetrieveSubnodeConfig {
embedding: EmbeddingInstance | EmbeddingInstance[];
/**
* @displayOptions.show { useReranker: [true] }
*/
reranker: RerankerInstance;
}
export type LcVectorStoreMongoDBAtlasV1RetrieveNode = {
type: '@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas';
version: 1;
config: NodeConfig<LcVectorStoreMongoDBAtlasV1RetrieveParams> & { credentials?: Credentials } & { subnodes: LcVectorStoreMongoDBAtlasV1RetrieveSubnodeConfig };
};