Get Started
Agentic
Agentic RAG with ai-sdk
Installation
npm install ai @ai-sdk/openai @ai-sdk/react agentset @agentset/ai-sdk
Usage
This is an example of how to use the AgenticEngine with the ai-sdk in Nextjs.
import { AgenticEngine } from '@agentset/ai-sdk';
import { llmModel } from '@/lib/llm';
import { Agentset } from 'agentset';
const agentset = new Agentset({
apiKey: process.env.AGENTSET_API_KEY,
});
const ns = agentset.namespace(process.env.AGENTSET_NAMESPACE_ID);
export const POST = async (req: Request) => {
const { messages } = await req.json();
return AgenticEngine(ns, {
messages,
generateQueriesStep: { model: llmModel },
evaluateQueriesStep: { model: llmModel },
answerStep: { model: llmModel },
// maxEvals: 3, (optional, default is 3)
// tokenBudget: 4096, (optional, default is 4096)
// queryOptions: {...}, (optional, default is `{ topK: 50, rerankLimit: 15, rerank: true }`)
});
};
On this page
Assistant
Responses are generated using AI and may contain mistakes.