The future of applications is agentic. With the democratization of LLMs, the widespread adoption of multimodality, the ability to pack ever more intelligence into resource-constrained environments (the rise of Small Language Models), the emergence of numerous quality control and observability tools for LLM-based applications, and more... the nature of applications as we know them is undergoing a transformation. It's only a matter of time before all our interactions with computer systems are governed by artificial agents that are more flexible and more intelligent than linear programs.
An agentic application is one that can:
LangGraph is a framework for building agentic applications, characterized by great flexibility, theoretically adaptable to any business need. Today, let's take a closer look at a pattern that is both simple and powerful for achieving this: the ReAct pattern, which breaks down problems into three potentially cyclical steps:
LangGraph is built on top of Langchain, a very popular library for integrating LLMs into applications. A chain is an ordered sequence of calls to various tools, including LLMs, that produces a final result.
For example, a chain might correspond to the following process:
In this example, each step of the chain can be handled by a different LLM, specialized (fine-tuned) for a given task. What makes this paradigm so powerful is that you can also plug in external systems that aren't LLMs, as in this example:
Let's write our previous example chain with web search using LangChain.
First, we import the dependencies and then define our search query generation chain.
The next step is to create the chain for summarizing the search results:
Finally, we wire everything together with our LLM and can now ask it a question in natural language and get a response summarizing an automated web search!
This gives us a concise Markdown summary of the web search. As you can see, it's fairly easy to insert standard programmatic logic anywhere in a chain using the | character and to compose chains involving LLMs at any stage.
Chains already enable highly advanced processes, thanks to their natural language handling, and are interoperable with all kinds of systems, including legacy systems; however, they are limited by their linear nature because:
I like to think of Langchain chains as "units of work," intended to be orchestrated within more complex workflows: that's where LangGraph comes in.
We'll take our previous chain and integrate it into an agentic application following the ReAct pattern.
In this pattern, the LLM can decide to use the tools at its disposal based on the user's query. It can also decide to respond directly if it doesn't need any tools. Finally, the result of a tool call, if used, is fed back as input to the LLM, which can then use it to decide whether to respond directly or use the tools again.
This very simple mechanism enables rich and flexible interactions.
Let's reimplement our previous example in LangGraph. This time, our web search chain will simply be a tool available to the agent:
We get a response like =>
Based on the search results from September 2024, the latest hot LLMs include:\n\n1. OpenAI o1-preview\n2. Anthropic's Claude 3 Models\n3. Google Gemini 1.5 Pro\n4. AI21 Jamba 1.5 Large\n5. Stable LM 2\n\nThese models represent the cutting-edge of AI language understanding and generation, with significant advancements in performance across various tasks such as reasoning, question answering, and coding. The global large language model market is projected to grow substantially from $6.5 billion in 2024 to $140.8 billion by 2033, indicating the increasing importance and adoption of LLMs in different industries
If the agent had determined it already possessed the knowledge to answer the query, it could have responded directly without using the tools. Of course, this simple example doesn't include anti-hallucination fact-checking, and we only have one tool here (web search), but the idea is simply to show you the principle and how you can implement relatively complex logic with simple graphs using LangGraph.
You can:
Your imagination is your only limit!
Nota bene: I deliberately used
Ollamaand SLMs (small language models) here to demonstrate that it's possible to implement this kind of system in complete privacy on consumer-grade machines (for example, my laptop).
See you soon for more agentic adventures 🤖.
CTO de la scale-up LAMALO, Yacine est un développeur fullstack qui ne tient pas en place : JavaScript, Node.js, Python, LLM, voice UX... Toujours en veille, il transforme les dernières innovations en solutions concrètes !
LinkedInGet our best articles every month.
Le premier produit propre de Reboot Conseil. Une solution innovante née de la collaboration.
ProjectCréer une plateforme IA accessible sur web et mobile. Un projet combinant orchestration IA et mobilité.
ProjectRéduire le délai de conception bijoutière de 8 jours à 20 minutes grâce à l'IA générative et la modélisation 3D.
TrainingMaîtrisez les APIs, intégrez l'IA dans vos applications. Embeddings, fine-tuning, function calling.
ServiceFormateurs opérationnels. IA, data science, développement web. Certifié Qualiopi.
ArticlePère Castor, raconte-moi N8N N8N (prononcez « n-huit-n » ou « nodemation » si vous voulez faire classe). C'est un outil qui permet de connecter vos...