[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tool-benman1--generative_ai_with_langchain":3,"similar-benman1--generative_ai_with_langchain":113},{"id":4,"github_repo":5,"name":6,"description_en":7,"description_zh":8,"ai_summary_zh":8,"readme_en":9,"readme_zh":10,"quickstart_zh":11,"use_case_zh":12,"hero_image_url":13,"owner_login":14,"owner_name":15,"owner_avatar_url":16,"owner_bio":17,"owner_company":18,"owner_location":19,"owner_email":20,"owner_twitter":21,"owner_website":22,"owner_url":23,"languages":24,"stars":48,"forks":49,"last_commit_at":50,"license":51,"difficulty_score":52,"env_os":53,"env_gpu":54,"env_ram":54,"env_deps":55,"category_tags":59,"github_topics":64,"view_count":52,"oss_zip_url":20,"oss_zip_packed_at":20,"status":80,"created_at":81,"updated_at":82,"faqs":83,"releases":112},1146,"benman1\u002Fgenerative_ai_with_langchain","generative_ai_with_langchain","Build production-ready LLM applications and advanced agents using Python, LangChain, and LangGraph. This is the companion repository for the book on generative AI with LangChain.","Generative AI with LangChain 是一套基于Python和LangChain生态的开发工具集，专注于构建可落地的大型语言模型应用与智能代理系统。它针对企业级AI开发中从原型到生产的痛点，提供多代理架构设计、高效工作流编排（LangGraph）、增强检索生成（RAG）等核心技术方案。通过实战案例涵盖软件开发、数据分析等场景，支持Google Gemini、Anthropic等主流大模型，并包含测试评估、成本优化及安全合规等生产必备模块。适合希望将AI技术应用于实际业务的开发者与研究者，尤其对需要构建复杂智能系统的团队具有参考价值。配套书籍提供系统性指导，附带代码仓库与学习资源，助力开发者快速掌握生产环境下的LLM应用开发方法。","\u003Ch1 align=\"center\">\nGenerative AI with LangChain, Second Edition\u003C\u002Fh1>\n\u003Cp align=\"center\">This is the code repository for \u003Ca href =\"https:\u002F\u002Fwww.packtpub.com\u002Fen-us\u002Fproduct\u002Fgenerative-ai-with-langchain-second-edition-9781837022014\"> Generative AI with LangChain, Second Edition\u003C\u002Fa>, published by Packt.\n\u003C\u002Fp>\n\n\u003Ch2 align=\"center\">\nBuild production ready LLM applications and advanced agents using Python and LangGraph \n\u003C\u002Fh2>\n\u003Cp align=\"center\">\nBen Auffarth, Leonid Kuligin\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n   \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FYQbX5rsc74\" alt=\"Discord\" title=\"Learn more on the Discord server\">\u003Cimg width=\"32px\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_4b28edbea2b2.gif\"\u002F>\u003C\u002Fa>\n  &#8287;&#8287;&#8287;&#8287;&#8287;\n  \u003Ca href=\"https:\u002F\u002Fpackt.link\u002Ffree-ebook\u002F9781837022014\">\u003Cimg width=\"32px\" alt=\"Free PDF\" title=\"Free PDF\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_dedce39251ef.png\"\u002F>\u003C\u002Fa>\n &#8287;&#8287;&#8287;&#8287;&#8287;\n  \u003Ca href=\"https:\u002F\u002Fpackt.link\u002Fgbp\u002F9781837022014\">\u003Cimg width=\"32px\" alt=\"Graphic Bundle\" title=\"Graphic Bundle\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_25b222287da7.png\"\u002F>\u003C\u002Fa>\n  &#8287;&#8287;&#8287;&#8287;&#8287;\n   \u003Ca href=\"https:\u002F\u002Famzn.to\u002F4dErkya\">\u003Cimg width=\"32px\" alt=\"Amazon\" title=\"Get your copy\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_45ac6f33c263.png\"\u002F>\u003C\u002Fa>\n  &#8287;&#8287;&#8287;&#8287;&#8287;\n\u003C\u002Fp>\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>About the book\u003C\u002Fsummary>\n\u003Ca href=\"https:\u002F\u002Fwww.packtpub.com\u002Fen-us\u002Fproduct\u002Fgenerative-ai-with-langchain-9781837022014\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_a1653fa67bf8.jpg\" alt=\"Generative AI with LangChain, 2nd Edition (2025)\" height=\"256px\" align=\"right\">\n\u003C\u002Fa>\n\nThis second edition tackles the biggest challenge facing companies in AI today: moving from prototypes to production. Fully updated to reflect the latest developments in the LangChain ecosystem, it captures how modern AI systems are developed, deployed, and scaled in enterprise environments. This edition places a strong focus on multi-agent architectures, robust LangGraph workflows, and advanced retrieval-augmented generation (RAG) pipelines.\nYou'll explore design patterns for building agentic systems, with practical implementations of multi-agent setups for complex tasks. The book guides you through reasoning techniques such as Tree-of -Thoughts, structured generation, and agent handoffs—complete with error handling examples. Expanded chapters on testing, evaluation, and deployment address the demands of modern LLM applications, showing you how to design secure, compliant AI systems with built-in safeguards and responsible development principles. This edition also expands RAG coverage with guidance on hybrid search, re-ranking, and fact-checking pipelines to enhance output accuracy.\nWhether you're extending existing workflows or architecting multi-agent systems from scratch, this book provides the technical depth and practical instruction needed to design LLM applications ready for success in production environments.\n\u003C\u002Fdetails>\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>Key Learnings\u003C\u002Fsummary>\n\n\u003Cul>\n\u003Cli>Design and implement refined multi-agent systems using LangGraph\u003C\u002Fli>\n\u003Cli>Enterprise-grade testing and evaluation frameworks for LLM applications\u003C\u002Fli>\n\u003Cli>Deploy production-ready observability and monitoring solutions\u003C\u002Fli>\n\u003Cli>Build RAG systems with hybrid search and re-ranking capabilities\u003C\u002Fli>\n\u003Cli>Implement agents for software development and data analysis\u003C\u002Fli>\n\u003Cli>Work with latest LLMs and providers Google Gemini, Anthropic and Mistral, DeepSeek, and OpenAI o3-mini\u003C\u002Fli>\n\u003Cli>Optimize cost and performance across different deployment types\u003C\u002Fli>\n\u003Cli>Design secure, compliant AI systems with current best practices\u003C\u002Fli>\n\u003C\u002Ful>\n\n  \u003C\u002Fdetails>\n  \u003Cdetails open>\n\u003Csummary>\u003Ch2>Note to Readers\u003C\u002Fsummary>\n\nThank you for choosing \"Generative AI with LangChain\"! We appreciate your enthusiasm and feedback.\n\nPlease note that we've released several updated versions of the code to keep pace with the ecosystem. Consequently, there are four different branches for this repository: \n* [v1](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fv1) - **Latest Migration**: Updates for LangChain v1.0 and 2026 model standards (Python 3.12+).\n* [2nd edition](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fsecond_edition) - Corresponds to the 2nd edition print, utilizing LangChain v0.3.\n* [softupdate](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fsoftupdate) - this is for the soft update of the book (2024), corresponding to ver 0.1.13 of LangChain.\n* [main](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fmain) - this is the original version of the book (December 2023).\n\nPlease refer to the version that you are interested in or that corresponds to your version of the book.\n\u003C\u002Fdetails>\n\n\u003Cdetails open>\n\u003Csummary>\u003Ch3>Download a free PDF \u003Cimg alt=\"Coding\" height=\"25\" width=\"40\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_0c8ba823dd96.gif\">\u003C\u002Fsummary>\nDownload a free PDF \u003Cimg alt=\"Coding\" height=\"25\" width=\"40\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_0c8ba823dd96.gif\">\n\n_If you have already purchased an up-to-date print or Kindle version of this book, you can get a DRM-free PDF version at no cost. Simply click on the link to claim your free PDF._\n[Free-Ebook](https:\u002F\u002Fpackt.link\u002Ffree-ebook\u002F9781837022014) \u003Cimg alt=\"Coding\" height=\"15\" width=\"35\"  src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_75578b9c5ce6.gif\">\n\nWe  provide a PDF file that has color images of the screenshots\u002Fdiagrams used in this book at [GraphicBundle](https:\u002F\u002Fpackt.link\u002Fgbp\u002F9781837022014) \u003Cimg alt=\"Coding\" height=\"15\" width=\"35\"  src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_75578b9c5ce6.gif\">\n\u003C\u002Fdetails>\n\n\u003Cdetails open>\n\u003Csummary>\u003Ch3>Commitment\u003C\u002Fsummary>\n\n\u003Cb>Code Updates:\u003C\u002Fb> Our commitment is to provide you with stable and valuable code examples. While LangChain is known for frequent updates, we understand the importance of aligning our code with the latest changes. The companion repository is regularly updated to harmonize with LangChain developments.\n\n\u003Cb>Expect Stability:\u003C\u002Fb> For stability and usability, the repository might not match every minor LangChain update. We aim for consistency and reliability to ensure a seamless experience for our readers. \n\n\u003Cb>How to Reach Us:\u003C\u002Fb> Encountering issues or have suggestions? Please don't hesitate to open an issue, and we'll promptly address it. Your feedback is invaluable, and we're here to support you in your journey with LangChain.\nThank you for your understanding and happy coding!\n\u003C\u002Fdetails>\n\n\u003Cdetails open> \n   \u003Csummary>\u003Ch3>Know more on the Discord server \u003Cimg alt=\"Coding\" height=\"25\" width=\"32\"  src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_4b28edbea2b2.gif\">\u003C\u002Fsummary>\n\nYou can engage with the author and other readers on the discord server and find latest updates and discussions in the community at [Discord](https:\u002F\u002Fdiscord.gg\u002FYQbX5rsc74)\n\u003C\u002Fdetails>\n\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>Chapters\u003C\u002Fsummary>\n\nIn the following table, you can find links to the directories in this repository. Each directory contains further links to python scripts and to notebooks. You can also see links to computing platforms, where you can execute the notebooks in the repository. Please note that there are other Python scripts and projects that are not notebooks, which you'll find in the chapter directories.\n\n| Chapter | Title | Directory Link |\n|---------|-------|----------------|\n| Chapter 1 | The Rise of Generative AI: From Language Models to Agents | [chapter1\u002F](.\u002Fchapter1) |\n| Chapter 2 | First Steps with LangChain | [chapter2\u002F](.\u002Fchapter2) |\n| Chapter 3 | Building Workflows with LangGraph | [chapter3\u002F](.\u002Fchapter3) |\n| Chapter 4 | Building Intelligent RAG Systems with LangChain | [chapter4\u002F](.\u002Fchapter4) |\n| Chapter 5 | Building Intelligent Agents | [chapter5\u002F](.\u002Fchapter5) |\n| Chapter 6 | Advanced Applications and Multi-Agent Systems | [chapter6\u002F](.\u002Fchapter6) |\n| Chapter 7 | Software Development and Data Analysis Agents | [chapter7\u002F](.\u002Fchapter7) |\n| Chapter 8 | Evaluation and Testing of LLM Applications | [chapter8\u002F](.\u002Fchapter8) |\n| Chapter 9 | Production Deployment and Observability | [chapter9\u002F](.\u002Fchapter9) |\n\n\u003C\u002Fdetails>\n\n\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>Requirements for this book\u003C\u002Fsummary>\n  \n### Software and hardware list\nThis is the companion repository for the book. Here are a few instructions that help getting set up. Please also see chapter 2. \n\nAll chapters rely on Python (3.12 or higher is recommended for the `v1` branch).\n\nPlease check the instructions for setting up the environment either in the book or [here](.\u002FSETUP.md). They include instructions for dependencies and API keys. **Following the instructions should make sure that you don't have any issues running the code in the book or this repository. If you encounter any issues, please make sure you've followed these instructions.**\n\n\n## 👋 Contribute\n\nWe welcome contributions from developers of all levels. If you'd like to contribute, please check our [contributing guidelines](.\u002FCONTRIBUTING.md) and help make this repository and the book more accessible.\n\n---\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_b6c38dc90921.png)](https:\u002F\u002Fstar-history.com\u002F#benman1\u002Fgenerative_ai_with_langchain&Date)\n\n\n## ❤️ Contributors\n\n[![repo contributors](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_3088f850fa06.png)](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Fgraphs\u002Fcontributors)\n\nA special thank you to [Leslie Pan](https:\u002F\u002Fgithub.com\u002Fleslie-zi-pan) for leading the migration to LangChain v1.0 and updating the repository.\n\n\u003Cdetails> \n  \u003Csummary>\u003Ch2>Get to know Authors\u003C\u002Fh2>\u003C\u002Fsummary>\n\n_Ben Auffarth_ Ben Auffarth is a full-stack data scientist with more than 15 years of work experience. With a background and Ph.D. in computational and cognitive neuroscience, he has designed and conducted wet lab experiments on cell cultures, analyzed experiments with terabytes of data, run brain models on IBM supercomputers with up to 64k cores, built production systems processing hundreds and thousands of transactions per day, and trained language models on a large corpus of text documents. He co-founded and is the former president of Data Science Speakers, London.\n\n_Leonid Kuligin_ Leonid Kuligin is a staff AI engineer at Google Cloud, working on generative AI and classical machine learning solutions (such as demand forecasting or optimization problems). Leonid is one of the key maintainers of Google Cloud integrations on LangChain, and a visiting lecturer at CDTM (TUM and LMU). Prior to Google, Leonid gained more than 20 years of experience in building B2C and B2B applications based on complex machine learning and data processing solutions such as search, maps, and investment management in German, Russian, and US technological, financial, and retail companies.\n\n\n\n\u003C\u002Fdetails>\n","\u003Ch1 align=\"center\">\n使用 LangChain 的生成式 AI，第二版\u003C\u002Fh1>\n\u003Cp align=\"center\">这是 Packt 出版的《使用 LangChain 的生成式 AI，第二版》（ISBN：9781837022014）的代码仓库。\u003C\u002Fp>\n\n\u003Ch2 align=\"center\">\n使用 Python 和 LangGraph 构建生产就绪的 LLM 应用程序及高级智能体\u003C\u002Fh2>\n\u003Cp align=\"center\">\n本·奥夫斯、列昂尼德·库利金\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n   \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FYQbX5rsc74\" alt=\"Discord\" title=\"在 Discord 服务器上了解更多\">\u003Cimg width=\"32px\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_4b28edbea2b2.gif\"\u002F>\u003C\u002Fa>\n  &#8287;&#8287;&#8287;&#8287;&#8287;\n  \u003Ca href=\"https:\u002F\u002Fpackt.link\u002Ffree-ebook\u002F9781837022014\">\u003Cimg width=\"32px\" alt=\"免费 PDF\" title=\"免费 PDF\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_dedce39251ef.png\"\u002F>\u003C\u002Fa>\n &#8287;&#8287;&#8287;&#8287;&#8287;\n  \u003Ca href=\"https:\u002F\u002Fpackt.link\u002Fgbp\u002F9781837022014\">\u003Cimg width=\"32px\" alt=\"图形包\" title=\"图形包\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_25b222287da7.png\"\u002F>\u003C\u002Fa>\n  &#8287;&#8287;&#8287;&#8287;&#8287;\n   \u003Ca href=\"https:\u002F\u002Famzn.to\u002F4dErkya\">\u003Cimg width=\"32px\" alt=\"亚马逊\" title=\"购买本书\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_45ac6f33c263.png\"\u002F>\u003C\u002Fa>\n  &#8287;&#8287;&#8287;&#8287;&#8287;\n\u003C\u002Fp>\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>关于本书\u003C\u002Fsummary>\n\u003Ca href=\"https:\u002F\u002Fwww.packtpub.com\u002Fen-us\u002Fproduct\u002Fgenerative-ai-with-langchain-9781837022014\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_a1653fa67bf8.jpg\" alt=\"使用 LangChain 的生成式 AI，第 2 版（2025）\" height=\"256px\" align=\"right\">\n\u003C\u002Fa>\n\n本第二版直面当今企业在 AI 领域面临的最大挑战：如何将原型转化为生产环境中的应用。本书全面更新，反映了 LangChain 生态系统的最新进展，深入探讨了现代 AI 系统在企业环境中开发、部署和扩展的方式。新版特别强调多智能体架构、稳健的 LangGraph 工作流以及先进的检索增强生成（RAG）流水线。\n\n您将探索构建智能体系统的设计模式，并通过实际案例了解用于复杂任务的多智能体配置。书中还介绍了思维树、结构化生成和智能体交接等推理技术，并提供了完整的错误处理示例。此外，新增的测试、评估和部署章节针对现代 LLM 应用的需求，教您如何设计具备内置安全机制和负责任开发原则的安全合规 AI 系统。新版还进一步扩展了 RAG 的内容，提供混合搜索、重排序和事实核查流水线的指导，以提升输出准确性。\n\n无论您是扩展现有工作流，还是从零开始构建多智能体系统，本书都能为您提供所需的技术深度和实用指导，助您设计出能够在生产环境中成功运行的 LLM 应用程序。\n\u003C\u002Fdetails>\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>核心学习点\u003C\u002Fsummary>\n\n\u003Cul>\n\u003Cli>使用 LangGraph 设计并实现精炼的多智能体系统\u003C\u002Fli>\n\u003Cli>面向 LLM 应用的企业级测试与评估框架\u003C\u002Fli>\n\u003Cli>部署生产就绪的可观测性和监控解决方案\u003C\u002Fli>\n\u003Cli>构建具备混合搜索和重排序能力的 RAG 系统\u003C\u002Fli>\n\u003Cli>为软件开发和数据分析任务部署智能体\u003C\u002Fli>\n\u003Cli>兼容最新的 LLM 及其提供商，包括 Google Gemini、Anthropic、Mistral、DeepSeek 和 OpenAI o3-mini\u003C\u002Fli>\n\u003Cli>优化不同部署方式下的成本与性能\u003C\u002Fli>\n\u003Cli>按照当前最佳实践设计安全合规的 AI 系统\u003C\u002Fli>\n\u003C\u002Ful>\n\n  \u003C\u002Fdetails>\n  \u003Cdetails open>\n\u003Csummary>\u003Ch2>致读者\u003C\u002Fsummary>\n\n感谢您选择《使用 LangChain 的生成式 AI》！我们非常重视您的热情与反馈。\n\n请注意，为了跟上生态系统的步伐，我们已发布了多个代码更新版本。因此，本仓库包含四个不同的分支：\n* [v1](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fv1) - **最新迁移**：适用于 LangChain v1.0 和 2026 年模型标准（Python 3.12+）。\n* [第二版](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fsecond_edition) - 对应第二版纸质书，使用 LangChain v0.3。\n* [softupdate](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fsoftupdate) - 用于该书的软更新版本（2024），对应 LangChain v0.1.13。\n* [main](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Ftree\u002Fmain) - 这是本书的原始版本（2023 年 12 月）。\n\n请根据您感兴趣的版本或与您手中书籍版本相对应的分支进行参考。\n\u003C\u002Fdetails>\n\n\u003Cdetails open>\n\u003Csummary>\u003Ch3>下载免费 PDF \u003Cimg alt=\"编程\" height=\"25\" width=\"40\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_0c8ba823dd96.gif\">\u003C\u002Fsummary>\n下载免费 PDF \u003Cimg alt=\"编程\" height=\"25\" width=\"40\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_0c8ba823dd96.gif\">\n\n_如果您已经购买了本书的最新纸质版或 Kindle 版，可以免费获取无 DRM 限制的 PDF 版本。只需点击链接即可领取您的免费 PDF。_\n[免费电子书](https:\u002F\u002Fpackt.link\u002Ffree-ebook\u002F9781837022014) \u003Cimg alt=\"编程\" height=\"15\" width=\"35\"  src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_75578b9c5ce6.gif\">\n\n我们还在 [GraphicBundle](https:\u002F\u002Fpackt.link\u002Fgbp\u002F9781837022014) 提供包含本书中截图和图表彩色图像的 PDF 文件 \u003Cimg alt=\"编程\" height=\"15\" width=\"35\"  src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_75578b9c5ce6.gif\">\n\u003C\u002Fdetails>\n\n\u003Cdetails open>\n\u003Csummary>\u003Ch3>承诺\u003C\u002Fsummary>\n\n\u003Cb>代码更新：\u003C\u002Fb> 我们致力于为您提供稳定且有价值的代码示例。尽管 LangChain 以频繁更新著称，但我们深知使代码与最新变化保持一致的重要性。配套仓库会定期更新，以配合 LangChain 的发展。\n\n\u003Cb>稳定性预期：\u003C\u002Fb> 为了确保稳定性和可用性，仓库可能不会完全匹配 LangChain 的每一次小更新。我们的目标是保持一致性与可靠性，从而为读者提供顺畅的体验。\n\n\u003Cb>联系我们：\u003C\u002Fb> 如果您遇到问题或有任何建议，请随时提交问题，我们将尽快予以解决。您的反馈对我们至关重要，我们愿意在您使用 LangChain 的旅程中提供支持。\n感谢您的理解，祝编码愉快！\n\u003C\u002Fdetails>\n\n\u003Cdetails open> \n   \u003Csummary>\u003Ch3>在 Discord 服务器上了解更多 \u003Cimg alt=\"编程\" height=\"25\" width=\"32\"  src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_4b28edbea2b2.gif\">\u003C\u002Fsummary>\n\n您可以在 Discord 服务器上与作者及其他读者互动，并在 [Discord](https:\u002F\u002Fdiscord.gg\u002FYQbX5rsc74) 社区中找到最新更新和讨论内容。\n\u003C\u002Fdetails>\n\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>章节\u003C\u002Fsummary>\n\n在下表中，您可以找到本仓库目录的链接。每个目录都包含指向 Python 脚本和笔记本的进一步链接。您还可以看到计算平台的链接，您可以在这些平台上运行仓库中的笔记本。请注意，还有一些非笔记本的 Python 脚本和项目，您可以在各章节目录中找到它们。\n\n| 章节 | 标题 | 目录链接 |\n|---------|-------|----------------|\n| 第1章 | 生成式 AI 的兴起：从语言模型到智能体 | [chapter1\u002F](.\u002Fchapter1) |\n| 第2章 | LangChain 初体验 | [chapter2\u002F](.\u002Fchapter2) |\n| 第3章 | 使用 LangGraph 构建工作流 | [chapter3\u002F](.\u002Fchapter3) |\n| 第4章 | 使用 LangChain 构建智能 RAG 系统 | [chapter4\u002F](.\u002Fchapter4) |\n| 第5章 | 构建智能体 | [chapter5\u002F](.\u002Fchapter5) |\n| 第6章 | 高级应用与多智能体系统 | [chapter6\u002F](.\u002Fchapter6) |\n| 第7章 | 软件开发与数据分析智能体 | [chapter7\u002F](.\u002Fchapter7) |\n| 第8章 | LLM 应用的评估与测试 | [chapter8\u002F](.\u002Fchapter8) |\n| 第9章 | 生产部署与可观测性 | [chapter9\u002F](.\u002Fchapter9) |\n\n\u003C\u002Fdetails>\n\n\n\u003Cdetails open> \n  \u003Csummary>\u003Ch2>本书所需条件\u003C\u002Fsummary>\n  \n\n\n### 软硬件清单\n这是本书的配套仓库。以下是一些帮助您进行设置的说明。请同时参阅第2章。\n\n所有章节都依赖于 Python（建议使用 `v1` 分支时使用 3.12 或更高版本）。\n\n请查看书中或[此处](.\u002FSETUP.md)的环境设置说明。这些说明包括依赖项和 API 密钥的配置。**按照说明操作应能确保您顺利运行本书及本仓库中的代码。如果您遇到任何问题，请务必确认已遵循这些步骤。**\n\n\n## 👋 贡献\n我们欢迎各水平开发者参与贡献。如果您希望贡献，请查阅我们的[贡献指南](.\u002FCONTRIBUTING.md)，帮助使本仓库和本书更加易用。\n\n---\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_b6c38dc90921.png)](https:\u002F\u002Fstar-history.com\u002F#benman1\u002Fgenerative_ai_with_langchain&Date)\n\n\n## ❤️ 贡献者\n\n[![repo contributors](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_readme_3088f850fa06.png)](https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Fgraphs\u002Fcontributors)\n\n特别感谢 [Leslie Pan](https:\u002F\u002Fgithub.com\u002Fleslie-zi-pan)，她主导了迁移到 LangChain v1.0 的工作，并更新了本仓库。\n\n\u003Cdetails> \n  \u003Csummary>\u003Ch2>了解作者\u003C\u002Fh2>\u003C\u002Fsummary>\n\n_本·奥夫法斯_ 本·奥夫法斯是一位全栈数据科学家，拥有超过 15 年的工作经验。他拥有计算与认知神经科学背景及博士学位，曾设计并执行细胞培养的湿实验，分析过包含数 TB 数据的实验，还在 IBM 超级计算机上运行过多达 6.4 万个核心的脑模型，构建过每日处理数百至数千笔交易的生产系统，并基于大量文本语料训练过语言模型。他是伦敦 Data Science Speakers 的联合创始人及前主席。\n\n_列昂尼德·库利金_ 列昂尼德·库利金是 Google Cloud 的一名资深 AI 工程师，专注于生成式 AI 和传统机器学习解决方案（如需求预测或优化问题）。他是 LangChain 上 Google Cloud 集成的主要维护者之一，同时也是 CDTM（慕尼黑工业大学和慕尼黑大学）的客座讲师。加入 Google 之前，列昂尼德曾在德国、俄罗斯和美国的科技、金融及零售企业中积累了超过 20 年的经验，负责构建基于复杂机器学习和数据处理技术的 B2C 和 B2B 应用，例如搜索、地图和投资管理。\n\n\n\n\u003C\u002Fdetails>","# Generative AI with LangChain 快速上手指南\n\n## 环境准备\n- **系统要求**：Python 3.12+（推荐使用 Python 3.12+）\n- **前置依赖**：需安装 `langchain`、`langgraph` 等库（使用国内镜像加速安装）\n\n## 安装步骤\n1. 克隆仓库（推荐使用 `v1` 分支，对应 LangChain v1.0+）：\n   ```bash\n   git clone -b v1 https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain.git\n   cd generative_ai_with_langchain\n   ```\n2. 安装依赖（使用清华镜像加速）：\n   ```bash\n   pip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n   ```\n3. 配置 API 密钥（参考 `SETUP.md`）：\n   - 在 `.env` 文件中设置 `OPENAI_API_KEY` 等密钥\n\n## 基本使用\n运行 Chapter 2 的基础示例：\n```bash\npython chapter2\u002Ffirst_steps.py\n```\n**输出示例**：\n```\nHello, how are you? -> I'm doing well, thank you! How can I assist you today?\n```\n\n> 提示：如需使用最新功能，确保选择 `v1` 分支；其他章节示例请参考对应目录（如 `chapter3\u002F`、`chapter4\u002F`）。","一家电商公司正为客服团队开发智能助手，用于实时处理客户咨询、订单查询和退货流程，但现有系统频繁崩溃且响应迟缓。\n\n### 没有 generative_ai_with_langchain 时\n- 系统响应延迟高，平均等待时间超10秒，客户流失率上升15%。\n- RAG管道设计粗糙，常推荐已下架商品，错误率高达40%。\n- 新功能（如退货流程）需重写核心逻辑，每次迭代耗时2周以上。\n- 缺乏实时监控，问题定位依赖人工排查，平均修复时间超4小时。\n- 部署到生产环境需手动配置API密钥和模型参数，每次更新耗时半天。\n\n### 使用 generative_ai_with_langchain 后\n- 通过LangGraph优化的混合搜索RAG管道，响应时间压缩至1.5秒内，客户等待体验显著改善。\n- 多代理架构实现智能错误处理与事实核查，推荐准确率提升至95%，错误率降至5%。\n- LangGraph的模块化工作流使退货流程集成仅需1天，迭代效率提高80%。\n- 内置的可观测性工具（如日志追踪和性能仪表盘）将问题定位时间缩短至30分钟。\n- 自动化部署脚本实现一键发布，生产环境更新从半天缩减至10分钟。\n\n核心价值在于让企业从原型开发无缝过渡到稳定高效的AI客服系统，真正实现“开箱即用”的生产级体验。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbenman1_generative_ai_with_langchain_66891de4.png","benman1","Ben Auffarth","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fbenman1_0a27ffe1.png","Ben has architected, developed, and deployed mission-critical systems in different industries and written bestselling technical books.","Chelsea AI Ventures","London, United Kingdom",null,"benji1a","https:\u002F\u002Fwww.chelseaai.co.uk\u002F","https:\u002F\u002Fgithub.com\u002Fbenman1",[25,29,33,37,41,45],{"name":26,"color":27,"percentage":28},"Jupyter Notebook","#DA5B0B",93.6,{"name":30,"color":31,"percentage":32},"Python","#3572A5",5.4,{"name":34,"color":35,"percentage":36},"HTML","#e34c26",0.9,{"name":38,"color":39,"percentage":40},"Dockerfile","#384d54",0.1,{"name":42,"color":43,"percentage":44},"Makefile","#427819",0,{"name":46,"color":47,"percentage":44},"Shell","#89e051",1317,540,"2026-04-03T10:27:49","MIT",3,"","未说明",{"notes":56,"python":57,"dependencies":58},"需要配置 LLM 服务提供商的 API keys（如 OpenAI、Anthropic 等），环境设置参考 SETUP.md 文件。","3.12+",[],[60,61,62,63],"开发框架","Agent","图像","语言模型",[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],"chatgpt","gpt","huggingface","langchain","llms","openai","claude","claude-3-5-sonnet","deepseek","deepseek-r1","ollama","agent","gpt-4o","langgraph","llamacpp","ready","2026-03-27T02:49:30.150509","2026-04-06T07:12:47.579027",[84,89,94,99,104,108],{"id":85,"question_zh":86,"answer_zh":87,"source_url":88},5180,"如何解决 'python_repl not found' 错误？","需要从 langchain_experimental.tools 导入 PythonREPLTool，示例代码：\nfrom langchain_experimental.tools import PythonREPLTool\ntools = [PythonREPLTool()]","https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Fissues\u002F29",{"id":90,"question_zh":91,"answer_zh":92,"source_url":93},5181,"Ubuntu 24.04 安装依赖时出现编译错误如何解决？","需安装 C++ 编译器，运行命令：\nsudo apt-get install g++\n或使用 conda 环境管理依赖","https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Fissues\u002F61",{"id":95,"question_zh":96,"answer_zh":97,"source_url":98},5182,"Docker 运行 notebook 时出现 PydanticUserError 如何修复？","需更新依赖库或显式调用模型重建，建议检查 langchain 版本并执行：\nChatOpenAI.model_rebuild()","https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Fissues\u002F76",{"id":100,"question_zh":101,"answer_zh":102,"source_url":103},5183,"OpenAI 模块找不到 'OpenAI' 属性如何解决？","需确认安装的是 LangChain 0.0.284 版本，且正确导入方式为：\nfrom langchain_openai import ChatOpenAI","https:\u002F\u002Fgithub.com\u002Fbenman1\u002Fgenerative_ai_with_langchain\u002Fissues\u002F36",{"id":105,"question_zh":106,"answer_zh":107,"source_url":93},5184,"如何处理 'Could not build wheels' 依赖问题？","建议使用 conda 环境安装依赖，或手动安装缺失的编译工具链（如 g++）",{"id":109,"question_zh":110,"answer_zh":111,"source_url":98},5185,"Docker 镜像更新后 notebook 无法运行如何修复？","需检查 langchain 版本兼容性，确保使用与书本配套的 0.0.284 版本并重新构建镜像",[],[114,122,131,139,147,160],{"id":115,"name":116,"github_repo":117,"description_zh":118,"stars":119,"difficulty_score":52,"last_commit_at":120,"category_tags":121,"status":80},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[60,62,61],{"id":123,"name":124,"github_repo":125,"description_zh":126,"stars":127,"difficulty_score":128,"last_commit_at":129,"category_tags":130,"status":80},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[60,61,63],{"id":132,"name":133,"github_repo":134,"description_zh":135,"stars":136,"difficulty_score":128,"last_commit_at":137,"category_tags":138,"status":80},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[60,62,61],{"id":140,"name":141,"github_repo":142,"description_zh":143,"stars":144,"difficulty_score":128,"last_commit_at":145,"category_tags":146,"status":80},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[60,63],{"id":148,"name":149,"github_repo":150,"description_zh":151,"stars":152,"difficulty_score":128,"last_commit_at":153,"category_tags":154,"status":80},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[62,155,156,157,61,158,63,60,159],"数据工具","视频","插件","其他","音频",{"id":161,"name":162,"github_repo":163,"description_zh":164,"stars":165,"difficulty_score":52,"last_commit_at":166,"category_tags":167,"status":80},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[61,62,60,63,158]]