pie 0.1.1

Programmable Inference Engine (PIE)
Documentation
interface core {

    // Import pollable functionality from the WASI IO poll package
    use wasi:io/poll@0.2.4.{pollable};

    // Returns the runtime version string
    get-version: func() -> string;

    // Returns a unique identifier for the running instance
    get-instance-id: func() -> string;

    // Retrieves POSIX-style CLI arguments passed to the inferlet from the remote user client
    get-arguments: func() -> list<string>;

    // Retrieve a model by name; returns None if not found
    get-model: func(name: string) -> option<model>;

    // Get a list of all available model names
    get-all-models: func() -> list<string>;

    // Get names of models that have all specified traits (e.g. "input_text", "tokenize")
    get-all-models-with-traits: func(traits: list<string>) -> list<string>;

    // Sends a message to the remote user client
    send: func(message: string);

    // Receives an incoming message from the remote user client
    receive: func() -> receive-result;

    // Publishes a message to a topic (broadcast to all subscribers)
    broadcast: func(topic: string, message: string);

    // Subscribes to a topic and returns a subscription handle
    subscribe: func(topic: string) -> subscription;

    // Retrieves a value from the persistent store for a given key.
    // Returns none if the key does not exist.
    store-get: func(key: string) -> option<string>;

    // Sets a value in the persistent store for a given key.
    // This will create a new entry or overwrite an existing one.
    store-set: func(key: string, value: string);

    // Deletes a key-value pair from the store.
    store-delete: func(key: string);

    // Checks if a key exists in the store.
    store-exists: func(key: string) -> bool;

    // Returns a list of all keys currently in the store.
    store-list-keys: func() -> list<string>;

    // Executes a debug command and returns the result as a string
    debug-query: func(query: string) -> debug-query-result;

    // Resource representing a specific model instance
    resource model {
        get-name: func() -> string;                  // Returns the model's name (e.g. "llama-3.1-8b-instruct")
        get-traits: func() -> list<string>;          // Returns the full set of model traits
        get-description: func() -> string;           // Human-readable description of the model
        get-version: func() -> string;               // Model version string (e.g. "1.0")
        get-license: func() -> string;               // License name (e.g. "Llama")
        get-prompt-template: func() -> string;       // Returns the prompt formatting template in Tera
        get-service-id: func() -> u32;
        create-queue: func() -> queue;               // Create a new command queue
    }

    // Defines task priority levels
    enum priority {
        low,        // Lowest priority
        normal,     // Default priority
        high,       // Highest priority
    }

    // Queue resource with methods for synchronization and priority control
    resource queue {
        get-service-id: func() -> u32;
        synchronize: func() -> synchronization-result; // Begin synchronization process
        set-priority: func(priority: priority);     // Change the queue's priority
        debug-query: func(query: string) -> debug-query-result;  // Sends a message to the model and returns the response
    }

    // Debug query response
    resource debug-query-result {
        pollable: func() -> pollable;
        get: func() -> option<string>;
    }

    // Result of a synchronization attempt
    resource synchronization-result {
        pollable: func() -> pollable;               // Returns a pollable for async readiness checks
        get: func() -> option<bool>;                // Returns true if sync succeeded, false if failed, none if not ready
    }

    // Result of an async receive operation
    resource receive-result {
        // Pollable to check readiness
        pollable: func() -> pollable;

        // Retrieves the message if available; None if not ready
        get: func() -> option<string>;
    }

    // Represents a subscription to a broadcast topic
    resource subscription {
        // Pollable to check for new messages on the topic
        pollable: func() -> pollable;

        // Retrieves a new message from the topic, if available
        get: func() -> option<string>;

        // Cancels the subscription
        unsubscribe: func();
    }
}