Skip to content

Commit 5ee97bb

Browse files
committed
Merge branch 'main' into develop
2 parents 6410ae8 + 562e74c commit 5ee97bb

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

README.md

+32-27
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,31 @@
1515
```xml
1616
<dependency>
1717
<groupId>org.bsc.langgraph4j</groupId>
18-
<artifactId>langgraph4j</artifactId>
18+
<artifactId>langgraph4j-jdk8</artifactId>
1919
<version>1.0-SNAPSHOT</version>
20-
<classifier>jdk8<classifier>
2120
<dependency>
2221
```
2322

2423
**JDK17 compliant**
25-
```xml
26-
<dependency>
27-
<groupId>org.bsc.langgraph4j</groupId>
28-
<artifactId>langgraph4j</artifactId>
29-
<version>1.0-SNAPSHOT</version>
30-
<classifier>jdk17<classifier>
31-
<dependency>
32-
```
24+
> _work in progress_
25+
3326

3427
### Define the agent state
3528

36-
The main type of graph in `langgraph` is the `StatefulGraph`. This graph is parameterized by a state object that it passes around to each node. Each node then returns operations to update that state. These operations can either SET specific attributes on the state (e.g. overwrite the existing values) or ADD to the existing attribute. Whether to set or add is denoted by initialize the property with a `AppendableValue`. The State must be compliant with `AgentState` interface that essentially is a `Map` wrapper.
29+
The main type of graph in `langgraph` is the `StatefulGraph`. This graph is parameterized by a state object that it passes around to each node.
30+
Each node then returns operations to update that state. These operations can either SET specific attributes on the state (e.g. overwrite the existing values) or ADD to the existing attribute.
31+
Whether to set or add is denoted by initialize the property with a `AppendableValue`. The State must inherit from `AgentState` base class (that essentially is a `Map` wrapper).
3732

3833
```java
39-
public interface AgentState {
34+
public class AgentState {
4035

41-
java.util.Map<String,Object> data();
36+
public AgentState( Map<String,Object> initData );
37+
38+
public final java.util.Map<String,Object> data();
39+
40+
public final <T> Optional<T> value(String key);
41+
42+
public final <T> AppendableValue<T> appendableValue(String key );
4243

4344
}
4445
```
@@ -73,22 +74,22 @@ Below you can find a piece of code of the `AgentExecutor` to give you an idea of
7374

7475
public static class State implements AgentState {
7576

76-
private final Map<String,Object> data;
77-
78-
public State( Map<String,Object> initData ) {
79-
this.data = new HashMap<>(initData);
80-
this.data.putIfAbsent("intermediate_steps",
81-
new AppendableValue<IntermediateStep>());
82-
}
83-
84-
public Map<String,Object> data() { return Map.copyOf(data); }
85-
86-
Optional<String> input() { return value("input"); }
87-
Optional<AgentOutcome> agentOutcome() { return value("agent_outcome"); }
88-
Optional<List<IntermediateStep>> intermediateSteps() { return appendableValue("intermediate_steps"); }
77+
public State(Map<String, Object> initData) {
78+
super(initData);
79+
}
80+
81+
Optional<String> input() {
82+
return value("input");
83+
}
84+
Optional<AgentOutcome> agentOutcome() {
85+
return value("agent_outcome");
86+
}
87+
AppendableValue<IntermediateStep> intermediateSteps() {
88+
return appendableValue("intermediate_steps");
89+
}
90+
8991
}
9092

91-
9293
var toolInfoList = ToolInfo.fromList( objectsWithTools );
9394

9495
final List<ToolSpecification> toolSpecifications = toolInfoList.stream()
@@ -130,6 +131,10 @@ var app = workflow.compile();
130131
return app.stream( inputs );
131132

132133
```
134+
## Samples
135+
136+
* [Agent Executor](agents-jdk8/src/main/java/dev/langchain4j/agentexecutor)
137+
* [Image To PlantUML Diagram](agents-jdk8/src/main/java/dev/langchain4j/image_to_diagram)
133138

134139
# References
135140

0 commit comments

Comments
 (0)