Skip to main content

ModelTask

Trait ModelTask 

Source
pub trait ModelTask: Send + Sync {
    type Input: Send + Sync;
    type Output: Serialize + DeserializeOwned + Clone + Send + Sync + 'static;

    // Required methods
    fn kind(&self) -> TaskKind;
    fn prompt_name(&self) -> &str;
    fn instructions(&self) -> &str;
    fn schema(&self, input: &Self::Input) -> Value;
    fn render(&self, input: &Self::Input) -> Vec<Message>;

    // Provided methods
    fn check(
        &self,
        _input: &Self::Input,
        _output: &Self::Output,
    ) -> Result<(), StructuralError> { ... }
    fn agree(&self, left: &Self::Output, right: &Self::Output) -> bool { ... }
}
Expand description

One narrow question put to a model.

Implementations are pure: they render messages and schemas from their input and check answers structurally. Everything about calling a model belongs to the engine.

Required Associated Types§

Source

type Input: Send + Sync

Everything the task’s context is built from.

Source

type Output: Serialize + DeserializeOwned + Clone + Send + Sync + 'static

The answer, as the schema allows it.

Required Methods§

Source

fn kind(&self) -> TaskKind

The task kind, which selects the profile and the route.

Source

fn prompt_name(&self) -> &str

The prompt name a prompt source is asked for, such as understand.segment.

Source

fn instructions(&self) -> &str

The built-in instructions, used when no source supplies the prompt.

Source

fn schema(&self, input: &Self::Input) -> Value

The answer’s JSON Schema for this input, with its closed sets filled in.

Source

fn render(&self, input: &Self::Input) -> Vec<Message>

The context messages, static parts first.

Provided Methods§

Source

fn check( &self, _input: &Self::Input, _output: &Self::Output, ) -> Result<(), StructuralError>

Structural checks the schema cannot express, such as a pointer in range.

§Errors

A StructuralError naming what is wrong, which a repair round quotes.

Source

fn agree(&self, left: &Self::Output, right: &Self::Output) -> bool

Whether two answers are the same answer, for voting.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§