langchain-retrieval
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLangChain 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_templatebash
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_template2. Remove Git History (Optional)
2. 移除Git历史记录(可选)
bash
rm -rf .git
git initbash
rm -rf .git
git init3. Install Dependencies
3. 安装依赖
bash
pnpm installbash
pnpm install4. Setup Environment Variables
4. 配置环境变量
Create with required variables:
.env- - Supabase project URL
SUPABASE_URL - - Supabase service role key
SUPABASE_PRIVATE_KEY - - For embeddings and LLM
OPENAI_API_KEY - - Direct PostgreSQL connection URL
SUPABASE_DB_URL
创建包含以下必填变量的文件:
.env- - Supabase项目URL
SUPABASE_URL - - Supabase服务角色密钥
SUPABASE_PRIVATE_KEY - - 用于嵌入模型和大语言模型
OPENAI_API_KEY - - PostgreSQL直接连接URL
SUPABASE_DB_URL
5. Setup Vector Store
5. 配置向量存储
Initialize pgvector extension and create documents table in Supabase.
在Supabase中初始化pgvector扩展并创建文档表。
Build
构建
bash
pnpm buildbash
pnpm buildDevelopment
开发
bash
pnpm devbash
pnpm dev