by czelabueno
Build programmatically custom agentic workflows, AI Agents, RAG systems for java
# Add to your Claude Code skills
git clone https://github.com/czelabueno/jai-workflowAn open-source Java library to build, package, integrate, orchestrate and monitor agentic AI systems for java developers š”

class MyStatefulBean extends AbstractStatefulBean {
private List<String> documents;
// other additional input/output fields that you want to store
}
StreamingChatLanguageModel model = OpenAiStreamingChatModel.builder()
.apiKey(System.getenv("OPENAI_API_KEY"))
.modelName(GPT_4_O_MINI)
.build();
var parserDocsNode = Node.from("Docs", obj -> transformDocsFromUrl(obj, uris));
var retrieveNode = Node.from("Vector DB", obj -> extractRelevantDocumentsFromVectorDB(obj));
var generateAnswerNode = StreamingNode.from("Generate",obj -> generateAnswer(obj), model);
var jAiWorkflow = new DefaultJAiWorkflow<MyStatefulBean>(
new MyStatefulBean(),
List.of(Transition.from(parserDocsNode, retrieveNode),
Transition.from(retrieveNode, Conditional.eval("enoughData",
obj -> obj.isEnoughData() ? generateAnswerNode : parserDocsNode,
List.of(parserDocsNode, generateAnswerNode))),
Transition.from(generateAnswerNode, WorkflowStateName.END)),
retrieveNode, // Start node
true // Run in streaming mode
);
// Chat with your JAiWorkflow
var question = "Summarizes the importance of building AI agentic systems";
Flux<String> response = jAiWorkflow.answerStream(question);
</details>
š Starring me: If you find this repository beneficial, don't forget to give it a star! š It's a simple way to show your appreciation and help this project grow!
JavAI Workflow (named initially Langchain4j-workflow) is a dynamic, stateful workflow engine crafted as a Java library. It empowers java developers with granular control over the orchestrated workflows as a graph, iteratively, with cycles, flexibility, control, and conditional decisions. This engine is a game-changer for building sophisticated AI applications, such as multiples RAG-based approaches using modern paradigms and agent architectures. It enables the crafting of custom behavior, leading to a significant reduction in hallucinations and an increase in response reliability.
jAI Workflow is influenced by [LangFlow](https://github.com/langf...