本仓库包含 Python 基础与 Pydantic 学习资料(中文注释与文档方便自学):
sample.ipynb与seq.ipynb:字典与序列的示例与练习,推荐通过 Jupyter Notebook 交互学习。pydantic_lab/:使用 Pydantic 进行数据验证的示例(CLI、FastAPI、环境配置)。python -m pydantic_lab.langgraph_pydantic_demo:LangGraph + Pydantic 状态机示例,展示类型校验与节点状态合并。python -m pydantic_lab.langgraph_rag_demo:离线 RAG 流程示例,LangGraph 负责任务流转,Pydantic 校验查询与检索结果。docs/学习指南.md:快速了解如何使用 Notebook 与 Pydantic 示例的中文技术文档。docs/LangGraph学习指南.md:LangGraph 入门与练习项目指引(含最小模板与练习思路)。docs/Pydantic介绍.md:Pydantic 的概念、常用模式与本仓库示例的中文入门介绍。requirements.txt:安装依赖以运行示例与测试(包含 Jupyter)。python -m pydantic_lab.cli:命令行校验 JSON 的示例,-f与-j参数二选一;路径不存在会给出中文提示。projects/todo_manager/:独立目录下的待办事项 CLI 示例,使用 Pydantic 校验和 JSON 存储,便于与其他脚本隔离。
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pytest如需以交互方式查看 Notebook,建议运行:
jupyter notebook国内或受限网络环境可为
pip指定镜像源(如清华):pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
FastAPI 示例运行:
uvicorn pydantic_lab.api:app --reload --host 0.0.0.0 --port 8000