tessera-command 0.4.21

The tesserax command: opens a recipe, then serves, fetches or runs tasks
Documentation
//! `serve`: answer OpenAI-shaped requests.

use crate::source::Source;
use tessera_frontend::tasks::Error;
use tessera_frontend::tasks::task::{Run, Sink, Task};

/// Start or run a text model as an OpenAI-compatible server.
#[derive(Task)]
#[task(kind = "generate", example = "start {model} as a server")]
pub(crate) struct Serve {
    /// Flags for the server and the model load.
    #[arg(extra)]
    pub flags: Vec<String>,
}

impl Run<Source> for Serve {
    fn run(self, source: Source, _: &mut dyn Sink) -> Result<(), Error> {
        let options = source.options(&self.flags)?;
        Ok(tessera_frontend::serve::start::run(options)?)
    }
}

crate::task::register!(Serve, crate::task::OnSource, "", true);