summaryrefslogtreecommitdiffstats
path: root/src/client/vertexai.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/vertexai.rs')
-rw-r--r--src/client/vertexai.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/client/vertexai.rs b/src/client/vertexai.rs
index a9f84f8..dc75c9f 100644
--- a/src/client/vertexai.rs
+++ b/src/client/vertexai.rs
@@ -1,5 +1,5 @@
-use super::*;
use super::access_token::*;
+use super::*;
use anyhow::{anyhow, bail, Context, Result};
use async_trait::async_trait;
@@ -73,7 +73,11 @@ impl VertexAIClient {
true => "RETRIEVAL_DOCUMENT",
false => "QUESTION_ANSWERING",
};
- let instances: Vec<_> = data.texts.into_iter().map(|v| json!({"task_type": task_type, "content": v})).collect();
+ let instances: Vec<_> = data
+ .texts
+ .into_iter()
+ .map(|v| json!({"task_type": task_type, "content": v}))
+ .collect();
let body = json!({
"instances": instances,
});
@@ -182,7 +186,11 @@ async fn embeddings(builder: RequestBuilder) -> Result<EmbeddingsOutput> {
}
let res_body: EmbeddingsResBody =
serde_json::from_value(data).context("Invalid request data")?;
- let output = res_body.predictions.into_iter().map(|v| v.embeddings.values).collect();
+ let output = res_body
+ .predictions
+ .into_iter()
+ .map(|v| v.embeddings.values)
+ .collect();
Ok(output)
}
@@ -198,7 +206,7 @@ struct EmbeddingsResBodyPrediction {
#[derive(Deserialize)]
struct EmbeddingsResBodyPredictionEmbeddings {
- values: Vec<f32>
+ values: Vec<f32>,
}
fn gemini_extract_chat_completions_text(data: &Value) -> Result<ChatCompletionsOutput> {