Spaces:
Runtime error
Runtime error
| //! Text Generation gRPC client library | |
| mod client; | |
| mod pb; | |
| mod sharded_client; | |
| pub use client::Client; | |
| pub use pb::generate::v1::HealthResponse; | |
| pub use pb::generate::v1::InfoResponse as ShardInfo; | |
| pub use pb::generate::v1::{ | |
| Batch, FinishReason, GeneratedText, Generation, NextTokenChooserParameters, PrefillTokens, | |
| Request, StoppingCriteriaParameters, | |
| }; | |
| pub use sharded_client::ShardedClient; | |
| use thiserror::Error; | |
| use tonic::transport; | |
| use tonic::Status; | |
| pub enum ClientError { | |
| Connection(String), | |
| Generation(String), | |
| } | |
| impl From<Status> for ClientError { | |
| fn from(err: Status) -> Self { | |
| let err = Self::Generation(err.message().to_string()); | |
| tracing::error!("{err}"); | |
| err | |
| } | |
| } | |
| impl From<transport::Error> for ClientError { | |
| fn from(err: transport::Error) -> Self { | |
| let err = Self::Connection(err.to_string()); | |
| tracing::error!("{err}"); | |
| err | |
| } | |
| } | |
| pub type Result<T> = std::result::Result<T, ClientError>; | |