Langchain-Chatchat is a free, open source ai interaction & interfaces project written in Python and released under Apache-2.0. It has 38,641 GitHub stars, 6,263 forks and 26 open issues, and was last pushed 10 months ago. On this registry it ranks #13 of 76 tracked projects in AI Interaction & Interfaces, with 5 head-to-head comparisons available. It gained 5 stars over the last 3 tracked days.

What is Langchain-Chatchat?

What it is

Langchain-Chatchat (formerly Langchain-ChatGLM) is an open-source RAG and Agent application built on the Langchain framework and designed to run against local large language models such as ChatGLM, Qwen, and Llama. It lives in the Python ecosystem, is distributed under the Apache-2.0 license, and is published on PyPI as langchain-chatchat. The project targets Chinese-language scenarios and open-source models specifically, with the stated goal of providing a knowledge-base question-answering solution that can run entirely offline.

The concrete problem it solves is retrieval-augmented generation over private documents without sending data to a hosted API. The pipeline loads files, reads text, splits it, vectorizes chunks and the incoming question, matches the top-k most similar vectors, and injects the matched text as context into the prompt before the LLM generates an answer. This lets an operator point a local model at an internal corpus and get grounded answers, rather than relying on a model's parametric memory or a third-party service.

Key capabilities

  • Retrieval-augmented generation over a local knowledge base, with the full load, split, embed, match, and prompt pipeline implemented in Langchain.
  • Agent application support alongside the RAG workflow, as stated in the project description.
  • Model access through Xinference and Ollama, covering GLM-4-Chat, Qwen2-Instruct, and Llama3.
  • A model_provider abstraction for local models and oneapi for online models, introduced in the 0.3.x line.
  • FastAPI-based API service for programmatic calls and a Streamlit WebUI for interactive use.
  • Support for mainstream open-source LLM, embedding, and vector database backends, with FAISS listed among the project topics.
  • Optional OpenAI GPT API calls in addition to the fully local path.

Who uses it and how

  • Teams that need an internal document question-answering system deployed on private infrastructure, using only open-source models.
  • Chinese-language deployments, since the project explicitly optimizes for Chinese scenarios and open-source model support.
  • Operators who want to swap model backends, using Xinference or Ollama to serve GLM-4-Chat, Qwen2-Instruct, or Llama3 behind the same application.
  • Developers who need an HTTP interface, calling the FastAPI service rather than the Streamlit UI.
  • Users who prefer a prebuilt environment, via the AutoDL image whose 0.3.0 version tracks the project's v0.3.0 release.

Getting started

The README documents three deployment paths: pip installation, source or development installation, and Docker deployment, with Python 3.8 through 3.11 supported. An AutoDL image for version 0.3.0 is available, and a Docker image update is noted as forthcoming.

When to use it — and when not to

project readme (upstream, from github) — read inline

chatchat-space%2FLangchain-Chatchat | Trendshift

pypi badge Generic badge zread

🌍 READ THIS IN ENGLISH

📃 LangChain-Chatchat (原 Langchain-ChatGLM)

基于 ChatGLM 等大语言模型与 Langchain 等应用框架实现,开源、可离线部署的 RAG 与 Agent 应用项目。


目录

概述

🤖️ 一种利用 langchain 思想实现的基于本地知识库的问答应用,目标期望建立一套对中文场景与开源模型支持友好、可离线运行的知识库问答解决方案。

💡 受 GanymedeNil 的项目 document.aiAlexZhangji 创建的 ChatGLM-6B Pull Request 启发,建立了全流程可使用开源模型实现的本地知识库问答应用。本项目的最新版本中可使用 XinferenceOllama 等框架接入 GLM-4-ChatQwen2-InstructLlama3 等模型,依托于 langchain 框架支持通过基于 FastAPI 提供的 API 调用服务,或使用基于 Streamlit 的 WebUI 进行操作。

✅ 本项目支持市面上主流的开源 LLM、 Embedding 模型与向量数据库,可实现全部使用开源模型离线私有部署。与此同时,本项目也支持 OpenAI GPT API 的调用,并将在后续持续扩充对各类模型及模型 API 的接入。

⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 -> 在文本向量中匹配出与问句向量最相似的 top k个 -> 匹配出的文本作为上下文和问题一起添加到 prompt中 -> 提交给 LLM生成回答。

📺 原理介绍视频

实现原理图

从文档处理角度来看,实现流程如下:

实现原理图2

🚩 本项目未涉及微调、训练过程,但可利用微调或训练对本项目效果进行优化。

🌐 AutoDL 镜像0.3.0 版本所使用代码已更新至本项目 v0.3.0 版本。

🐳 Docker 镜像将会在近期更新。

🧑‍💻 如果你想对本项目做出贡献,欢迎移步开发指南 获取更多开发部署相关信息。

功能介绍

0.3.x 版本功能一览

功能 0.2.x 0.3.x
模型接入 本地:fastchat
在线:XXXModelWorker
本地:model_provider,支持大部分主流模型加载框架
在线:oneapi
所有模型接入均兼容openai sdk
Agent ❌不稳定 ✅针对ChatGLM3和Qwen进行优化,Agent能力显著提升
LLM对话
知识库对话
搜索引擎对话
文件对话 ✅仅向量检索 ✅统一为File RAG功能,支持BM25+KNN等多种检索方式
数据库对话
多模态图片对话 ✅ 推荐使用 qwen-vl-chat
ARXIV文献对话
Wolfram对话
文生图
本地知识库管理
WEBUI ✅更好的多会话支持,自定义系统提示词...

0.3.x 版本的核心功能由 Agent 实现,但用户也可以手动实现工具调用:

操作方式 实现的功能 适用场景
选中"启用Agent",选择多个工具 由LLM自动进行工具调用 使用ChatGLM3/Qwen或在线API等具备Agent能力的模型
选中"启用Agent",选择单个工具 LLM仅解析工具参数 使用的模型Agent能力一般,不能很好的选择工具
想手动选择功能
不选中"启用Agent",选择单个工具 不使用Agent功能的情况下,手动填入参数进行工具调用 使用的模型不具备Agent能力
不选中任何工具,上传一个图片 图片对话 使用 qwen-vl-chat 等多模态模型

更多功能和更新请实际部署体验.

已支持的模型部署框架与模型

本项目中已经支持市面上主流的如 GLM-4-ChatQwen2-Instruct 等新近开源大语言模型和 Embedding 模型,这些模型需要用户自行启动模型部署框架后,通过修改配置信息接入项目,本项目已支持的本地模型部署框架如下:

模型部署框架 Xinference LocalAI Ollama FastChat
OpenAI API 接口对齐
加速推理引擎 GPTQ, GGML, vLLM, TensorRT, mlx GPTQ, GGML, vLLM, TensorRT GGUF, GGML vLLM
接入模型类型 LLM, Embedding, Rerank, Text-to-Image, Vision, Audio LLM, Embedding, Rerank, Text-to-Image, Vision, Audio LLM, Text-to-Image, Vision LLM, Vision
Function Call /
更多平台支持(CPU, Metal)
异构

readme truncated — read the full docs on github

Frequently asked questions

Is Langchain-Chatchat free to use?

Langchain-Chatchat is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does Langchain-Chatchat do?

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowle

What is Langchain-Chatchat written in?

Langchain-Chatchat is primarily written in Python. Its source is publicly available at https://github.com/chatchat-space/Langchain-Chatchat, and it has 38,641 GitHub stars.