0.1.0 โ€ข Published 5 months ago

pocketflowframework v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

License: MIT Docs npm version

๐Ÿš€ 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

  1. Clone the Repo

    git clone https://github.com/helenaeverleyz/pocket.git
    cd pocket
  2. Check out documentation: https://the-pocket-world.github.io/Pocket-Flow-Framework/