pub trait TextModel: Send + Sync {
// Required method
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 Prompt,
) -> Pin<Box<dyn Future<Output = Result<Completion, TextModelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn supports(&self, _tier: ModelTier, _capability: Capability) -> bool { ... }
}Expand description
Completes a prompt, over whichever provider the venture wired for the
Prompt::tier it was asked for. An adapter serves any tier it is
configured for (typically one); RoutingTextModel dispatches between
the adapters a venture configured.
Required Methods§
Sourcefn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 Prompt,
) -> Pin<Box<dyn Future<Output = Result<Completion, TextModelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 Prompt,
) -> Pin<Box<dyn Future<Output = Result<Completion, TextModelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Completes prompt.
Prompt::json_schema is a request: an adapter whose provider
cannot honour structured output answers with plain text in
Completion::text and None in Completion::json, rather than
failing the call.
Provided Methods§
Sourcefn supports(&self, _tier: ModelTier, _capability: Capability) -> bool
fn supports(&self, _tier: ModelTier, _capability: Capability) -> bool
Whether this adapter can do capability for a prompt routed to
tier. Defaults to false: a model that has not opted in is
refused a tools-bearing prompt by RoutingTextModel and
run_tool_loop before it is ever called,
rather than sent a request it would silently drop the tools from.
An adapter that carries Capability::Tools or
Capability::Images overrides this to answer true for it.
tier is the router’s own routing key, not the adapter’s: an
adapter serves whatever tier it was wired for and is free to ignore
it — an adapter only honours tier if the same deployment could be
wired for two tiers with different capabilities. The parameter is
on the method so a caller never has to ask the router which model a
tier holds just to ask what it can do.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".