diff options
| author | sigoden <sigoden@gmail.com> | 2024-05-30 17:10:02 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-30 17:10:02 +0800 |
| commit | 54a837784c3df7e73c7c95adfef96e68c842984b (patch) | |
| tree | e090da40436bd3c1220d5ab88071ac33397ce57c /src/client/vertexai.rs | |
| parent | fa4bf14e02b1e6361b38014fe6a986738cf06837 (diff) | |
| download | aichat-54a837784c3df7e73c7c95adfef96e68c842984b.tar.gz | |
refactor: rename `SendData` to `CompletionData` (#553)
Diffstat (limited to 'src/client/vertexai.rs')
| -rw-r--r-- | src/client/vertexai.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/client/vertexai.rs b/src/client/vertexai.rs index 1abbffc..102b5cb 100644 --- a/src/client/vertexai.rs +++ b/src/client/vertexai.rs @@ -1,7 +1,7 @@ use super::{ access_token::*, catch_error, json_stream, message::*, patch_system_message, Client, - CompletionOutput, ExtraConfig, Model, ModelData, ModelPatches, PromptAction, PromptKind, - SendData, SseHandler, ToolCall, VertexAIClient, + CompletionData, CompletionOutput, ExtraConfig, Model, ModelData, ModelPatches, PromptAction, + PromptKind, SseHandler, ToolCall, VertexAIClient, }; use anyhow::{anyhow, bail, Context, Result}; @@ -35,7 +35,11 @@ impl VertexAIClient { ("location", "Location", true, PromptKind::String), ]; - fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result<RequestBuilder> { + fn request_builder( + &self, + client: &ReqwestClient, + data: CompletionData, + ) -> Result<RequestBuilder> { let project_id = self.get_project_id()?; let location = self.get_location()?; let access_token = get_access_token(self.name())?; @@ -66,7 +70,7 @@ impl Client for VertexAIClient { async fn send_message_inner( &self, client: &ReqwestClient, - data: SendData, + data: CompletionData, ) -> Result<CompletionOutput> { prepare_gcloud_access_token(client, self.name(), &self.config.adc_file).await?; let builder = self.request_builder(client, data)?; @@ -77,7 +81,7 @@ impl Client for VertexAIClient { &self, client: &ReqwestClient, handler: &mut SseHandler, - data: SendData, + data: CompletionData, ) -> Result<()> { prepare_gcloud_access_token(client, self.name(), &self.config.adc_file).await?; let builder = self.request_builder(client, data)?; @@ -177,8 +181,8 @@ fn gemini_extract_completion_text(data: &Value) -> Result<CompletionOutput> { Ok(output) } -pub(crate) fn gemini_build_body(data: SendData, model: &Model) -> Result<Value> { - let SendData { +pub(crate) fn gemini_build_body(data: CompletionData, model: &Model) -> Result<Value> { + let CompletionData { mut messages, temperature, top_p, |
