https://github.com/The-Pocket/PocketFlow-Java
Pocket Flow: A minimalist LLM framework. Let Agents build Agents!
https://github.com/The-Pocket/PocketFlow-Java
Last synced: about 1 month ago
JSON representation
Pocket Flow: A minimalist LLM framework. Let Agents build Agents!
- Host: GitHub
- URL: https://github.com/The-Pocket/PocketFlow-Java
- Owner: The-Pocket
- License: mit
- Created: 2025-04-11T18:58:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-11T22:36:18.000Z (about 1 year ago)
- Last Synced: 2025-10-10T21:55:48.364Z (9 months ago)
- Language: Java
- Homepage:
- Size: 897 KB
- Stars: 23
- Watchers: 1
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - PocketFlow
README
# PocketFlow Java
A minimalist LLM framework, ported from Python to Java.
## Overview
PocketFlow Java is a direct port of the original [Python PocketFlow](https://github.com/The-Pocket/PocketFlow) framework. It provides a lightweight, flexible system for building and executing LLM-based workflows through a simple node-based architecture.
> **Note:** This is an initial implementation that currently does not support asynchronous operations. Community contributors are welcome to help enhance and maintain this project.
## Installation
### Maven
Add the following dependency to your `pom.xml`:
```xml
io.github.the-pocket
PocketFlow
1.0.0
```
### Gradle
**Groovy DSL (`build.gradle`):**
```groovy
dependencies {
implementation 'io.github.the-pocket:PocketFlow:1.0.0'
}
```
**Kotlin DSL (`build.gradle.kts`):**
```kotlin
dependencies {
implementation("io.github.the-pocket:PocketFlow:1.0.0")
}
```
## Usage
Here's a simple example of how to use PocketFlow Java in your application:
```java
import io.github.the_pocket.PocketFlow;
import io.github.the_pocket.PocketFlow.*;
import java.util.HashMap;
import java.util.Map;
public class MyWorkflowApp {
// Define a custom start node
static class MyStartNode extends Node {
@Override
public String exec(Void prepResult) {
System.out.println("Starting workflow...");
return "started";
}
}
// Define a custom end node
static class MyEndNode extends Node {
@Override
public String prep(Map ctx) {
return "Preparing to end workflow";
}
@Override
public Void exec(String prepResult) {
System.out.println("Ending workflow with: " + prepResult);
return null;
}
}
public static void main(String[] args) {
// Create instances of your nodes
MyStartNode startNode = new MyStartNode();
MyEndNode endNode = new MyEndNode();
// Connect the nodes
startNode.next(endNode, "started");
// Create a flow with the start node
Flow flow = new Flow<>(startNode);
// Create a context and run the flow
Map context = new HashMap<>();
System.out.println("Executing workflow...");
flow.run(context);
System.out.println("Workflow completed successfully.");
}
}
```
## Development
### Building the Project
```bash
mvn compile
```
### Running Tests
```bash
mvn test
```
## Contributing
Contributions are welcome! We're particularly looking for volunteers to:
1. Implement asynchronous operation support
2. Add comprehensive test coverage
3. Improve documentation and provide examples
Please feel free to submit pull requests or open issues for discussion.
## License
[MIT License](LICENSE)