How abn-apps/prompt-forge works
Prompt Forge turns a raw prompt into a clarified, enriched, optionally compressed prompt through either its CLI or HTTP API. The shared service starts or resumes a LangGraph session; the graph analyzes sufficiency, pauses for user answers when needed, compiles the prompt, then compresses it. Results include token estimates and compression metadata. The README documents optional LLMLingua compression and configurable DSPy models; config internals were not sampled, so their wiring is shown only where supported by the documented workflow.
Main entry points: service.py Session Service · graph.py Workflow Graph · cli.py CLI · api.py HTTP API
Components 16
User Interfaces
- CLI
src/prompt_forge/cli.py - HTTP API
src/prompt_forge/api.py - Refinement Result
src/prompt_forge/service.py
Session Runtime
- Session Service
src/prompt_forge/service.py - DSPy Config
src/prompt_forge/config.py - Workflow Graph
src/prompt_forge/graph.py - Session State
src/prompt_forge/state.py - Memory Checkpointer
src/prompt_forge/graph.py
Refinement Stages
- Sufficiency Analyzer
src/prompt_forge/analyzer.py - Clarification Pause
src/prompt_forge/nodes.py - Prompt Compiler
src/prompt_forge/compiler.py
Optimization
- Compression Stage
src/prompt_forge/compression.py - Token Estimates
src/prompt_forge/service.py
Other components
- Prompt User
- DSPy Model
- LLMLingua-2
Connections 20
- Prompt User → CLI: enters prompt
- Prompt User → HTTP API: submits prompt
- CLI → Session Service: starts / resumes
- HTTP API → Session Service: starts / resumes
- Session Service → DSPy Config: configures DSPy
- Session Service → Workflow Graph: compiles / invokes
- Session Service → Session State: initializes state
- Workflow Graph → Sufficiency Analyzer: dispatches analysis
- Workflow Graph → Clarification Pause: dispatches pause
- Workflow Graph → Prompt Compiler: dispatches compile
- Workflow Graph → Compression Stage: dispatches compression
- Workflow Graph → Memory Checkpointer: persists sessions
- Sufficiency Analyzer → DSPy Model: requests judgment
- Prompt Compiler → DSPy Model: requests enrichment
- Clarification Pause → Prompt User: asks / receives answers
- Compression Stage → LLMLingua-2: compresses prompt
- Session Service → Token Estimates: estimates tokens
- Session Service → Refinement Result: builds result
- Refinement Result → CLI: returns output
- Refinement Result → HTTP API: returns response