Run cargo clippy --fix
This commit is contained in:
@@ -52,7 +52,7 @@ impl<T: TokenProvider + Clone> GeminiClient<T> {
|
||||
let access_token = match self.token_provider.get_token(AUTH_SCOPE).await {
|
||||
Ok(access_token) => access_token,
|
||||
Err(e) => {
|
||||
queue.push(Some(Err(e.into())));
|
||||
queue.push(Some(Err(e)));
|
||||
return queue;
|
||||
}
|
||||
};
|
||||
@@ -60,7 +60,7 @@ impl<T: TokenProvider + Clone> GeminiClient<T> {
|
||||
// Clone the queue and other necessary data to move into the async block.
|
||||
let cloned_queue = queue.clone();
|
||||
let endpoint_url: String = format!(
|
||||
"https://{}/v1beta1/projects/{}/locations/{}/publishers/google/models/{}:streamGenerateContent?alt=sse", self.api_endpoint, self.project_id, self.location_id, model.to_string(),
|
||||
"https://{}/v1beta1/projects/{}/locations/{}/publishers/google/models/{}:streamGenerateContent?alt=sse", self.api_endpoint, self.project_id, self.location_id, model,
|
||||
);
|
||||
let client = self.client.clone();
|
||||
let request = request.clone();
|
||||
@@ -112,7 +112,7 @@ impl<T: TokenProvider + Clone> GeminiClient<T> {
|
||||
) -> Result<GenerateContentResponseResult> {
|
||||
let access_token = self.token_provider.get_token(AUTH_SCOPE).await?;
|
||||
let endpoint_url: String = format!(
|
||||
"https://{}/v1beta1/projects/{}/locations/{}/publishers/google/models/{}:generateContent", self.api_endpoint, self.project_id, self.location_id, model.to_string(),
|
||||
"https://{}/v1beta1/projects/{}/locations/{}/publishers/google/models/{}:generateContent", self.api_endpoint, self.project_id, self.location_id, model,
|
||||
);
|
||||
let resp = self
|
||||
.client
|
||||
@@ -189,8 +189,7 @@ impl<T: TokenProvider + Clone> GeminiClient<T> {
|
||||
response
|
||||
.candidates
|
||||
.iter()
|
||||
.map(Candidate::get_text)
|
||||
.flatten()
|
||||
.filter_map(Candidate::get_text)
|
||||
.collect::<Vec<String>>()
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ impl Display for Error {
|
||||
Error::Token(e) => write!(f, "Token error: {}", e),
|
||||
Error::Serde(e) => write!(f, "Serde error: {}", e),
|
||||
Error::VertexError(e) => {
|
||||
write!(f, "Vertex error: {}", e.to_string())
|
||||
write!(f, "Vertex error: {}", e)
|
||||
}
|
||||
Error::NoCandidatesError => {
|
||||
write!(f, "No candidates returned for the prompt")
|
||||
|
||||
@@ -123,9 +123,9 @@ pub enum GenerateContentResponse {
|
||||
Error(GenerateContentResponseError),
|
||||
}
|
||||
|
||||
impl Into<Result<GenerateContentResponseResult>> for GenerateContentResponse {
|
||||
fn into(self) -> Result<GenerateContentResponseResult> {
|
||||
match self {
|
||||
impl From<GenerateContentResponse> for Result<GenerateContentResponseResult> {
|
||||
fn from(val: GenerateContentResponse) -> Self {
|
||||
match val {
|
||||
GenerateContentResponse::Ok(result) => Ok(result),
|
||||
GenerateContentResponse::Error(error) => Err(error.error.into()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user