pocketflow/cookbook/pocketflow-streamlit-hitl
zachary62 966ced9dd1 update streamlit app 2025-05-25 19:54:10 -04:00
..
docs update streamlit hitl 2025-05-25 19:35:47 -04:00
utils update streamlit hitl 2025-05-25 19:35:47 -04:00
README.md update streamlit app 2025-05-25 19:54:10 -04:00
app.py update streamlit app 2025-05-25 19:54:10 -04:00
flow.py update streamlit nodes/flow 2025-05-25 19:39:17 -04:00
nodes.py update streamlit nodes/flow 2025-05-25 19:39:17 -04:00
requirements.txt streamlit example 2025-05-13 00:07:47 -04:00

README.md

PocketFlow Streamlit Image Generation HITL

Human-in-the-Loop (HITL) image generation application using PocketFlow and Streamlit. Enter text prompts, generate images with OpenAI, and approve/regenerate results.

Features

  • Image Generation: Uses OpenAI's gpt-image-1 model to generate images from text prompts
  • Human Review: Interactive interface to approve or regenerate images
  • State Machine: Clean state-based workflow (initial_inputuser_feedbackfinal)
  • PocketFlow Integration: Uses PocketFlow Node and Flow for image generation with built-in retries
  • Session State Management: Streamlit session state acts as PocketFlow's shared store
  • In-Memory Images: Images stored as base64 strings, no disk storage required

How to Run

  1. Set OpenAI API Key:

    export OPENAI_API_KEY="your-openai-api-key"
    
  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Run the Streamlit Application:

    streamlit run app.py
    
  4. Access the Web UI: Open the URL provided by Streamlit (usually http://localhost:8501).

Usage

  1. Enter Prompt: Describe the image you want to generate
  2. Generate: Click "Generate Image" to create the image
  3. Review: View the generated image and choose:
    • Approve: Accept the image and move to final result
    • Regenerate: Generate a new image with the same prompt
  4. Final: View approved image and optionally start over

Files