This template provides an Internal Knowledge Base, a retrieval-augmented generation (RAG) Next.js chatbot. It leverages the Vercel AI SDK's Language Model Middleware to perform advanced RAG and enforce guardrails, ensuring responses are accurate and controlled. Built with Next.js, this solution offers a robust foundation for creating intelligent chatbots that can interact with your internal documentation or data.
Key Features:
- Retrieval-Augmented Generation (RAG): Enhances chatbot responses by retrieving relevant information from a knowledge base before generating a reply, leading to more informed and contextually accurate answers.
- AI SDK Language Model Middleware: Utilizes the AI SDK's powerful middleware interface for seamless integration with various language models and for implementing custom logic like guardrails.
- Guardrails Enforcement: Ensures that the chatbot adheres to predefined rules and guidelines, preventing the generation of inappropriate or off-topic content.
- Next.js Framework: Built on Next.js, providing benefits like server-side rendering, static site generation, and API routes for a performant and scalable application.
- Easy Deployment: Designed for quick deployment on Vercel, simplifying the process of getting your knowledge base online.
Use Cases:
- Internal Company Knowledge Base: Provide employees with an intelligent assistant to quickly find answers to questions about company policies, procedures, or project documentation.
- Customer Support Chatbot: Offer instant support to customers by allowing them to query a knowledge base for product information, troubleshooting steps, or FAQs.
- Educational Platforms: Create interactive learning tools where students can ask questions and receive detailed explanations based on course materials.
- Developer Documentation Assistant: Help developers navigate complex documentation by providing quick, context-aware answers to their coding queries.
How to Use:
To get started with this template, you can bootstrap it using create-next-app with npm, Yarn, or pnpm:
npx create-next-app --example https://github.com/vercel-labs/ai-sdk-preview-internal-knowledge-base ai-sdk-preview-internal-knowledge-base-example
# or
yarn create next-app --example https://github.com/vercel-labs/ai-sdk-preview-internal-knowledge-base ai-sdk-preview-internal-knowledge-base-example
# or
pnpm create next-app --example https://github.com/vercel-labs/ai-sdk-preview-internal-knowledge-base ai-sdk-preview-internal-knowledge-base-exampleTo run the example locally, you will need to:
- Sign up for accounts with the AI providers you want to use (e.g., OpenAI, Anthropic).
- Obtain API keys for each provider.
- Set the required environment variables (e.g.,
OPENAI_API_KEY,AUTH_SECRET) in a new file named.env, based on the.env.example. - Install dependencies using
npm install. - Launch the development server with
npm run dev.
This template is an excellent starting point for building powerful, AI-driven applications that require intelligent information retrieval and controlled content generation.





