# learn_langgraph **Repository Path**: ckdkambh/learn_langgraph ## Basic Information - **Project Name**: learn_langgraph - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-13 - **Last Updated**: 2026-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LangChain + LangGraph 学习项目 一个全面学习 LangChain 和 LangGraph 的 Demo 项目,包含详细注释和面试考点。 ## 项目结构 ``` langchain_learn/ ├── config.yaml # 模型配置 ├── requirements.txt # 依赖 ├── utils/ # 工具函数 │ └── config.py ├── 01_basics/ # LangChain 基础 │ ├── 01_llcel_basics.py # LCEL 表达式 │ ├── 02_components.py # 组件 │ └── 03_models.py # 模型调用 ├── 02_tools/ # Tools 系统 │ ├── 01_simple_tool.py │ ├── 02_tool_builder.py │ └── 03_multiple_tools.py ├── 03_agent/ # Agent │ ├── 01_react_agent.py │ └── 02_function_calling.py ├── 04_memory/ # Memory │ ├── 01_buffer.py │ └── 02_summary.py ├── 05_langgraph/ # LangGraph (重点!) │ ├── 01_basic_graph.py # 基础状态图 │ ├── 02_conditional.py # 条件边 │ ├── 03_checkpointer.py # 持久化 │ ├── 04_multi_agent.py # 多Agent协作 │ ├── 05_custom_nodes.py # 自定义节点 │ ├── 06_custom_edges.py # 自定义边 │ ├── 07_subgraph.py # 子图 │ ├── 08_advanced_patterns.py # 高级模式 │ └── 09_invoke_stream_batch.py # invoke/stream/batch对比 └── 06_rag/ # RAG ``` ## 快速开始 ### 1. 安装依赖 ```bash pip install -r requirements.txt ``` ### 2. 配置模型 编辑 `config.yaml`,修改: - `model_type`: "openai兼容" 或 "ollama" - `base_url`: 你的API地址 - `api_key`: 你的API Key - `model`: 使用的模型 ### 3. 运行 Demo ```bash # LCEL 基础 python 01_basics/01_llcel_basics.py # Tools python 02_tools/01_simple_tool.py # Agent python 03_agent/01_react_agent.py # Memory python 04_memory/01_buffer.py # LangGraph 基础 python 05_langgraph/01_basic_graph.py ``` ## 学习路径 ### 面试重点推荐 1. **LCEL** - 管道操作符原理 2. **Tools** - @tool装饰器、bind_tools 3. **LangGraph 基础** - StateGraph 原理 - add_edge vs add_conditional_edges - 节点和边的执行流程 4. **Checkpointer** - 持久化原理 - 状态恢复流程 ## 面试常见问题 ### LangGraph - `add_edge` vs `add_conditional_edges` 的区别? - 条件函数返回什么? - Checkpointer 如何保存和恢复状态? - invoke vs stream vs batch 的区别? ### LCEL - `|` 管道操作符原理? - Runnable 接口有哪些方法? - LCEL vs LangGraph 怎么选? ## 配置说明 ```yaml model_type: "openai兼容" openai: base_url: "https://api.siliconflow.cn/v1" # API地址 api_key: "sk-xxx" # API Key model: "Qwen/Qwen2.5-7B-Instruct" # 模型名 temperature: 0.7 storage: type: "memory" # 或 "sqlite" ``` ## 环境要求 - Python 3.10+ - LangChain 0.3.0+ - LangGraph 0.2.0+ ## 学习建议 1. **先跑通基础Demo** - 理解每个模块的基本用法 2. **阅读注释** - 每个文件都有详细的原理说明 3. **关注面试考点** - 标记了常见面试问题 4. **修改配置调试** - 用自己的模型测试 5. **理解底层原理** - 不仅会用,还要知道为什么这样设计