Chapter 10. LangGraph4j
In the previous two chapters, you learned how to use the LangChain4j project across multiple use cases—such as building chatbots, categorizing text, and developing RAG systems. Moreover, we introduced you to the vector embedding world, developing various use cases, such as clustering, all using the features of LangChain4j. However, you also saw that for certain advanced scenarios, LangChain4j alone isn’t enough.
When building complex, multiagent applications, you start involving many pieces, such as numerous prompts, tools, content retrievers, or RAG. Having all these pieces work together is a great feeling, but this approach comes with some challenges, as mentioned in the previous chapter:
-
Excluding unnecessary tokens—such as unused tools or irrelevant documents—which can slow the model, increase hallucination risk (models providing incorrect responses), and raise costs
-
Managing the state of various agents
-
Coordinating agents
-
Handling more-complex testing
-
Implementing complex behaviors to support human interaction or parallelization of processes
LangGraph4j addresses these problems by using cyclical graphs (we’ll call them graphs in this book for simplicity) to coordinate and execute one or more agents. In this chapter, you’ll learn LangGraph4j for implementing advanced AI applications that use multiple agents or require manual steps to continue their execution. Even though we are using LangGraph4j in this chapter, any other graph framework ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access