ragSaveEmbeddings( )
Saves pre-embedded documents to the RAG vector database. Part of the segregated flow: chunk() → embed() → saveEmbeddings() **Workspace lifecycle:** This operation implicitly opens (or creates) the workspace. The workspace remains open until closed.
function ragSaveEmbeddings(params: RagSaveEmbeddingsParams, options?: { forceNewConnection?: boolean; profiling?: { enabled?: boolean; includeServerBreakdown?: boolean; mode?: "summary" | "verbose" }; timeout?: number }): PromiseParameters
| Name | Type | Required? | Description |
|---|---|---|---|
params | RagSaveEmbeddingsParams | ✓ | The parameters for saving |
options | `{ forceNewConnection?: boolean; profiling?: { enabled?: boolean; includeServerBreakdown?: boolean; mode?: "summary" | "verbose" }; timeout?: number }` | ✗ |
Returns
PromiseThrows
| Error | When |
|---|---|
When the operation fails | |
When streaming ends unexpectedly (only when using onProgress) |
Example
// Segregated flow
const chunks = await ragChunk({ documents: ["text1", "text2"] });
const embeddings = await embed({ modelId, text: chunks.map(c => c.content) });
const embeddedDocs = chunks.map((chunk, i) => ({
...chunk,
embedding: embeddings[i],
embeddingModelId: modelId,
}));
const result = await ragSaveEmbeddings({
documents: embeddedDocs,
workspace: "my-workspace",
});ragReindex( )
Reindexes the RAG database to optimize search performance. For HyperDB, this rebalances centroids using k-means clustering. **Workspace lifecycle:** This operation requires an existing workspace. **Note:** Reindex requires a minimum number of documents to perform clustering. For HyperDB, this is 16 documents by default. If there are insufficient documents, `reindexed` will be `false` with `details` explaining the reason.
ragSearch( )
Searches for similar documents in the RAG vector database. **Workspace lifecycle:** This operation requires an existing workspace. If the workspace doesn't exist, returns an empty array.