Skip to main content

Reliable language model orchestration. Type-safe with 100% test coverage.

Project description

ClearFlow

codecov PyPI Python 3.13+

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clearflow-0.0.4.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clearflow-0.0.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

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

Hashes for clearflow-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5ebe6d57121a0f4ea52b16c18e57d694e77df5156fa14197e62a4cb8471b8b8e
MD5 3105d7151c443bd165a3ea26e95f267e
BLAKE2b-256 ef55a72e9ddb20c482f359b1922a8ce5a250bd24aacb7ba0981214743d20f097

See more details on using hashes here.

Provenance

The following attestation bundles were made for clearflow-0.0.4.tar.gz:

Publisher: release.yml on consent-ai/ClearFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for clearflow-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4e5d601ada7b3c2c1c4bd497024a181ed5333f32e528d4942033299dbbe09e15
MD5 1b1c9566454b3c738730e8491e741b0a
BLAKE2b-256 3a26efb3531f4e5f82ba43d669b2ad63eae0cf0fe0608c39c7556e8106dc6e1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for clearflow-0.0.4-py3-none-any.whl:

Publisher: release.yml on consent-ai/ClearFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page