mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-28 08:08:50 +00:00
1.8 KiB
1.8 KiB
Lollms Flow Library - Quick Reference
Core Classes
-
WorkflowNode
: Represents a single node in the workflow.- Constructor:
new WorkflowNode(id, name, inputs, outputs, operation, options, x, y)
- Key methods:
connect()
,execute()
,toJSON()
,fromJSON()
- Constructor:
-
Workflow
: Manages the entire workflow.- Key methods:
addNode()
,connectNodes()
,execute()
,toJSON()
,fromJSON()
- Key methods:
-
WorkflowVisualizer
: Handles visualization using SVG.- Constructor:
new WorkflowVisualizer(containerId)
- Key methods:
addNode()
,connectNodes()
,execute()
,saveToJSON()
,loadFromJSON()
- Constructor:
Basic Usage
-
Create a visualizer:
const visualizer = new WorkflowVisualizer('container-id');
-
Define node operations:
const nodeOperations = { 'OperationName': (inputs, options) => ({ output: result }) };
-
Create and add nodes:
const node = new WorkflowNode(id, name, inputs, outputs, operation, options); visualizer.addNode(node);
-
Connect nodes:
visualizer.connectNodes(sourceId, sourceOutput, targetId, targetInput);
-
Execute workflow:
const results = visualizer.execute();
-
Save/Load workflow:
const json = visualizer.saveToJSON(); visualizer.loadFromJSON(json, nodeOperations);
Key Features
- SVG-based visualization with drag-and-drop
- Interactive socket connections
- Node options (checkbox, radio, select, file, textarea)
- JSON serialization and local storage integration
- Custom node and socket colors
- Event handling for interactivity
Best Practices
- Use unique node IDs
- Define clear input/output types
- Implement error handling in operations
- Use descriptive names for nodes and sockets