QVAC Logo

ragIngest( )

Ingests documents into the RAG vector database.

function ragIngest(params): Promise<{ processed: RagSaveEmbeddingsResult[]; droppedIndices: number[] }>;

Full pipeline: chunk → embed → save. Implicitly opens (or creates) the workspace.

Parameters

NameTypeRequired?DefaultDescription
params.modelIdstringThe embedding model identifier
params.documentsstring | string[]Documents to ingest
params.chunkbooleantrueWhether to chunk documents before embedding
params.chunkOptsChunkOptionsChunking options
params.workspacestring"default"Workspace for isolated storage. Created if it doesn't exist.
params.onProgress(stage, current, total) => voidProgress callback
params.progressIntervalnumberMinimum interval between progress updates in ms

Returns

FieldTypeDescription
processedRagSaveEmbeddingsResult[]Array of { status: "fulfilled" | "rejected", id?, error? }
droppedIndicesnumber[]Indices of documents that were dropped

Throws

ErrorWhen
RAG_SAVE_FAILEDThe ingestion operation fails
STREAM_ENDED_WITHOUT_RESPONSEStreaming ends unexpectedly (when using onProgress)

Example

const result = await ragIngest({
  modelId,
  documents: ["Document 1", "Document 2"],
  workspace: "my-docs",
  onProgress: (stage, current, total) => {
    console.log(`[${stage}] ${current}/${total}`);
  },
});

On this page