@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
42 lines (41 loc) • 1.97 kB
TypeScript
/**
* RAG Integration for generate() and stream()
*
* Provides automatic RAG pipeline setup when `rag` config is provided
* in GenerateOptions or StreamOptions. Handles file loading, chunking,
* embedding generation, vector storage, and tool creation internally
* so developers only need to pass `rag: { files: [...] }`.
*/
import type { RAGConfig, VectorQueryResult, RAGPreparedTool } from "../types/index.js";
/**
* Generate deterministic embeddings for chunks.
* Combines character-frequency (40%) with word-level hash features (60%)
* for better semantic discrimination than pure character frequency.
* When a real embedding provider is configured, it will be used instead.
*/
declare function generateSimpleEmbedding(text: string, dimension: number): number[];
/**
* Diversify retrieval results via round-robin across source files.
* Ensures at least one chunk per source file appears in the top-K results,
* preventing any single file from dominating retrieval.
*/
declare function diversifyResults(results: VectorQueryResult[], topK: number): VectorQueryResult[];
/**
* Prepare RAG tools from the provided configuration.
*
* This function:
* 1. Loads and reads all specified files
* 2. Chunks them using the configured (or auto-detected) strategy
* 3. Generates embeddings for each chunk
* 4. Stores them in an in-memory vector store
* 5. Creates a tool the AI model can use to search the documents
*
* @param ragConfig - RAG configuration from generate/stream options
* @param fallbackProvider - Provider to use for embeddings if not specified in ragConfig
* @returns Prepared RAG tool to inject into the tools record
*/
export declare function prepareRAGTool(ragConfig: RAGConfig, fallbackProvider?: string): Promise<RAGPreparedTool>;
/** @internal Exported for testing only */
export { generateSimpleEmbedding as _generateSimpleEmbedding };
/** @internal Exported for testing only */
export { diversifyResults as _diversifyResults };