---
name: bijection-rag
description: "Evaluate and integrate the RAG component with Bijection."
---

# RAG

Chunking and semantic retrieval

- Package: @bijectionhq/rag
- Category: AI & Agents
- Status: Included
- License: Apache-2.0
- Bijection source (repository access required): https://github.com/bijectionhq/rag/tree/f2395882af1c729f0e6e4aeba13b44d823caecee
- Upstream: https://github.com/convex/rag/tree/8647bdefba28057c2393cc27fc40ad5a1ff820b3
- Documentation: https://docs.bijection.com/components/using
- Directory: https://bijection.com/components/rag

## Get the source

Bijection repository access is required. Request access at https://bijection.com/contact.

```sh
git clone https://github.com/bijectionhq/rag.git
cd rag
git checkout f2395882af1c729f0e6e4aeba13b44d823caecee
```

## Before using this component

Read the package README at the recorded revision for setup, dependencies, and API examples. Upstream documentation describes the original package and may differ from the Bijection adaptation. This source is included in Bijection's workspace. Catalog inclusion does not establish npm availability or runtime qualification. Check compatibility with your SDK and deployment before adoption. External providers run their own compute.

## Integration workflow

1. Read the source README and package manifest at the recorded revision.
2. Confirm the required SDK, dependency availability, and runtime compatibility.
3. Follow the component's documented setup and configuration. Never invent an npm install command from a catalog package name.
4. Keep credentials in the project's existing secret store.
5. Follow the project's execution rules for verification and report what was actually checked.

## Original upstream skill

The following guidance describes @convex-dev/rag. Its installation commands and APIs refer to the upstream package. Evaluate compatibility with the Bijection source separately.


> Agents: read this skill fully before writing code that uses RAG. Follow the installation and configuration steps exactly.

# RAG

## Instructions

A semantic search component that implements Retrieval-Augmented Generation (RAG) for AI applications. It automatically chunks text content, generates embeddings using AI SDK models, and provides vector-based similarity search across namespaced content. Includes features like custom filtering, importance weighting, chunk context expansion, and graceful content migration for production RAG workflows.

### Installation

```bash
npm install @convex-dev/rag
```

Current npm version: `@convex-dev/rag@0.7.8`

## Use cases

- **Building AI chatbots** that need to search through documentation, knowledge bases, or user-specific content to provide contextual responses
- **Creating document Q&A systems** where users upload files and ask questions that require semantic search across the content with proper context
- **Implementing multi-tenant RAG** where different users or organizations need isolated search namespaces with custom filtering by document type, category, or metadata
- **Adding semantic search to existing apps** that need to surface relevant content based on user queries rather than exact keyword matches
- **Building AI agents** that need to retrieve and synthesize information from large content repositories before generating responses

## How it works

The component integrates with your Convex app through the standard component pattern, requiring a `convex.config.ts` setup and creating a RAG instance with your chosen embedding model from AI SDK. Content is added via the `add()` method which automatically chunks text and generates embeddings, organizing everything into namespaces for isolation.

Search operates through the `search()` method which performs vector similarity matching and returns results with configurable score thresholds, chunk context expansion, and custom filtering. The component handles the complexity of embedding generation, vector storage, and result formatting, providing both raw results and formatted text ready for LLM consumption.

For full RAG workflows, the `generateText()` method combines search and LLM generation in one call, automatically retrieving relevant context and formatting it for the language model. The component supports graceful content replacement using keys, allowing you to update documents without disrupting active searches.

## When NOT to use

- When a simpler built-in solution exists for your specific use case
- If you are not using Convex as your backend
- When the functionality provided by RAG is not needed

## Resources

- [npm package](https://www.npmjs.com/package/%40convex-dev%2Frag)
- [GitHub repository](https://github.com/get-convex/rag)
- [Convex Components Directory](https://www.convex.dev/components/rag)
- [Convex documentation](https://docs.convex.dev)