pub trait ChatCompletionProvider: Send + Sync {
type Message: Send + Sync + 'static;
// Required method
fn chat_complete<'s, M>(
&'s self,
params: ChatCompleteParameters<M>,
) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<GenericMessage>>> + Send + 's>>
where M: Into<Self::Message> + Clone + Send + Sync + 's;
}Expand description
A backend turns a chat prompt into a network call to a concrete provider (OpenAI, Ollama, Anthropic, …) and parses the structured chat response.
The trait is intentionally minimal:
- One associated type – the in-memory
Messagerepresentation this provider accepts. - One async-ish method –
chat_complete, which performs a single non-streaming round-trip and returns a value whose type is dictated by thePromptTemplate.
Required Associated Types§
Required Methods§
Sourcefn chat_complete<'s, M>(
&'s self,
params: ChatCompleteParameters<M>,
) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<GenericMessage>>> + Send + 's>>
fn chat_complete<'s, M>( &'s self, params: ChatCompleteParameters<M>, ) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<GenericMessage>>> + Send + 's>>
Execute the chat prompt and deserialize the provider’s reply into
P::Output.
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.