langchain-retrieval

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LangChain Retrieval

LangChain Retrieval

Document Q&A with RAG (Retrieval Augmented Generation) using Supabase vector store.
使用Supabase向量存储实现基于RAG(检索增强生成)的文档问答系统。

Tech Stack

技术栈

  • Framework: Next.js
  • AI: LangChain.js, AI SDK
  • Vector Store: Supabase pgvector
  • Package Manager: pnpm
  • Framework: Next.js
  • AI: LangChain.js, AI SDK
  • Vector Store: Supabase pgvector
  • Package Manager: pnpm

Prerequisites

前提条件

  • Supabase project with pgvector extension
  • OpenAI API key
  • 已安装pgvector扩展的Supabase项目
  • OpenAI API密钥

Setup

安装配置

1. Clone the Template

1. 克隆模板

bash
git clone --depth 1 https://github.com/Eng0AI/langchain-retrieval.git .
If the directory is not empty:
bash
git clone --depth 1 https://github.com/Eng0AI/langchain-retrieval.git _temp_template
mv _temp_template/* _temp_template/.* . 2>/dev/null || true
rm -rf _temp_template
bash
git clone --depth 1 https://github.com/Eng0AI/langchain-retrieval.git .
如果目标目录非空:
bash
git clone --depth 1 https://github.com/Eng0AI/langchain-retrieval.git _temp_template
mv _temp_template/* _temp_template/.* . 2>/dev/null || true
rm -rf _temp_template

2. Remove Git History (Optional)

2. 移除Git历史记录(可选)

bash
rm -rf .git
git init
bash
rm -rf .git
git init

3. Install Dependencies

3. 安装依赖

bash
pnpm install
bash
pnpm install

4. Setup Environment Variables

4. 配置环境变量

Create
.env
with required variables:
  • SUPABASE_URL
    - Supabase project URL
  • SUPABASE_PRIVATE_KEY
    - Supabase service role key
  • OPENAI_API_KEY
    - For embeddings and LLM
  • SUPABASE_DB_URL
    - Direct PostgreSQL connection URL
创建包含以下必填变量的
.env
文件:
  • SUPABASE_URL
    - Supabase项目URL
  • SUPABASE_PRIVATE_KEY
    - Supabase服务角色密钥
  • OPENAI_API_KEY
    - 用于嵌入模型和大语言模型
  • SUPABASE_DB_URL
    - PostgreSQL直接连接URL

5. Setup Vector Store

5. 配置向量存储

Initialize pgvector extension and create documents table in Supabase.
在Supabase中初始化pgvector扩展并创建文档表。

Build

构建

bash
pnpm build
bash
pnpm build

Development

开发

bash
pnpm dev
bash
pnpm dev