Reliable language model orchestration. Type-safe with 100% test coverage.
Project description
ClearFlow
Reliable language model orchestration. Type-safe with 100% test coverage.
Quick Example
from clearflow import Flow, Node, NodeResult
class ChatNode(Node[dict]):
async def exec(self, state: dict) -> NodeResult[dict]:
messages = state.get("messages", [])
# Call your language model here:
# response = await openai_client.chat.completions.create(messages=messages)
# content = response.choices[0].message.content
content = "Hello!" # Placeholder response
new_messages = [*messages, {"role": "assistant", "content": content}]
return NodeResult({**state, "messages": new_messages}, outcome="success")
# Build flow with explicit routing
chat = ChatNode()
flow = (
Flow[dict]("ChatBot")
.start_with(chat)
.route(chat, "success", None) # Single termination
.build()
)
result = await flow({"messages": []})
Installation
pip install clearflow
Why ClearFlow?
- <200 lines - Read the entire source in 5 minutes
- Zero dependencies - No bloat, no conflicts
- 100% tested - Every line covered, no surprises
- Type-safe - Catch errors at compile time, not production
- Composable - Build complex agents from simple pieces
Examples
- Chat - Language model conversation with state management
- Structured Output - Extract typed data from text
Contributing
See CONTRIBUTING.md
Acknowledgments
Inspired by PocketFlow's Node-Flow-State pattern.
License
MIT
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 clearflow-0.0.4.tar.gz.
File metadata
- Download URL: clearflow-0.0.4.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ebe6d57121a0f4ea52b16c18e57d694e77df5156fa14197e62a4cb8471b8b8e
|
|
| MD5 |
3105d7151c443bd165a3ea26e95f267e
|
|
| BLAKE2b-256 |
ef55a72e9ddb20c482f359b1922a8ce5a250bd24aacb7ba0981214743d20f097
|
Provenance
The following attestation bundles were made for clearflow-0.0.4.tar.gz:
Publisher:
release.yml on consent-ai/ClearFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clearflow-0.0.4.tar.gz -
Subject digest:
5ebe6d57121a0f4ea52b16c18e57d694e77df5156fa14197e62a4cb8471b8b8e - Sigstore transparency entry: 398106052
- Sigstore integration time:
-
Permalink:
consent-ai/ClearFlow@63f3444165870bf22620e374f1718c165de97476 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/consent-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@63f3444165870bf22620e374f1718c165de97476 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file clearflow-0.0.4-py3-none-any.whl.
File metadata
- Download URL: clearflow-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e5d601ada7b3c2c1c4bd497024a181ed5333f32e528d4942033299dbbe09e15
|
|
| MD5 |
1b1c9566454b3c738730e8491e741b0a
|
|
| BLAKE2b-256 |
3a26efb3531f4e5f82ba43d669b2ad63eae0cf0fe0608c39c7556e8106dc6e1b
|
Provenance
The following attestation bundles were made for clearflow-0.0.4-py3-none-any.whl:
Publisher:
release.yml on consent-ai/ClearFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clearflow-0.0.4-py3-none-any.whl -
Subject digest:
4e5d601ada7b3c2c1c4bd497024a181ed5333f32e528d4942033299dbbe09e15 - Sigstore transparency entry: 398106054
- Sigstore integration time:
-
Permalink:
consent-ai/ClearFlow@63f3444165870bf22620e374f1718c165de97476 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/consent-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@63f3444165870bf22620e374f1718c165de97476 -
Trigger Event:
workflow_dispatch
-
Statement type: