中文

LangChain ReAct Agent

An intelligent customer service system, a ReAct Agent based on LangChain / LangGraph.

Verified

Core facts

Read by a script from the official API, not rewritten by a model.

License
MIT
Languages
Python
Maintainer
lhh737
Verified

What it is

This is an intelligent customer service system, a ReAct Agent based on LangChain / LangGraph. It is implemented on LangChain as a ReAct (Reasoning + Acting) Agent that integrates RAG retrieval augmentation, multi-tool calling and dynamic prompt switching. The system automatically judges the task type (knowledge Q&A / report generation) based on the user's intent, calls suitable tools and the knowledge base to complete reasoning, and shows the Agent's thinking and execution process in real time through a Streamlit streaming interface. The project is licensed under MIT, by lhh737.

Main features

  1. The ReAct paradigm uses a Thought → Action → Observation loop in which the Agent reasons autonomously and decides which tool to call.

  2. RAG retrieval augmentation uses the Chroma vector store with DashScope Embedding, with MD5 file deduplication, and supports mixed txt/pdf loading.

  3. Multi-tool calling covers weather query, user location, external data retrieval and report context filling, selected automatically by the Agent as needed.

  4. For dynamic prompt switching, Middleware automatically switches between two System Prompts, ordinary Q&A and report generation, based on runtime context.

  5. The streaming chat interface is built with Streamlit and supports streaming character-by-character output, retained history messages, and a visible Agent reasoning process.

  6. The modular structure consists of independent Agent, RAG, Model, Tools and Middleware modules, driven by YAML configuration.

Getting started

  1. The environment requires Python 3.10 or newer.

  2. The DashScope API Key is applied for at 阿里云百炼.

  3. For the first run, it is enough to ensure the DashScope API Key is set and the data directory holds knowledge base documents.

  4. The test question about the main functions of the robot vacuum triggers RAG knowledge base Q&A.

  5. The test question about what to do when the robot cannot recharge normally triggers knowledge base troubleshooting.

  6. The test request to generate a personalized usage report from user data triggers report generation plus tool calling.

From the README · bash
git clone https://github.com/lhh737/LangChain-ReAct-Agent.git
cd LangChain-ReAct-Agent
From the README · bash
pip install -r requirements.txt
From the README · bash
# Linux / macOS
export DASHSCOPE_API_KEY="your-api-key"

# Windows (CMD)
set DASHSCOPE_API_KEY=your-api-key
From the README · bash
python -c "from rag.vector_store import VectorStoreService; VectorStoreService().load_document()"
From the README · bash
streamlit run app.py

Who it is for

In the technology stack, the LLM layer uses Tongyi Qianwen (DashScope / ChatTongyi). The Agent framework uses LangChain plus LangGraph. The vector database is Chroma.

Document processing uses PyPDF plus RecursiveCharacterTextSplitter. The front end uses Streamlit. Configuration is driven by YAML, covering Agent, RAG, Chroma and Prompts.

The project manages configuration through YAML files under the config directory. The rag.yml file holds the chat model name and the Embedding model name. The chroma.yml file holds the Chroma persistence path, chunk size, retrieval Top-K and supported file types.

The prompts.yml file holds the prompt template file paths for each scenario. The agent.yml file holds the Agent timeout, the external data path and similar settings.

Sources

This page is written from the official sources below. Open them to check the original text.

Verified ·

This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.