ragSearch( )
Searches for similar documents in the RAG vector database.
function ragSearch(params): Promise<RagSearchResult[]>;
| Name | Type | Required? | Default | Description |
|---|
| params.modelId | string | ✓ | — | The embedding model identifier |
| params.query | string | ✓ | — | The search query text |
| params.topK | number | ✗ | 5 | Number of top results to retrieve |
| params.n | number | ✗ | 3 | Number of centroids for IVF index search |
| params.workspace | string | ✗ | "default" | Workspace to search in |
Promise<RagSearchResult[]> — Array of search results. Empty array if workspace doesn't exist.
| Field | Type | Description |
|---|
| id | string | Document identifier |
| content | string | Document text content |
| score | number | Similarity score |
| Error | When |
|---|
RAG_SEARCH_FAILED | The search operation fails |
const results = await ragSearch({
modelId,
query: "AI and machine learning",
topK: 5,
workspace: "my-docs",
});