@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
31 lines (30 loc) • 1.45 kB
TypeScript
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>;
export {};