agent_core/client/
traits.rs

1use super::error::LlmError;
2use super::http::HttpClient;
3use super::models::{Message, MessageOptions, StreamEvent};
4use futures::Stream;
5use std::future::Future;
6use std::pin::Pin;
7
8pub trait LlmProvider {
9    /// Send a message to the LLM.
10    /// Returns the assistant's response message or an error.
11    fn send_msg(
12        &self,
13        client: &HttpClient,
14        messages: &[Message],
15        options: &MessageOptions,
16    ) -> Pin<Box<dyn Future<Output = Result<Message, LlmError>> + Send>>;
17
18    /// Send a streaming message to the LLM.
19    /// Returns a stream of events as they arrive from the API.
20    fn send_msg_stream(
21        &self,
22        _client: &HttpClient,
23        _messages: &[Message],
24        _options: &MessageOptions,
25    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, LlmError>> + Send>>, LlmError>> + Send>> {
26        Box::pin(async {
27            Err(LlmError::new(
28                "NOT_IMPLEMENTED",
29                "Streaming not supported for this provider",
30            ))
31        })
32    }
33}