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§
Required Methods§
Sourcefn prompt_name(&self) -> &str
fn prompt_name(&self) -> &str
The prompt name a prompt source is asked for, such as understand.segment.
Sourcefn instructions(&self) -> &str
fn instructions(&self) -> &str
The built-in instructions, used when no source supplies the prompt.
Provided Methods§
Sourcefn check(
&self,
_input: &Self::Input,
_output: &Self::Output,
) -> Result<(), StructuralError>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".