pub trait PromptExecutionProvider: Send + Sync {
type Message: Send + Sync + 'static;
// Required method
fn prompt_execute<'a, 'p, P>(
&'a self,
prompt: P,
) -> BoxedResponseFut<'p, P::Output>
where P: PromptTemplate + Send + Sync + 'p,
<P as IntoPrompt>::Message: Into<Self::Message>,
'a: 'p;
}Expand description
A backend turns a prompt into a network call to a concrete provider (OpenAI, Ollama, Anthropic, …) and parses the structured response.
The trait is intentionally minimal:
- One associated type – the in-memory
Messagerepresentation this provider accepts. - One async-ish method –
complete, which performs a single non-streaming round-trip and returns a value whose type is dictated by thePromptTemplate.
The method returns a Pin<Box<dyn Future>> so we stay object-safe
without pulling in async_trait.
Required Associated Types§
Required Methods§
Sourcefn prompt_execute<'a, 'p, P>(
&'a self,
prompt: P,
) -> BoxedResponseFut<'p, P::Output>where
P: PromptTemplate + Send + Sync + 'p,
<P as IntoPrompt>::Message: Into<Self::Message>,
'a: 'p,
fn prompt_execute<'a, 'p, P>(
&'a self,
prompt: P,
) -> BoxedResponseFut<'p, P::Output>where
P: PromptTemplate + Send + Sync + 'p,
<P as IntoPrompt>::Message: Into<Self::Message>,
'a: 'p,
Execute the prompt and deserialize the provider’s reply into
P::Output.
The blanket constraint P: PromptTemplate<Message = Self::Message>
guarantees at compile time that callers only feed the backend
messages it understands.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.