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