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: any): PromiseDescription
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.
Parameters
| Name | Type | Required? | Description |
|---|---|---|---|
params | any | ✓ | The parameters for saving |
Returns
PromiseExamples
// 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.