language_barrier_core/provider/
mod.rs

1use crate::error::Result;
2use crate::{Chat, Message, ModelInfo};
3
4use reqwest::Request;
5
6// Include the provider-specific modules
7pub mod anthropic;
8pub mod gemini;
9pub mod mistral;
10pub mod openai;
11
12/// An `HTTPProvider` can take a chat and turn it into an http request.
13pub trait HTTPProvider<M: ModelInfo>: Send + Sync {
14    /// Converts a chat into an HTTP request
15    ///
16    /// # Errors
17    ///
18    /// Returns an error if the chat cannot be converted to a request, for example
19    /// if the provider configuration is invalid or if serialization fails.
20    fn accept(&self, model: M, chat: &Chat) -> Result<Request>;
21
22    /// Parses a raw HTTP response into a message
23    ///
24    /// # Errors
25    ///
26    /// Returns an error if the response cannot be parsed, for example if the
27    /// response is not valid JSON or if it contains an error status.
28    fn parse(&self, raw_response_text: String) -> Result<Message>;
29}