java langgraph-checkpoint

This commit is contained in:
Nuno Campos
2025-03-01 18:51:45 -08:00
parent c4275bdc32
commit 196bcfe08d
24 changed files with 2321 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
# LangGraph Java
A Java port of LangGraph, a framework for building stateful, observable applications with large language models (LLMs).
## Project Structure
- `langgraph-checkpoint`: Base persistence interfaces
- `langgraph-core`: Main library with channels, Pregel, and StateGraph
- `langgraph-examples`: Example applications
## Requirements
- Java 17 or higher
- Gradle 7.0 or higher
## Building
```bash
./gradlew build
```
## Features
- Graph-based architecture with nodes and edges
- Type-safe state schema using Java Records
- Cyclical execution patterns
- Checkpoint integration for persistence
- Streaming support
- Human-in-the-loop capabilities
## Usage Example
```java
// Create a graph with our schema
StateGraph<CounterState> graph = new StateGraph<>(CounterState.class);
// Add nodes
graph.addNode("increment", state -> {
Map<String, Object> updates = new HashMap<>();
updates.put("count", state.count() + 1);
return updates;
});
// Add edges
graph.addEdge(START, "increment");
graph.addEdge("increment", "check");
// Add conditional edge
graph.addConditionalEdges("check", state -> {
if (state.count() >= 3) {
return "finish";
}
return "increment";
});
// Compile and run
CompiledStateGraph<CounterState> compiled = graph.compile();
CounterState result = compiled.invoke(new CounterState(0, ""));
```
## License
This project is licensed under the MIT License - see the LICENSE file for details.