UNPKG

@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

46 lines (45 loc) 2.12 kB
/** * File Summarization Service * * Orchestrates the end-to-end file summarization pipeline: * 1. Accept raw file inputs (strings or Buffers) * 2. Extract readable text and estimate tokens * 3. Use `planFileSummarization()` to decide which files to summarize * 4. Call an LLM to produce context-aware summaries of the largest files * 5. Fall back to truncation when the LLM call fails * * The LLM is instantiated via a *dynamic import* of NeuroLink to avoid * circular dependency issues (NeuroLink → fileSummarizationService → NeuroLink). */ import type { FileForSummarization, FileSummarizationCheckParams, FileSummarizationServiceOptions, RawFileInput, SummarizedFile } from "../types/index.js"; export declare class FileSummarizationService { private readonly provider; private readonly model; constructor(options?: FileSummarizationServiceOptions); /** * Extract readable text from a file's content. * * - Strings are returned as-is. * - Buffers are decoded as UTF-8 when the MIME type is textual. * - Known-binary types (image/*, audio/*, video/*) return a placeholder. */ extractFileText(content: string | Buffer, mimeType: string, fileName: string): string; /** * Map a MIME type (and filename for fallback) to a human-readable label. */ getFileTypeLabel(mimeType: string, fileName: string): string; /** * Convert an array of raw file inputs into `FileForSummarization` objects. * * Extracts text and estimates token count for each file. */ prepareFilesForSummarization(files: RawFileInput[], provider?: string): FileForSummarization[]; /** * Summarize files that exceed the context budget. * * For each file marked "summarize" by `planFileSummarization()`, we call * the configured LLM to produce a context-aware summary. If the LLM call * fails, we fall back to naive truncation so the request can still proceed. */ summarizeFiles(files: FileForSummarization[], userPrompt: string, budgetParams: FileSummarizationCheckParams): Promise<SummarizedFile[]>; }