Creating workflows
Building AI Workflows with CogniBlocks
At the heart of CogniBlocks, individual Cognitive Units (Blocks) serve as the fundamental components for constructing AI-driven workflows. The platform includes a library of predefined modules, but users can also create, modify, and share custom Blocks to build scalable AI solutions.
By designing Blocks with modularity in mind, they can be reused across multiple workflows, enabling a seamless drag-and-drop development experience. CogniBlocks also integrates AI-assisted coding to streamline modifications directly within the platform, ensuring efficiency without requiring external tools.
Below, we explore the core components of Blocks, how they function, and how users can create or modify them.
Understanding Block Components
Each CogniBlock consists of different elements depending on its function. There are three primary types of Blocks:
1️⃣ Parameter Blocks
Define input values for workflows.
No input nodes—values are manually set via the UI.
Examples: File Input, Text, Number, List, Boolean.
2️⃣ Processing Blocks
Contain the core logic of AI operations.
Accept multiple inputs and generate processed outputs.
Examples: Train Model, Edge Detection, Data Transformation.
3️⃣ Visualization Blocks
Render graphical representations of outputs.
Display results in real time based on defined logic.
Examples: Graph Renderer, Image Viewer, Data Plotter.
Each Block is saved in a directory that mirrors its name inside:
📂 workspace/modules/blocks/{block-name}
Structure of a Block
Each Block is composed of multiple files, depending on its type. Below is an overview of the key components:
Parameter Block Components
specs.json – Defines the Block’s configuration and parameters. 📂 workspace/modules/blocks/{block-name}/specs.json
Processing Block Components
A Processing Block includes five essential files:
📄 computations.py
Contains the compute() function, which processes inputs and generates outputs.
Includes a test() function to validate computations.
📄 Dockerfile
Defines the environment setup for execution.
Always includes:
COPY computations.py ..
📄 requirements.txt
Lists required dependencies for execution.
📄 run_test.py
Builds a test container and runs validation scripts.
📄 specs.json
Stores the Block’s metadata and structure.
Visualization Block Components
Visualization Blocks extend Processing Blocks by rendering results dynamically. These Blocks include:
computations.py
(with HTML-based visualization logic)Dockerfile
requirements.txt
run_test.py
specs.json
Creating New Blocks
To develop a custom Block, use the prebuilt templates available in the Component Library.
Steps to Create a New Block:
1️⃣ Drag a template Block (e.g., "New Python") into the workspace. 2️⃣ Modify its logic within the Block Editor. 3️⃣ Save changes and compile the Block.
Modifying Blocks with the Code Editor
To edit an existing Block:
Click the </> icon on the Block header to open the Code Editor Sidebar.
Modify the compute() function within computations.py.
Save changes and recompile the Block.
Block Templates
Processing Block Template
Visualization Block Template
🔹 Note: The compute()
function always returns a dictionary where keys match output node names in specs.json
.
Compiling & Saving Blocks
Once modifications are complete, recompile the Block using:
📷 (compile-run-block-editor.png)
Compile Block Files – Saves all changes.
Compile & Run Block – Saves changes and executes validation tests.
💡 Next Steps: Dive deeper into the CogniBlocks Editor Guide for advanced customization techniques.
🚀 Now you're ready to build and integrate your own CogniBlocks components!
Last updated