pocketflowframework
v0.1.0
Published
A modern flow framework for pocket-sized applications and LLM orchestration
Downloads
5
Maintainers
Readme
🚀 Pocket Flow Framework
Build enterprise-ready AI systems—fast, modular, and vendor-agnostic.
Why Pocket Flow?
Enterprises need automation. The typescript LLM framework capture what we see as the core abstraction of most LLM frameworks: A Nested Directed Graph that breaks down tasks into multiple (LLM) steps, with branching and recursion for agent-like decision-making.
From there, it's easy to layer on more complex features like Multi-Agents, Prompt Chaining, RAG, etc.
✨ Features
- 🔄 Nested Directed Graph - Each "node" is a simple, reusable unit
- 🔓 No Vendor Lock-In - Integrate any LLM or API without specialized wrappers
- 🔍 Built for Debuggability - Visualize workflows and handle state persistence
📦 Installation
You can install the package via npm:
npm install pocketflowframeworkOr using yarn:
yarn add pocketflowframework🔧 Usage
Here's a quick example of how to use the Pocket Flow Framework:
import { BaseNode, Flow } from 'pocketflowframework';
// Create a custom node
class GreetingNode extends BaseNode {
private greeting: string;
constructor(greeting: string) {
super();
this.greeting = greeting;
}
_clone(): BaseNode {
return new GreetingNode(this.greeting);
}
async prep(sharedState: any): Promise<any> {
return { user: sharedState.userName || 'World' };
}
async execCore(prepResult: any): Promise<any> {
return `${this.greeting}, ${prepResult.user}!`;
}
async post(prepResult: any, execResult: any, sharedState: any): Promise<string> {
console.log(execResult);
// Update shared state
sharedState.lastGreeting = execResult;
return 'default';
}
}
// Create a flow
const helloNode = new GreetingNode('Hello');
const hiNode = new GreetingNode('Hi');
helloNode.addSuccessor(hiNode);
const flow = new Flow(helloNode);
// Run the flow
(async () => {
const state = { userName: 'Pocket User' };
await flow.orchestrate(state);
console.log('Final state:', state);
})();Get Started
- Clone the Repo
git clone https://github.com/helenaeverleyz/pocket.git cd pocket - Check out documentation: https://the-pocket-world.github.io/Pocket-Flow-Framework/
