Introduction
The nrvna-ai C++ library provides a simple, filesystem-based asynchronous inference primitive. It enables applications to submit AI inference jobs and retrieve results through a workspace directory, decoupling job submission from processing.Core Components
The library consists of four main classes:Work
TheWork class handles job submission. It creates job requests in the workspace directory with prompts, images, and metadata.
Flow
TheFlow class retrieves job results and monitors status. It reads completed jobs from the workspace.
Server
TheServer class processes submitted jobs using AI models. It runs worker threads that scan the workspace and execute inference.
Types
Core type definitions includingStatus, JobId, JobType, and result structures.
Namespace
All classes and types are defined in thenrvnaai namespace:
Workspace Structure
The library uses a filesystem workspace to coordinate between job submitters and processors:- Jobs are submitted as directories in the workspace
- Each job directory contains
prompt.txt,type, and optional image files - Results are written to
result.txtorerror.txt - Status is tracked through directory states (queued, running, done, failed)
Thread Safety
TheWork and Flow classes are move-only and not thread-safe. Create separate instances per thread if needed. The Server class manages its own internal threading.
Error Handling
The library uses result types and optional values for error handling:SubmitResultfor job submission operationsstd::optional<Job>for retrieval operations- Status enums for job state tracking