The list-and-close lesson closed the in-memory handle for a workspace without touching the data. This one drops the workspace and its on-disk files in one call.
ragCloseWorkspace({ workspace, deleteOnClose: true }) releases the in-memory handle and removes the on-disk folder in a single pass. The flag is the only thing that flips the call from "close" to "delete":
await ragCloseWorkspace({ workspace, deleteOnClose: true });The setup is the same as the other RAG lessons: a named workspace, an ingest to give it content, then the teardown. Right call for "throw away the index and start over":
const workspace = "delete-workspace-demo";
const samples = [
"A temporary workspace holds documents we want to remove in one go.",
];
const modelId = await loadModel({ modelSrc: GTE_LARGE_FP16 });
await ragIngest({ modelId, workspace, documents: samples, chunk: false });
console.log(`▸ Created workspace '${workspace}' with ${samples.length} document`);
await ragCloseWorkspace({ workspace, deleteOnClose: true });
console.log(`▸ Deleted workspace '${workspace}' and its on-disk files`);
await unloadModel({ modelId });After the call returns, the workspace is gone. The next ragIngest against the same name starts fresh; the next ragSearch returns "workspace not found" instead of empty results.
Note:
deleteOnClose: trueis the destructive flag. Omit it and the sameragCloseWorkspacecall only releases the in-memory handle, leaving the on-disk data intact for the nextragOpen(when one is available).
ragIngest to add a few documents to a named workspace, then log the workspace name and document count.ragCloseWorkspace({ workspace, deleteOnClose: true }) and log the deletion.$ Run your code to see results
$