From 42d952ea70e4d4b79d0eded9f5b10cda05c67e01 Mon Sep 17 00:00:00 2001 From: vbarda Date: Tue, 11 Jun 2024 14:53:45 -0400 Subject: [PATCH] expand compilation --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 70141e320..42174f805 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ final_state["messages"][-1].content - we define the tools we want to use -- a web search tool in our case. It is really easy to create your own tools - see documentation here on how to do that [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools). 2.
- Initialize graph with state + Initialize graph with state. - we initialize graph (`StateGraph`) by passing state schema (in our case `MessagesState`) - `MessagesState` is a prebuilt state schema that has one attribute -- a list of LangChain `Message` objects, as well as logic for merging the updates from each node into the state @@ -168,7 +168,7 @@ final_state["messages"][-1].content - The `tools` node that invokes tools: if the agent decides to take an action, this node will then execute that action.
4.
- Define entry point and graph edges + Define entry point and graph edges. First, we need to set the entry point for graph execution - `agent` node. @@ -182,10 +182,12 @@ final_state["messages"][-1].content 5.
Compile the graph. - When we compile the graph, we are translating it to low-level [Pregel](https://research.google/pubs/pregel-a-system-for-large-scale-graph-processing/) operations + - When we compile the graph, we turn it into a LangChain [Runnable](https://python.langchain.com/v0.2/docs/concepts/#runnable-interface), which automaticall enables calling `.invoke()`, `.stream()` and `.batch()` with your inputs + - We can also optionally pass checkpointer object for persisting state between graph runs, and enabling memory, human-in-the-loop workflows, time travel and more. In our case we use `MemorySaver` - a simple in-memory checkpointer + - Compiling graph translates it to low-level [Pregel](https://research.google/pubs/pregel-a-system-for-large-scale-graph-processing/) operations
6.
- Execute the graph + Execute the graph. 1. LangGraph adds the input message to the internal state, then passes the state to the entrypoint node, `"agent"`. 2. The `"agent"` node executes, invoking the chat model.