Skip to content

st_flow API Reference

The st_flow function is designed for creating and managing flow-based UI editors in Streamlit applications. It combines a collection of base blocks, editor schemas, and command functionalities to build and interact with a dynamic flow editor.

Function barfi.flow.streamlit.st_flow

Parameters

  • blocks (Union[List[Block], Dict[str, List[Block]]]): The foundational blocks that define the structure of the flow editor. Can be provided as:

    • A list of Block instances
    • A dictionary where keys are categories and values are lists of blocks
  • editor_schema (FlowSchema, optional): The schema defining the structure of the editor. Default configuration:

    • version: Schema version
    • nodes: Empty list of nodes
    • connections: Empty list of connections
    • viewport: Default viewport (x=0, y=0, zoom=1)
  • commands (List[str], optional): List of available editor commands. Defaults to:

    • “execute”
    • “save”
  • key (Any, optional): Unique identifier for the Streamlit component instance

Returns

Returns a StreamlitFlowResponse object. The contains the command and editor_schema.

Example

from barfi.flow import Block
from barfi.flow.streamlit import st_flow
 
# Basic Blocks as a list
base_blocks = [
    Block(id="1", type="start"),
    Block(id="2", type="end"),
]
# ... OR ...
# Categorized Blocks with Custom Commands
base_blocks = {
    "inputs": [Block(id="1", type="text_input")],
    "outputs": [Block(id="2", type="text_output")],
}
 
response = st_flow(blocks=base_blocks)