一个企业级 FastAPI 后端,用于具有会话记忆和检索增强生成的对话式 AI 聊天机器人,支持 PDF 文件、LangChain 和 ChromaDB 向量搜索,并提供来源引用。

Stars

35

7 天增长

暂无数据

Fork 数

0

开放 Issue

0

开源协议

暂无数据

最近更新

2026-07-27

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它提供了一个即用型 RAG 聊天机器人后端,具备记忆和向量搜索功能,结构易于扩展(认证、流式、工具),并包含从 PDF 摄取到 API 端点的清晰设置流程。

适合谁使用

  • 构建基于文档问答的 AI 聊天机器人的开发者
  • 寻找 FastAPI + LangChain RAG 系统启动模板的团队
  • 探索向量数据库与 LLM 记忆的工程师
  • 需要极简但可扩展的对话式 AI 后端的原型设计人员

典型使用场景

  • 从公司手册(PDF)中回答问题的客户支持聊天机器人
  • 基于会话历史会话的内部知识库助手
  • 从教科书中检索并引用特定页面的教育工具
  • 快速构建带有流式支持的文档问答系统原型

项目优势

  • 清晰的逐步设置流程:虚拟环境、依赖安装、PDF 摄取和服务器启动
  • 模块化文件夹结构(auth、memory、rag、tools、analytics、streaming)便于扩展
  • 内置来源引用,提升答案的透明度和可信度
  • 使用成熟组件:FastAPI 提供 API、LangChain 编排、ChromaDB 向量搜索

使用前须知

  • 需要 OpenAI API 密钥,限制为 OpenAI 模型并产生使用成本
  • ChromaDB 为单节点,大规模生产部署可能需要替换
  • 仅提供后端 API(含 Swagger 文档),无前端界面
  • 安全功能(auth 文件夹)未详细说明,可能仅为基础或占位

README 快速开始

🧠 AI RAG Chatbot Backend

Memory • Retrieval-Augmented Generation (RAG) • FastAPI • LangChain • Vector DB


📌 Project Overview

This project implements an enterprise-grade backend for a Conversational AI Chatbot using FastAPI and LangChain.

The chatbot supports:

  • ✅ Session-based conversational memory
  • ✅ Retrieval Augmented Generation (RAG) using PDFs
  • ✅ Vector search using ChromaDB
  • ✅ Source citations with answers
  • ✅ Extensible architecture (Auth, Streaming, Tools ready)

🏗️ Architecture

Client → FastAPI → LangChain (Memory + RAG) → ChromaDB → Documents


🧰 Tech Stack

  • FastAPI
  • LangChain (classic + openai)
  • OpenAI
  • ChromaDB
  • PyPDF
  • Uvicorn
  • Python 3.10+

📁 Folder Structure

ai_rag_chatbot_backend/
├── app.py
├── config.py
├── database.py
├── models.py
├── auth/
├── memory/
├── rag/
├── tools/
├── analytics/
├── streaming/
├── utils/
├── data/
├── vectorstore/
├── .env
└── README.md

🔐 Environment Variables

Create a .env file:

OPENAI_API_KEY=your_openai_api_key_here
CHROMA_PERSIST_DIR=vectorstore

▶️ Step-by-Step Setup

1️⃣ Create Virtual Environment

python -m venv venv
venv\Scripts\activate

2️⃣ Install Dependencies

pip install fastapi uvicorn pydantic python-dotenv langchain langchain-classic langchain-openai langchain-community chromadb pypdf

3️⃣ Add PDFs

Place PDFs inside:

data/

4️⃣ Ingest Documents

python rag/ingest.py

5️⃣ Run Server

uvicorn app:app --reload

Open:

http://127.0.0.1:8000/docs

🧪 Test API

POST /chat

{
  "message": "What is RAG?",
  "session_id": "test-1",
  "memory_type": "buffer"
}

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

slvDev
精选
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI 与机器学习大语言模型
1,960
gavamedia
精选
gavamedia GitHub avatar

deltafin

Deltafin is a research project that runs the 2.8-trillion-parameter Mixture-of-Experts model Kimi K3 on a single Apple Silicon Mac (e.g., M1 Max with 64 GB) at about 16 seconds per token, using exact, reproducible inference with local or streaming expert loading.

AI 与机器学习大语言模型
304
jamesob
精选
jamesob GitHub avatar

local-llm

A comprehensive guide for building and configuring a high-end local machine to run state-of-the-art LLMs, with detailed hardware choices, BIOS tuning, and Docker-based model serving.

AI 与机器学习大语言模型
1,660