Remove dead code and fix typo
- Remove unused AUTH_SCOPE constant from client.rs - Remove unused ErrorType, ErrorInfoMetadata, FieldViolation, and Link types from types/error.rs - Fix "EventSourrce" typo in error.rs Display impl
This commit is contained in:
@@ -6,8 +6,6 @@ use tokio_stream::{Stream, StreamExt};
|
||||
use tokio_util::codec::LinesCodecError;
|
||||
use tracing::error;
|
||||
|
||||
pub static AUTH_SCOPE: &[&str] = &["https://www.googleapis.com/auth/cloud-platform"];
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GeminiClient {
|
||||
client: reqwest::Client,
|
||||
|
||||
@@ -34,7 +34,7 @@ impl Display for Error {
|
||||
write!(f, "No candidates returned for the prompt")
|
||||
}
|
||||
Error::EventSourceError(e) => {
|
||||
write!(f, "EventSourrce Error: {e}")
|
||||
write!(f, "EventSource Error: {e}")
|
||||
}
|
||||
Error::EventSourceClosedError => {
|
||||
write!(f, "EventSource closed error")
|
||||
|
||||
@@ -26,42 +26,12 @@ pub struct GeminiApiError {
|
||||
|
||||
impl core::fmt::Display for GeminiApiError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||
write!(f, "Gemini API Error {} - {}", self.error.code, self.error.message)
|
||||
write!(
|
||||
f,
|
||||
"Gemini API Error {} - {}",
|
||||
self.error.code, self.error.message
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for GeminiApiError {}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Link {
|
||||
pub description: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(tag = "@type")]
|
||||
pub enum ErrorType {
|
||||
#[serde(rename = "type.googleapis.com/google.rpc.ErrorInfo")]
|
||||
ErrorInfo { metadata: ErrorInfoMetadata },
|
||||
|
||||
#[serde(rename = "type.googleapis.com/google.rpc.Help")]
|
||||
Help { links: Vec<Link> },
|
||||
|
||||
#[serde(rename = "type.googleapis.com/google.rpc.BadRequest")]
|
||||
BadRequest {
|
||||
#[serde(rename = "fieldViolations")]
|
||||
field_violations: Vec<FieldViolation>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ErrorInfoMetadata {
|
||||
pub service: String,
|
||||
pub consumer: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct FieldViolation {
|
||||
pub field: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user