0.1.0 โข Published 5 months ago
pocketflowframework v0.1.0
๐ 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 pocketflowframework
Or 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/
0.1.0
5 months ago