Documentation Index
Fetch the complete documentation index at: https://docs.agentset.ai/llms.txt
Use this file to discover all available pages before exploring further.
Search your namespace to retrieve relevant chunks from your documents. Agentset uses semantic and keyword search to return the most relevant results.
Basic search
Pass a query string to search your namespace and retrieve chunks.
import { Agentset } from "agentset";
const agentset = new Agentset({
apiKey: process.env.AGENTSET_API_KEY,
});
const ns = agentset.namespace("YOUR_NAMESPACE_ID");
const results = await ns.search("What is machine learning?");
for (const result of results) {
console.log(result.text);
}
Limiting results
Control the number of results returned with topK. The default is 10, with a maximum of 100.
const results = await ns.search("quarterly revenue", {
topK: 20,
});
Reranking
Agentset reranks results by default using a cross-encoder model to improve relevance. You can adjust reranking behavior or disable it.
const results = await ns.search("product roadmap", {
topK: 50,
rerank: true,
rerankLimit: 10,
});
| Parameter | Default | Description |
|---|
rerank | true | Enable or disable reranking |
rerankLimit | Same as topK | Number of results to return after reranking |
rerankModel | cohere:rerank-v3.5 | Model used for reranking |
Available rerank models
| Model | Description |
|---|
cohere:rerank-v3.5 | Latest Cohere reranker (default) |
cohere:rerank-english-v3.0 | English-optimized Cohere reranker |
cohere:rerank-multilingual-v3.0 | Multilingual Cohere reranker |
zeroentropy:zerank-1 | ZeroEntropy reranker |
zeroentropy:zerank-1-small | Smaller, faster ZeroEntropy reranker |
Minimum score threshold
Filter out low-relevance results by setting a minimum score.
const results = await ns.search("API documentation", {
minScore: 0.7,
});
Search modes
Agentset supports two search modes.
const results = await ns.search("error code 500", {
mode: "keyword",
});
| Mode | Description |
|---|
semantic | Uses embeddings to find semantically similar content (default) |
keyword | Traditional keyword-based search |
Response structure
Each result includes an ID, relevance score, and text content. Metadata is included by default.
{
"success": true,
"data": [
{
"id": "chunk_abc123",
"score": 0.92,
"text": "Machine learning is a subset of artificial intelligence...",
"metadata": {
"filename": "ml-guide.pdf",
"filetype": "application/pdf",
"file_directory": "/documents"
}
}
]
}
const results = await ns.search("user authentication", {
includeMetadata: false,
});
Next steps