orditect-stream
Streaming rich-media output plane for the Orditect ecosystem
orditect-stream is the output plane of the Orditect ecosystem: standard SSE
protocol, multi-stream mux, rich-media placeholders, disconnect strategies —
turning LLM streaming output into a governable, observable, recoverable
production capability.
Core Capabilities
- 🌊 Standard SSE protocol: stream.delta / enrich.* / stage.end /
stream.manifest (golden-test frozen schema; business extension only via
data.ext) - 🔀 Multi-stream mux: max_id concurrent sub-streams per request, per-stream monotonic seq
- 🖼️ Rich-media placeholders: in-stream image markers → placeholder → settle-window backfill / manifest delegation
- 🧠 thinking three modes: inline / separate / suppress (reasoning-model chain-of-thought handling)
- 🔌 Disconnect strategies: cancel / grace (grace-period reconnect) / continue
- ❌ Dual-mode cancel:
cancel()graceful (stops output, sem held until LLM ends) /cancel(force=True)forced (coroutine cancelled) - 🛡️ Resource governance: stage-level resource injection (default_stream_llm special holding semantics)
Installation
pip install orditect-stream[fastapi]
# depends on orditect-core>=0.1, orditect-flow>=0.1, orditect-protocol>=0.1
Quick Start
from orditect.stream import (
DEFAULT_CONFIG, EnrichMode, EventType, MockVectorEnricher,
SourceChunk, SourceRequest, StageConfig, SourceType, StreamRunner,
)
from orditect.stream.store import MemoryResultStore
class MyLLMSource:
async def stream(self, request: SourceRequest, cancel_token=None):
yield SourceChunk(text="正文![img]完")
yield SourceChunk(finish=True)
runner = StreamRunner(
stages=[StageConfig(name="main", source_type=SourceType.LLM, source=MyLLMSource())],
enricher=MockVectorEnricher(),
store=MemoryResultStore(),
config=DEFAULT_CONFIG.merge(enrich_mode=EnrichMode.LOCAL),
)
async for env, et in runner.run():
if et == EventType.STREAM_DELTA:
print(env.data.get("text"))
FastAPI integration
from fastapi import FastAPI, Request
from orditect.stream.fastapi import create_stream_response, make_refetch_router
app = FastAPI()
store = MemoryResultStore()
app.include_router(make_refetch_router(store))
@app.get("/stream")
async def stream(request: Request):
runner = StreamRunner(
stages=[...], enricher=..., store=store,
config=DEFAULT_CONFIG,
loading_url="https://oss.example.com/loading.jpg",
)
return create_stream_response(runner, request)
Cancel & partial content
# Graceful cancel (default): stop output, LLM connection kept, sem held until LLM ends
await runner.cancel(stream_id=sid, reason="user_interrupt")
# Forced cancel: coroutine cancelled, sem released immediately
await runner.cancel(stream_id=sid, force=True)
# Partial content not lost on cancel: delivered via stream.cancelled event,
# also queryable (for business-side history saving)
partial = runner.get_partial_content(sid)
Protocol-backed result store (v0.1.0)
from orditect.adapter.memory import MemoryStore
from orditect.stream.store import get_protocol_store
parts = MemoryStore()
store = get_protocol_store(parts.result, parts.result) # protocol result domain
# Production: swap in a commercial PG adapter's result part
Documentation
- Event protocol: SSE frame format & event schema (golden frozen) + pause/resume semantics decision
Testing
pytest tests/unit -v # pure logic
pytest -m golden # protocol snapshot
pytest tests/ -v # full suite
Related Projects
- orditect-core: governance engine (rate limiting, connection pool)
- orditect-flow: orchestration plane (enrich task backend, recovery)
- orditect-protocol: storage interaction contracts
License
Apache-2.0
Metadata
Release files for orditect-stream 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| orditect_stream-0.1.7.tar.gz | 57.3 kB | With provenance | Details for orditect_stream-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orditect_stream-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for orditect_stream-0.1.7-py3-none-any.whl |
Total release size: 132.4 kB
Release files / orditect_stream-0.1.7.tar.gz
| Download URL | orditect_stream-0.1.7.tar.gz |
|---|---|
| Size | 57.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f64694f68fb065e8872d96722e6a0bb675963e3220385e09d3123ff574b6f512
|
|
BLAKE2b-256 checksum How to use checksums |
a9dd892e35e05fbc83583a2054cd50df0f65c6f78c1155181c1c4e311fa42e77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logRelease files / orditect_stream-0.1.7-py3-none-any.whl
| Download URL | orditect_stream-0.1.7-py3-none-any.whl |
|---|---|
| Size | 75.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1599aea5ad4489b7a16f5c6457fe45dd7251ffbf4b3173b541ef760ea413c15
|
|
BLAKE2b-256 checksum How to use checksums |
dc9752f6ec85ce2c22a4ec0405e651e7f1d93aecc648ee2419e2d00fa4f43672
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logSecurity for orditect-stream 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for orditect_stream-0.1.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.