Interface for models that can resolve intent volumes for various operations.

This interface extends intent-aware models with the ability to calculate appropriate volumes for specific intents (e.g., CALIBRATE, PRIME, FLUSH). Typically implemented by holder and pump models that have ingredient assignments and need to determine operation-specific volumes based on ingredient type, pump configuration, or operational requirements.

Use this interface in combination with IntentAware to create models that can both determine appropriate volumes and execute the operations.

Example

Using IntentContainer for calibration:

async function calibratePump(holder: HolderModel & IntentContainer) {
// Resolve appropriate calibration volume
const result = await holder.resolveIntentVolume("CALIBRATE");
console.log(`Calibration requires ${result.volume} oz`);

// Execute calibration with resolved volume
await holder.performIntent("CALIBRATE");
}

Example

Checking for ingredient assignment:

function canResolveVolume(model: IntentContainer): boolean {
return model.ingredientId !== undefined;
}

See

IntentAware for intent execution capabilities

interface IntentContainer {
    resolveIntentVolume(intent): Promise<{
        volume: number;
    }>;
    ingredientId?: string;
}

Properties

ingredientId?: string

Optional ingredient identifier for the assigned ingredient.

When undefined, no ingredient is assigned to this holder/pump and volume resolution operations may fail or return default values. Check this property before calling resolveIntentVolume to ensure an ingredient is assigned.

Example

Checking for assignment before resolving volume:

if (holder.ingredientId) {
const volume = await holder.resolveIntentVolume("CALIBRATE");
// Use volume...
} else {
console.log("No ingredient assigned - cannot calibrate");
}

Methods

  • Resolves the appropriate volume for a given intent operation.

    Different intents require different volumes based on operational requirements:

    • CALIBRATE: Standard calibration volume based on ingredient type and pump configuration
    • PRIME: Volume needed to prime the line from reservoir to dispense point
    • FLUSH: Cleaning volume to flush contaminants from the system
    • PURGE: Volume to completely clear the line

    The resolved volume is calculated based on:

    • Ingredient type and properties
    • Pump hardware configuration (line length, diameter)
    • Operational parameters (flow rates, pressure)
    • Device-specific calibration data

    Parameters

    • intent: string

      The intent string identifier (e.g., "CALIBRATE", "PRIME", "FLUSH")

    Returns Promise<{
        volume: number;
    }>

    Promise resolving to object with volume property in ounces (oz)

    Throws

    May reject if ingredient is not assigned or volume cannot be determined

    Example

    Resolving calibration volume:

    const result = await holder.resolveIntentVolume("CALIBRATE");
    console.log(`Calibration: ${result.volume} oz`);

    Example

    Handling volume resolution errors:

    try {
    const result = await holder.resolveIntentVolume("PRIME");
    displayVolume(result.volume);
    } catch (error) {
    console.error("Cannot resolve volume - ingredient may not be assigned");
    }