Generflow Python runtime — streams low-token UI specs over SSE, with HITL checkpoints, live data binding, action gating, and rewind/replay.
Project description
generflow-core
The Python runtime for Generflow — open-source generative UI.
Generflow solves four problems nobody else has solved together:
- Token-efficient UI description — GF-Lang is a streaming-friendly DSL that uses 57.6% fewer tokens than equivalent JSON (benchmarked, beats JSON on 10/10 widgets).
- Data-grounded rendering — components can declare
$refs to live data sources (REST, SQL, GraphQL, MCP). No fabricated numbers. - HITL hallucination mitigation — every render passes through a security boundary (component allow-list), and every action is gated by HITL checks (PII scan, missing source, ambiguity, low confidence).
- Cross-platform — Web Components + React + vanilla TS renderers. Same protocol, any framework.
Install
pip install generflow-core
Or with all dev extras:
pip install generflow-core[dev]
Quickstart (no API key)
from generflow_core.adapters import EchoAdapter
from generflow_core.spec import GFLangParser
from generflow_core.registry import Registry
import asyncio
async def main():
adapter = EchoAdapter()
registry = Registry()
parser = GFLangParser()
full = ""
async for chunk in adapter.stream("", "build a dashboard"):
full += chunk
for node in parser.feed_chunk(full):
if registry.has(node.name):
print(f" ✓ {node.name}")
asyncio.run(main())
Quickstart (real LLM)
export OPENAI_API_KEY=sk-...
python -m generflow_core.api.app # → http://localhost:7878
Then send a chat message:
curl -X POST http://localhost:7878/v1/stream \
-H "Content-Type: application/json" \
-d '{"message": "build a sales dashboard", "session_id": "demo"}'
CLI
The package ships a CLI for local-only rendering (no LLM, no API key):
generflow-render render dashboard.gf -o dashboard.html
generflow-render validate dashboard.gf
generflow-render diff before.gf after.gf
generflow-render to-a2ui dashboard.gf -o dashboard.a2ui.json
generflow-render from-a2ui incoming.a2ui.json -o spec.gf
Architecture
┌──────────────────┐ SSE ┌──────────────────┐
│ LLM Adapter │ ─────────▶ │ SSE /v1/stream │
│ (OpenAI/Anthro/ │ │ │
│ Echo) │ │ parser (Python) │
└──────────────────┘ │ │ │
│ ▼ │
│ Registry │
│ (allow-list) │
│ │ │
│ ▼ │
│ DataResolver │
│ (REST/SQL/GQL) │
│ │ │
│ ▼ │
│ HITL gates │
│ (PII/conf/etc) │
│ │ │
│ ▼ │
│ Action dispatch │
│ (intent → HTTP) │
└──────────────────┘
│
▼
SSE events: spec.line,
component.mount, data.fill,
hitl.request, action.request,
update, stream.end
Protocol
Generflow's protocol is a stream of typed SSE events. See the GF-Lang grammar and the event reference.
event: session.start
data: {"session_id":"demo","adapter":"openai"}
event: spec.line
data: {"path":"line:1","component":"Card","node":{...},"valid":true}
event: data.fill
data: {"ref":"monthly_revenue","ok":true,"value":[...]}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file generflow_core-0.2.0.tar.gz.
File metadata
- Download URL: generflow_core-0.2.0.tar.gz
- Upload date:
- Size: 49.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18b6f4eca031d55ca6d30ef1618931c4808b7f2d4dfe7fbf13fa434f6e0b2c99
|
|
| MD5 |
3e86884d166c67eb3e6f32107945c84c
|
|
| BLAKE2b-256 |
47ada0b3593130ca2a8de8ba3c1433059378a384dffc1404ee59d6bb9d5c5d57
|
File details
Details for the file generflow_core-0.2.0-py3-none-any.whl.
File metadata
- Download URL: generflow_core-0.2.0-py3-none-any.whl
- Upload date:
- Size: 50.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cef963f3c0f36e20f5cbf9033946397fd21504ca680880b5d30cc52167773328
|
|
| MD5 |
25e9b9f34b0ad5ab92c7dc2eedd43e06
|
|
| BLAKE2b-256 |
9333aa36581a9cd9f5ea8e5f65b0ba6236c9c507b849b69cb43684e595ae93d0
|