pub trait AiService:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn model(&self) -> &str;
fn complete<'life0, 'async_trait>(
&'life0 self,
prompt: Prompt,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Inference, as a port.
Implementations live in adapters/origin-ai-*. Domain code never names a provider,
so switching one — or letting the user pick — changes the composition root and
nothing else.
Errors follow the usual model: a provider outage is ExternalService, a rejected
key is Authentication, a quota is RateLimited. Callers can therefore treat an
unavailable model exactly like an unavailable API.
Required Methods§
fn complete<'life0, 'async_trait>(
&'life0 self,
prompt: Prompt,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".