Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ritz541/flower-engine/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Theengine/utils.py module provides utility functions for building WebSocket JSON payloads and loading YAML asset files from the filesystem.
Functions
build_ws_payload
Constructs a standardized WebSocket JSON message following the Flower Engine protocol.Event type (e.g.,
sync_state, chat_chunk, system_update, error)Main message content (can be empty string for metadata-only events)
Optional metadata dictionary (defaults to empty dict if not provided)
engine/utils.py:7-14
engine/main.py- All WebSocket communicationengine/commands.py- Command responsesengine/handlers.py- State synchronizationengine/llm.py- Streaming chat responses
load_yaml_assets
Loads and parses YAML asset files matching a glob pattern, returning valid assets with anid field.
Glob pattern for YAML files (e.g.,
assets/worlds/*.yaml)id field
Behavior:
- Expands glob pattern to find matching files
- Sorts files alphabetically
- Attempts to parse each file as YAML
- Validates that
idfield exists - Logs errors for files that fail to load
- Returns only successfully loaded assets
engine/utils.py:16-27
engine/state.py- Loading available worlds, characters, and rules at startupengine/main.py- Syncing YAML assets to database during startup
- Silently skips files that fail to parse
- Logs error message with file path and exception
- Returns empty list if no valid assets found
Asset File Requirements
For a YAML file to be loaded successfully:- Must be valid YAML syntax
- Must contain an
idfield at the root level - File must be readable with UTF-8 encoding
Dependencies
json- JSON serialization for WebSocket messagesyaml- YAML parsing viayaml.safe_load()glob- File pattern matchingtyping- Type hintsengine.logger.log- Error logging
Related
WebSocket Protocol
Message format specification
Asset Schemas
YAML file formats
State Management
Asset loading at startup
Handlers
Functions that use build_ws_payload