Blocks & Adapters
Modular components (blocks) and adapters make LoomOS extensible for different model backends.Blocks are the building blocks of LoomOS extensibility. Adapters allow seamless integration with external model providers, custom runtimes, and new modalities. This page covers advanced usage, registry best practices, and troubleshooting.
Block Registry
Register, load, and benchmark model blocks.What is a Block?
A block is a reusable, versioned component: model, tokenizer, pre/postprocessor, or pipeline. Blocks are registered in the Block Registry with full metadata, compatibility checks, and version constraints. Block metadata fields:- name, version, author, description
- entry point (Python import path)
- requirements (PyPI dependencies, CUDA, etc.)
- supported input/output types
- tags (e.g. “vision”, “text”, “diffusion”)
Registering and loading blocks
Blocks can be registered programmatically or via manifest files. Example:Block manifest example
Benchmarking and compatibility
Blocks can be benchmarked for latency, throughput, and memory usage. The registry tracks compatibility with adapters and runtime environments. Best practices:- Use semantic versioning for all blocks
- Document input/output schemas
- Tag blocks for discoverability
Adapters
Adapter architecture
Adapters provide a thin, consistent interface to external model providers and runtimes. They standardize authentication, rate-limiting, streaming, batching, and error handling. Adapter features:- Unified async API for all providers
- Built-in retry and exponential backoff
- Cost and latency instrumentation
- Streaming and chunked response support
- Pluggable caching and batching
Supported adapters
- OpenAI: GPT-style providers (examples below use Loom AI API models by default)
- Hugging Face: Transformers, LoRA, quantized models
- Vision: CLIP, VLM, image classification
- Diffusion: Stable Diffusion, image-to-image, text-to-image
- Custom: Bring your own model with a Python entry point
Example: OpenAI Adapter (advanced)
Example: Hugging Face Adapter (advanced)
Example: Vision Adapter
Example: Diffusion Adapter
Adapter troubleshooting
- Timeouts: Increase
timeoutparameter or check network/firewall settings - Authentication errors: Verify API keys and permissions
- Model loading failures: Check device availability and model weights
- High latency: Enable caching, reduce batch size, or use quantized models
- Cost spikes: Set usage limits and monitor with cost instrumentation
Best practices
- Cache tokens and models to reduce latency and cost
- Use adapter-level rate limiting and backoff strategies
- Instrument adapters with cost metrics and usage tags
- Document adapter configuration and expected outputs
- Regularly update adapter dependencies for security and performance
Block Registry
The Block Registry stores metadata about reusable components (blocks) such as models, tokenizers, preprocessors, and postprocessors. Blocks have:- name, version, author, entry point, requirements
- compatibility checks and version constraints
Adapter patterns
Adapters provide a thin, consistent interface to external model providers and runtimes. They standardize authentication, rate-limiting, streaming, and batching.OpenAI Adapter
Example usageHugging Face Adapter
Example usageBest practices
- Cache tokens and models to reduce latency and cost
- Use adapter-level rate limiting and backoff strategies
- Instrument adapters with cost metrics and usage tags
