2022-10-08 10:30:12 +00:00
|
|
|
//! BLOOM Inference gRPC client library
|
|
|
|
|
|
|
|
mod client;
|
|
|
|
mod pb;
|
|
|
|
mod sharded_client;
|
|
|
|
|
|
|
|
pub use client::Client;
|
2022-10-11 14:50:54 +00:00
|
|
|
pub use pb::generate::v1::{Batch, GeneratedText, LogitsWarperParameters, Request};
|
2022-10-08 10:30:12 +00:00
|
|
|
pub use sharded_client::ShardedClient;
|
|
|
|
use thiserror::Error;
|
2022-10-17 12:59:00 +00:00
|
|
|
pub use tonic::transport;
|
2022-10-08 10:30:12 +00:00
|
|
|
use tonic::Status;
|
|
|
|
|
|
|
|
#[derive(Error, Debug, Clone)]
|
2022-10-17 12:59:00 +00:00
|
|
|
pub enum ClientError {
|
|
|
|
#[error("Could not connect to Text Generation server: {0:?}")]
|
|
|
|
Connection(String),
|
|
|
|
#[error("Server error: {0:?}")]
|
|
|
|
Generation(String),
|
2022-10-08 10:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Status> for ClientError {
|
|
|
|
fn from(err: Status) -> Self {
|
2022-10-17 12:59:00 +00:00
|
|
|
Self::Generation(err.to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<transport::Error> for ClientError {
|
|
|
|
fn from(err: transport::Error) -> Self {
|
|
|
|
Self::Connection(err.to_string())
|
2022-10-08 10:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Result<T> = std::result::Result<T, ClientError>;
|