ChatCompletionProvider

Trait ChatCompletionProvider 

Source
pub trait ChatCompletionProvider: Send + Sync {
    type Message: Send + Sync + 'static;

    // Required method
    fn chat_complete<'p, M>(
        &self,
        params: ChatCompleteParameters<M>,
    ) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<GenericMessage>>> + Send + 'p>>
       where M: Into<Self::Message> + Clone + Send + Sync + 'p;
}
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 Message representation this provider accepts.
  • One async-ish methodchat_complete, which performs a single non-streaming round-trip and returns a value whose type is dictated by the PromptTemplate.

Required Associated Types§

Source

type Message: Send + Sync + 'static

Chat message type consumed by this backend.

Required Methods§

Source

fn chat_complete<'p, M>( &self, params: ChatCompleteParameters<M>, ) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<GenericMessage>>> + Send + 'p>>
where M: Into<Self::Message> + Clone + Send + Sync + 'p,

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.

Implementors§