LangGraphChatBot  by NanGePlus

AI chatbot with memory and tool use

Created 6 months ago
275 stars

Top 94.1% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a framework for building intelligent customer service chatbots with memory capabilities, leveraging LangGraph, DeepSeek-R1, FastAPI, and Gradio. It supports various large language models, including GPT, domestic models via OneApi, Ollama, and Alibaba's Tongyi Qianwen, offering a flexible and extensible solution for conversational AI applications.

How It Works

The core of the project utilizes LangGraph to define a stateful, graph-based workflow for chatbot interactions. This graph structure allows for complex conversational flows, including dynamic routing, tool integration, and memory management. Short-term memory is maintained within the graph's thread, while long-term memory is persisted using PostgreSQL, enabling continuous and context-aware conversations. The system supports tool calling, dynamic routing based on tool types (retrieval vs. non-retrieval), and includes mechanisms for document relevance scoring and query rewriting.

Quick Start & Requirements

  • Installation: Clone the repository from GitHub or Gitee. Install dependencies using pip install langgraph==0.2.74 langchain-openai==0.3.6 fastapi==0.115.8 uvicorn==0.34.0 gradio==5.18.0. For PostgreSQL persistence, install langgraph-checkpoint-postgres and psycopg2.
  • LLM Access: Requires access to LLM APIs (e.g., OpenAI, OneApi, Ollama, Tongyi Qianwen). Configuration is managed in llms.py.
  • Database: PostgreSQL with pgvector extension is required for persistent memory. Docker can be used to set up the database.
  • Dependencies: Python 3.x, FastAPI, Gradio, LangChain, LangGraph, PostgreSQL, NLTK, pdfminer.six.
  • Documentation: Links to Bilibili and YouTube videos are provided for setup and demonstrations.

Highlighted Details

  • Supports multiple LLM backends, including local Ollama models and various API-based services.
  • Implements both short-term (in-thread) and long-term (PostgreSQL) memory management for conversational context.
  • Features dynamic routing and tool integration, allowing the chatbot to call external tools and adapt its responses.
  • Includes a FastAPI backend for API services and a Gradio frontend for a user-friendly web interface with session management.
  • Offers visualization of the LangGraph state machine as a PNG file.

Maintenance & Community

  • The project is actively developed by NanGePlus.
  • Links to GitHub and Gitee repositories are provided.

Licensing & Compatibility

  • The specific license is not explicitly stated in the provided text, but the project appears to be open-source. Compatibility for commercial use would require license verification.

Limitations & Caveats

  • The README mentions a potential openai.BadRequestError when using certain models (e.g., OneApi, Qwen) with specific embeddings, requiring a modification in the langchain_openai/embeddings/base.py source code.
  • Users need to configure API keys, model parameters, and service IPs/ports according to their environment.
Health Check
Last Commit

5 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
36 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Elvis Saravia Elvis Saravia(Founder of DAIR.AI), and
2 more.

awesome-llm-apps by Shubhamsaboo

2.6%
69k
LLM app collection with AI agents and RAG examples
Created 1 year ago
Updated 3 days ago
Feedback? Help us improve.