Skip to content

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.

License

Notifications You must be signed in to change notification settings

benman1/generative_ai_with_langchain

Repository files navigation

Generative AI with LangChain, Second Edition

This is the code repository for Generative AI with LangChain, Second Edition, published by Packt.

Build production ready LLM applications and advanced agents using Python and LangGraph

Ben Auffarth, Leonid Kuligin

      Free PDF       Graphic Bundle       Amazon      

About the book

Generative AI with LangChain, 2nd Edition (2025)

This 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. You'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. Whether 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.

Key Learnings

  • Design and implement refined multi-agent systems using LangGraph
  • Enterprise-grade testing and evaluation frameworks for LLM applications
  • Deploy production-ready observability and monitoring solutions
  • Build RAG systems with hybrid search and re-ranking capabilities
  • Implement agents for software development and data analysis
  • Work with latest LLMs and providers Google Gemini, Anthropic and Mistral, DeepSeek, and OpenAI o3-mini
  • Optimize cost and performance across different deployment types
  • Design secure, compliant AI systems with current best practices

Note to Readers

Thank you for choosing "Generative AI with LangChain"! We appreciate your enthusiasm and feedback.

Please note that we've released several updated versions of the book. Consequently, there are three different branches for this repository:

  • 2nd edition - this is for the 2nd edition of the book, corresponding to ver 0.3 of LangChain.
  • softupdate - this is for the soft update of the book (2024), corresponding to ver 0.1.13 of LangChain.
  • main - this is the original version of the book (December 2023).

Please refer to the version that you are interested in or that corresponds to your version of the book.

Download a free PDF Coding

Download a free PDF Coding

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. Free-Ebook Coding

We provide a PDF file that has color images of the screenshots/diagrams used in this book at GraphicBundle Coding

Commitment

Code Updates: 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.

Expect Stability: 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.

How to Reach Us: 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. Thank you for your understanding and happy coding!

Know more on the Discord server Coding

You can engage with the author and other readers on the discord server and find latest updates and discussions in the community at Discord

Chapters

In 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.

Chapter Title Directory Link
Chapter 1 The Rise of Generative AI: From Language Models to Agents chapter1/
Chapter 2 First Steps with LangChain chapter2/
Chapter 3 Building Workflows with LangGraph chapter3/
Chapter 4 Building Intelligent RAG Systems with LangChain chapter4/
Chapter 5 Building Intelligent Agents chapter5/
Chapter 6 Advanced Applications and Multi-Agent Systems chapter6/
Chapter 7 Software Development and Data Analysis Agents chapter7/
Chapter 8 Evaluation and Testing of LLM Applications chapter8/
Chapter 9 Production Deployment and Observability chapter9/

Requirements for this book

Software and hardware list

This is the companion repository for the book. Here are a few instructions that help getting set up. Please also see chapter 2.

All chapters rely on Python.

Please check the instructions for setting up the environment either in the book or here. 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.

👋 Contribute

We welcome contributions from developers of all levels. If you'd like to contribute, please check our contributing guidelines and help make this repository and the book more accessible.


Star History Chart

❤️ Contributors

repo contributors

Get to know Authors

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.

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.

About

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8