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.
| Name | Type | Required? | Default | Description |
|---|
| params.modelId | string | ✓ | — | The embedding model identifier |
| params.documents | string | string[] | ✓ | — | Documents to ingest |
| params.chunk | boolean | ✗ | true | Whether to chunk documents before embedding |
| params.chunkOpts | ChunkOptions | ✗ | — | Chunking options |
| params.workspace | string | ✗ | "default" | Workspace for isolated storage. Created if it doesn't exist. |
| params.onProgress | (stage, current, total) => void | ✗ | — | Progress callback |
| params.progressInterval | number | ✗ | — | Minimum interval between progress updates in ms |
| Field | Type | Description |
|---|
| processed | RagSaveEmbeddingsResult[] | Array of { status: "fulfilled" | "rejected", id?, error? } |
| droppedIndices | number[] | Indices of documents that were dropped |
| Error | When |
|---|
RAG_SAVE_FAILED | The ingestion operation fails |
STREAM_ENDED_WITHOUT_RESPONSE | Streaming ends unexpectedly (when using onProgress) |
const result = await ragIngest({
modelId,
documents: ["Document 1", "Document 2"],
workspace: "my-docs",
onProgress: (stage, current, total) => {
console.log(`[${stage}] ${current}/${total}`);
},
});