pie 0.1.1

Programmable Inference Engine (PIE)
Documentation
use crate::bindings;
use crate::bindings::core;
use crate::instance::InstanceState;
use crate::model::Command;
use crate::object::IdRepr;
use wasmtime::component::Resource;
use wasmtime_wasi::p2::IoView;

impl bindings::pie::inferlet::input_image::Host for InstanceState {
    async fn embed_image(
        &mut self,
        queue: Resource<core::Queue>,
        emb_ids: Vec<IdRepr>,
        image_blob: Vec<u8>,
        _position_offset: u32, // Placeholder for position_offset
    ) -> anyhow::Result<()> {
        let inst_id = self.id();
        let q = self.table().get(&queue)?;
        Command::EmbedImage {
            inst_id,
            stream_id: q.stream_id,
            embs: emb_ids,
            image_blob,
        }
        .dispatch(q.service_id)?;
        Ok(())
    }

    async fn calculate_embed_size(
        &mut self,
        _queue: Resource<core::Queue>,
        _image_width: u32,
        _image_height: u32,
    ) -> anyhow::Result<u32> {
        // Placeholder implementation
        // This would typically involve a call to the model service
        // to determine the number of tokens/embeddings for a given image size.
        Ok(1024) // e.g., return a fixed size for now
    }
}