crate::ix!();
#[async_trait]
pub trait RetrieveBatchById: Send + Sync {
type Error;
async fn retrieve_batch(&self, batch_id: &str) -> Result<Batch, Self::Error>;
}
#[async_trait]
pub trait GetBatchFileContent: Send + Sync {
type Error;
async fn file_content(&self, file_id: &str) -> Result<Bytes, Self::Error>;
}
#[async_trait]
pub trait UploadBatchFileCore: Send + Sync {
type Error;
async fn upload_batch_file_path(
&self,
file_path: &Path
) -> Result<OpenAIFile, Self::Error>;
}
#[async_trait]
pub trait UploadBatchFileExt: UploadBatchFileCore {
async fn upload_batch_file<P>(
&self,
file_path: P
) -> Result<OpenAIFile, Self::Error>
where
P: AsRef<Path> + Send + Sync,
{
self.upload_batch_file_path(file_path.as_ref()).await
}
}
#[async_trait]
pub trait CreateBatch: Send + Sync {
type Error;
async fn create_batch(
&self,
input_file_id: &str,
) -> Result<Batch, Self::Error>;
}
#[async_trait]
pub trait WaitForBatchCompletion: Send + Sync {
type Error;
async fn wait_for_batch_completion(
&self,
batch_id: &str,
) -> Result<Batch, Self::Error>;
}
#[async_trait]
pub trait LanguageModelClientInterface<E: Debug>:
RetrieveBatchById<Error = E>
+ GetBatchFileContent<Error = E>
+ UploadBatchFileCore<Error = E>
+ CreateBatch<Error = E>
+ WaitForBatchCompletion<Error = E>
+ Send
+ Sync
+ Debug
{
}
pub trait GetLanguageModelClient<E> {
fn language_model_client(&self) -> Arc<dyn LanguageModelClientInterface<E>>;
}