Skip to content

Commit aecd65e

Browse files
committedNov 15, 2024
docs: site refinement
1 parent 4ef6c3a commit aecd65e

38 files changed

+86
-12287
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ LangGraph for Java. A library for building stateful, multi-agents applications w
3131
- [x] Update state (_interact with the state directly and update it_)
3232
- [x] Breakpoints (_pause and resume feature_)
3333
- [x] [Studio] (_Playground Webapp_)
34+
- [X] Streaming response from LLM results
3435
- [ ] Parallel Node Execution
3536
- [ ] Child Graphs
36-
- [X] Streaming response from LLM results
3737

3838

3939
## Samples

‎core-jdk8/src/site/markdown/concepts/agentic_concepts_BAK.md

-91
This file was deleted.

‎core-jdk8/src/site/markdown/concepts/low_level.md

+19-18
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
At its core, LangGraph4j models agent workflows as graphs. You define the behavior of your agents using three key components:
66

7-
1. [`State`](#state): A shared data structure that represents the current snapshot of your application. It is represented by an [`AgentState`] object.
7+
1. [`State`](#State): A shared data structure that represents the current snapshot of your application. It is represented by an [`AgentState`] object.
88

9-
2. [`Nodes`](#nodes): A **Functional Interface** ([`AsyncNodeAction`]) that encode the logic of your agents. They receive the current `State` as input, perform some computation or side-effect, and return an updated `State`.
9+
2. [`Nodes`](#Nodes): A **Functional Interface** ([`AsyncNodeAction`]) that encode the logic of your agents. They receive the current `State` as input, perform some computation or side-effect, and return an updated `State`.
1010

11-
3. [`Edges`](#edges): A **Functional Interface** ([`AsyncEdgeAction`]) that determine which `Node` to execute next based on the current `State`. They can be conditional branches or fixed transitions.
11+
3. [`Edges`](#Edges): A **Functional Interface** ([`AsyncEdgeAction`]) that determine which `Node` to execute next based on the current `State`. They can be conditional branches or fixed transitions.
1212

1313
By composing `Nodes` and `Edges`, you can create complex, looping workflows that evolve the `State` over time. The real power, though, comes from how LangGraph4j manages that `State`.
1414
To emphasize: `Nodes` and `Edges` are like functions - they can contain an LLM or just Java code.
@@ -30,11 +30,12 @@ The [`StateGraph`] class is the main graph class to uses. This is parameterized
3030
3131
The `MessageGraph` class is a special type of graph. The `State` of a `MessageGraph` is ONLY an array of messages. This class is rarely used except for chatbots, as most applications require the `State` to be more complex than an array of messages.
3232
-->
33+
<a id="compiling-your-graph"></a>
3334
### Compiling your graph
3435

35-
To build your graph, you first define the [state](#state), you then add [nodes](#nodes) and [edges](#edges), and then you compile it. What exactly is compiling your graph and why is it needed?
36+
To build your graph, you first define the [state](#State), you then add [nodes](#Nodes) and [edges](#Edges), and then you compile it. What exactly is compiling your graph and why is it needed?
3637

37-
Compiling is a pretty simple step. It provides a few basic checks on the structure of your graph (no orphaned nodes, etc). It is also where you can specify runtime args like [checkpointers](#checkpointer) and [breakpoints](#breakpoints). You compile your graph by just calling the `.compile` method:
38+
Compiling is a pretty simple step. It provides a few basic checks on the structure of your graph (no orphaned nodes, etc). It is also where you can specify runtime args like [checkpointers](#Checkpointer) and [breakpoints](#Breakpoints). You compile your graph by just calling the `.compile` method:
3839

3940
```java
4041
// compile your graph
@@ -45,7 +46,7 @@ You **MUST** compile your graph before you can use it.
4546

4647
## State
4748

48-
The first thing you do when you define a graph is define the `State` of the graph. The `State` consists of the [schema of the graph](#schema) as well as [`reducer`](#reducers) functions which specify how to apply updates to the state. The schema of the `State` will be the input schema to all `Nodes` and `Edges` in the graph, and should be defined using a map of [`Channel`] object. All `Nodes` will emit updates to the `State` which are then applied using the specified `reducer` function.
49+
The first thing you do when you define a graph is define the `State` of the graph. The `State` consists of the [schema of the graph](#Schema) as well as [`reducer`](#Reducers) functions which specify how to apply updates to the state. The schema of the `State` will be the input schema to all `Nodes` and `Edges` in the graph, and should be defined using a map of [`Channel`] object. All `Nodes` will emit updates to the `State` which are then applied using the specified `reducer` function.
4950

5051
### Schema
5152

@@ -110,9 +111,9 @@ Currently the main class for state's serialization using built-in java stream is
110111
## Nodes
111112

112113
<!--
113-
In LangGraph4j, nodes are typically a **Functional Interface** ([`AsyncNodeAction`]) where the argument is the [state](#state), and (optionally), the **second** positional argument is a "config", containing optional [configurable parameters](#configuration) (such as a `thread_id`).
114+
In LangGraph4j, nodes are typically a **Functional Interface** ([`AsyncNodeAction`]) where the argument is the [state](#tate), and (optionally), the **second** positional argument is a "config", containing optional [configurable parameters](#configuration) (such as a `thread_id`).
114115
-->
115-
In LangGraph4j, nodes are typically a **Functional Interface** ([`AsyncNodeAction`]) where the argument is the [state](#state), you add these nodes to a graph using the [`addNode`] method:
116+
In LangGraph4j, nodes are typically a **Functional Interface** ([`AsyncNodeAction`]) where the argument is the [state](#State), you add these nodes to a graph using the [`addNode`] method:
116117

117118
```java
118119
import static org.bsc.langgraph4j.action.AsyncEdgeAction.edge_async;
@@ -145,6 +146,7 @@ var builder = new StateGraph( State::new )
145146

146147
Since [`AsyncNodeAction`] is designed to work with [`CompletableFuture`], you can use `node_async` static method that adapt it to a simpler syncronous scenario.
147148

149+
<a id="start-node"></a>
148150
### `START` Node
149151

150152
The `START` Node is a special node that represents the node sends user input to the graph. The main purpose for referencing this node is to determine which nodes should be called first.
@@ -154,7 +156,7 @@ import static org.bsc.langgraph4j.StateGraph.START;
154156

155157
graph.addEdge(START, "nodeA");
156158
```
157-
159+
<a id="end-node"></a>
158160
### `END` Node
159161

160162
The `END` Node is a special node that represents a terminal node. This node is referenced when you want to denote which edges have no actions after they are done.
@@ -181,6 +183,7 @@ Edges define how the logic is routed and how the graph decides to stop. This is
181183
<!-- 👉 PARALLEL
182184
A node can have MULTIPLE outgoing edges. If a node has multiple out-going edges, **all** of those destination nodes will be executed in parallel as a part of the next superstep. -->
183185

186+
<a id="normal-edges"></a>
184187
### Normal Edges
185188

186189
If you **always** want to go from node A to node B, you can use the [addEdge](/langgraphjs/reference/classes/langgraph.StateGraph.html#addEdge) method directly.
@@ -190,6 +193,7 @@ If you **always** want to go from node A to node B, you can use the [addEdge](/l
190193
graph.addEdge("nodeA", "nodeB");
191194
```
192195

196+
<a id="conditional-edges"></a>
193197
### Conditional Edges
194198

195199
If you want to **optionally** route to 1 or more edges (or optionally terminate), you can use the [`addConditionalEdges`] method. This method accepts the name of a node and a **Functional Interface** ([`AsyncEdgeAction`]) that will be used as " routing function" to call after that node is executed:
@@ -206,6 +210,7 @@ Similar to nodes, the `routingFunction` accept the current `state` of the graph
206210

207211
You must provide an object that maps the `routingFunction`'s output to the name of the next node.
208212
213+
<a id="entry-point"></a>
209214
### Entry Point
210215
211216
The entry point is the first node(s) that are run when the graph starts. You can use the [`addEdge`] method from the virtual `START` node to the first node to execute to specify where to enter the graph.
@@ -215,7 +220,7 @@ import static org.bsc.langgraph4j.StateGraph.START;
215220
216221
graph.addEdge(START, "nodeA");
217222
```
218-
223+
<a id="conditional-entry-point"></a>
219224
### Conditional Entry Point
220225
221226
A conditional entry point lets you start at different nodes depending on custom logic. You can use [`addConditionalEdges`] from the virtual `START` node to accomplish this.
@@ -275,7 +280,7 @@ See [this guide](../../how-tos/persistence.html) for how to use threads.
275280
<a id="checkpointer-state"></a>
276281
## Checkpointer state
277282
278-
When interacting with the checkpointer state, you must specify a [thread identifier](#threads). Each checkpoint saved by the checkpointer has two properties:
283+
When interacting with the checkpointer state, you must specify a [thread identifier](#Threads). Each checkpoint saved by the checkpointer has two properties:
279284
280285
- **state**: This is the value of the state at this point in time.
281286
- **nextNodeId**: This is the Idenfier of the node to execute next in the graph.
@@ -306,7 +311,7 @@ The config should contain `thread_id` specifying which thread to update.
306311
307312
**`values`**
308313
309-
These are the values that will be used to update the state. Note that this update is treated exactly as any update from a node is treated. This means that these values will be passed to the [reducer](#reducers) functions that are part of the state. So this does NOT automatically overwrite the state.
314+
These are the values that will be used to update the state. Note that this update is treated exactly as any update from a node is treated. This means that these values will be passed to the [reducer](#Reducers) functions that are part of the state. So this does NOT automatically overwrite the state.
310315
311316
**`asNode`**
312317
@@ -351,7 +356,7 @@ See [this guide](../how-tos/configuration.html) for a full breakdown on configur
351356
352357
It can often be useful to set breakpoints before or after certain nodes execute. This can be used to wait for human approval before continuing. These can be set when you ["compile" a graph](#compiling-your-graph). You can set breakpoints either _before_ a node executes (using `interruptBefore`) or after a node executes (using `interruptAfter`.)
353358
354-
You **MUST** use a [checkpoiner](#checkpointer) when using breakpoints. This is because your graph needs to be able to resume execution.
359+
You **MUST** use a [checkpoiner](#Checkpointer) when using breakpoints. This is because your graph needs to be able to resume execution.
355360
356361
In order to resume execution, you can just invoke your graph with `null` as the input.
357362
@@ -381,10 +386,6 @@ System.out.println(result.getContent());
381386
382387
```
383388
384-
## Streaming
385-
386-
LangGraph4j is built with first class support for streaming. it uses [java-async-generator] library to help with this.
387-
388389
<!--
389390
There are several different streaming modes that LangGraph4j supports:
390391
@@ -393,7 +394,7 @@ There are several different streaming modes that LangGraph4j supports:
393394
394395
In addition, you can use the [`streamEvents`](https://v02.api.js.langchain.com/classes/langchain_core_runnables.Runnable.html#streamEvents) method to stream back events that happen _inside_ nodes. This is useful for [streaming tokens of LLM calls](../how-tos/streaming-tokens-without-langchain.html). -->
395396
396-
[PlainTextStateSerializer]: /langgraph4j/apidocs//org/bsc/langgraph4j/serializer/plain_text/PlainTextStateSerializer.html
397+
[PlainTextStateSerializer]: /langgraph4j/apidocs/org/bsc/langgraph4j/serializer/plain_text/PlainTextStateSerializer.html
397398
[ObjectStreamStateSerializer]: /langgraph4j/apidocs/org/bsc/langgraph4j/serializer/std/ObjectStreamStateSerializer.html
398399
[Serializer]: /langgraph4j/apidocs/org/bsc/langgraph4j/serializer/Serializer.html
399400
[Reducer]: /langgraph4j/apidocs/org/bsc/langgraph4j/state/Reducer.html

0 commit comments

Comments
 (0)