CodeBase Intelligence Hub系统实现总览

CodeBase Intelligence Hub — 分阶段教学总览 > 按阶段渐进式实现整个系统,每阶段都包含:设计指导、要实现的功能、示例代码、依赖与环境、学习要点。 > 目标:在实现过程中充分学习 LangChain / LangGraph 与 Agent 设计模式。

CodeBase Intelligence Hub系统实现总览

CodeBase Intelligence Hub — 分阶段教学总览

按阶段渐进式实现整个系统,每阶段都包含:设计指导、要实现的功能、示例代码、依赖与环境、学习要点。
目标:在实现过程中充分学习 LangChain / LangGraph 与 Agent 设计模式。


阶段一览

阶段 主题 核心学习点 预计时间
Phase 0 环境与 LangChain 初识 虚拟环境、LangChain 模块划分、最小可运行链 0.5 天
Phase 1 LCEL 与提示词 LCEL 链、PromptTemplate、输出解析、Runnable 组合 1 天
Phase 2 文档加载与分块 DocumentLoader、TextSplitter、代码/文档分块策略 1 天
Phase 3 向量存储与检索 Embeddings、VectorStore、Retriever、Chroma 1 天
Phase 4 RAG 管道 检索+生成链、上下文格式化、RAGAS 初体验 1–2 天
Phase 5 工具与单 Agent @tool、bind_tools、ReAct、单 Agent 循环 1–2 天
Phase 6 LangGraph 与编排 StateGraph、节点、边、条件路由、状态 1–2 天
Phase 7 多 Agent 协作 Orchestrator、多专家、意图路由、结果聚合 2 天
Phase 8 记忆、流式与 API Memory、流式输出、FastAPI、LangServe 1–2 天

文档导航

阶段教程(Phase 0~8)

扩展教学


依赖版本(推荐)

项目使用 Python 3.11+,包管理器推荐 uvpip。以下与仓库 pyproject.toml 对齐,并按阶段逐步添加。

# pyproject.toml 中逐步添加的依赖(各阶段会注明)
[project]
requires-python = ">=3.11"
dependencies = [
    "langchain-core>=1.2.19",
    "langchain-openai>=1.1.11",
    "langchain-community>=0.3.0",
    "langchain-text-splitters>=0.3.0",
    "langgraph>=0.2.0",
    "langchain-chroma>=0.1.0",
    "chromadb>=0.4.0",
    "openai>=2.28.0",
    "pydantic>=2.0",
    "pydantic-settings>=2.13.1",
    "python-dotenv>=1.2.2",
    "fastapi>=0.115.0",
    "uvicorn>=0.30.0",
    "langserve>=0.2.0",
]

各阶段文档会标明本阶段新增的包,便于你按阶段安装。


目录结构(随阶段演进)

codebase-intelligence-hub/
├── .env                    # API Keys(不提交)
├── .env.example
├── pyproject.toml
├── main.py                  # Phase 0-1 入口
├── config/
│   └── settings.py         # Phase 1 起
├── retrieval/              # Phase 2 起
│   ├── loaders.py
│   ├── splitters.py
│   └── vectorstore.py      # Phase 3 起
├── chains/                 # Phase 1 起
│   └── rag.py              # Phase 4 起
├── agents/                 # Phase 5 起
│   ├── retrieval_agent.py
│   └── ...
├── graph/                  # Phase 6 起
│   ├── state.py
│   └── builder.py
├── api/                    # Phase 8
│   └── main.py
├── docs/
│   └── phased-tutorial/   # 本系列文档
└── tests/

从 Phase 0 开始,按顺序完成每一阶段的「需要实现的功能」与示例代码,即可在每阶段都跑通并理解对应设计模式。