@n8n/n8n-nodes-langchain
Version:
85 lines (80 loc) • 3.53 kB
text/typescript
/**
* Redis Vector Store Node - Version 1.4
* Discriminator: mode=retrieve
*/
interface Credentials {
redis: CredentialReference;
}
/** Retrieve documents from vector store to be used as vector store with AI nodes */
export type LcVectorStoreRedisV14RetrieveParams = {
/**
* 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';
redisIndex?: { __rl: true; mode: 'list' | 'id'; value: string; cachedResultName?: string };
/**
* 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: <code>@category:{electronics} @price:[0 100]</code>
* @hint Learn more about Redis vector search filtering <a target="_blank" href="https://docs.langchain.com/oss/javascript/integrations/vectorstores/redis#advanced-features">here</a>
*/
advancedFilter?: string | Expression<string>;
/** JSON array defining metadata field types for indexing. If not provided, schema will be inferred from documents. Example: <code>[{"name": "category", "type": "tag"}, {"name": "price", "type": "numeric", "options": {"sortable": true}}]</code>
* @hint Learn more about metadata schema configuration <a target="_blank" href="https://docs.langchain.com/oss/javascript/integrations/vectorstores/redis#advanced-features">here</a>
*/
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 LcVectorStoreRedisV14RetrieveSubnodeConfig {
embedding: EmbeddingInstance | EmbeddingInstance[];
/**
* @displayOptions.show { useReranker: [true] }
*/
reranker: RerankerInstance;
}
export type LcVectorStoreRedisV14RetrieveNode = {
type: '@n8n/n8n-nodes-langchain.vectorStoreRedis';
version: 1.4;
config: NodeConfig<LcVectorStoreRedisV14RetrieveParams> & { credentials?: Credentials } & { subnodes: LcVectorStoreRedisV14RetrieveSubnodeConfig };
};