Getting Started
Installation
Section titled “Installation”Install from PyPI:
pip install flexiflowOptional extras
Section titled “Optional extras”FlexiFlow ships with optional extras for common use cases:
pip install flexiflow[reload] # hot-reload with watchfilespip install flexiflow[api] # FastAPI integrationpip install flexiflow[dev] # pytest + coverageCLI usage
Section titled “CLI usage”The flexiflow CLI lets you register components, send messages, and hot-swap rules without writing Python.
Register and start a component
Section titled “Register and start a component”flexiflow register --config examples/config.yaml --startSend messages through the state machine
Section titled “Send messages through the state machine”flexiflow handle --config examples/config.yaml confirm --content confirmedflexiflow handle --config examples/config.yaml completeHot-swap rules at runtime
Section titled “Hot-swap rules at runtime”flexiflow update_rules --config examples/config.yaml examples/new_rules.yamlEmbedded Python usage
Section titled “Embedded Python usage”For programmatic control, use the engine directly:
from flexiflow.engine import FlexiFlowEnginefrom flexiflow.config_loader import ConfigLoader
config = ConfigLoader.load_component_config("config.yaml")engine = FlexiFlowEngine()
# Register and interactcomponent = engine.create_component(config)await engine.handle_message(component.name, "start")await engine.handle_message(component.name, "confirm", content="confirmed")Environment variable
Section titled “Environment variable”You can set FLEXIFLOW_CONFIG to point at your config file and omit --config from every CLI invocation:
export FLEXIFLOW_CONFIG=/path/to/config.yamlflexiflow register --startflexiflow handle confirmConfig introspection
Section titled “Config introspection”Before running anything, you can validate and inspect your configuration:
from flexiflow import explain
result = explain("config.yaml")if result.is_valid: print(result.format())This shows what components will be created, which states are registered, and flags any issues before you commit to a run.