UNPKG

@n8n/n8n-nodes-langchain

Version:
94 lines (89 loc) • 3.63 kB
/** * Redis Vector Store Node - Version 1.4 * Discriminator: mode=load */ interface Credentials { redis: CredentialReference; } /** Get many ranked documents from vector store for query */ export type LcVectorStoreRedisV14LoadParams = { /** * 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'; redisIndex?: { __rl: true; mode: 'list' | 'id'; value: string; cachedResultName?: 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?: { /** Redis query filter expression. Supports Tag, Numeric, Text, Geo filters with AND/OR logic. Example: &lt;code&gt;@category:{electronics} @price:[0 100]&lt;/code&gt; * @hint Learn more about Redis vector search filtering &lt;a target="_blank" href="https://docs.langchain.com/oss/javascript/integrations/vectorstores/redis#advanced-features"&gt;here&lt;/a&gt; */ advancedFilter?: string | Expression<string>; /** JSON array defining metadata field types for indexing. If not provided, schema will be inferred from documents. Example: &lt;code&gt;[{"name": "category", "type": "tag"}, {"name": "price", "type": "numeric", "options": {"sortable": true}}]&lt;/code&gt; * @hint Learn more about metadata schema configuration &lt;a target="_blank" href="https://docs.langchain.com/oss/javascript/integrations/vectorstores/redis#advanced-features"&gt;here&lt;/a&gt; */ metadataSchema?: string | Expression<string>; /** Prefix for Redis keys storing the documents */ keyPrefix?: string | Expression<string>; /** The hash key to be used to store the metadata of the document */ metadataKey?: string | Expression<string>; /** The hash key to be used to store the content of the document */ contentKey?: string | Expression<string>; /** The hash key to be used to store the embedding of the document */ vectorKey?: string | Expression<string>; }; }; export interface LcVectorStoreRedisV14LoadSubnodeConfig { embedding: EmbeddingInstance | EmbeddingInstance[]; /** * @displayOptions.show { useReranker: [true] } */ reranker: RerankerInstance; } export type LcVectorStoreRedisV14LoadNode = { type: '@n8n/n8n-nodes-langchain.vectorStoreRedis'; version: 1.4; config: NodeConfig<LcVectorStoreRedisV14LoadParams> & { credentials?: Credentials } & { subnodes: LcVectorStoreRedisV14LoadSubnodeConfig }; };