From 4e14665b06f0589b087a91da89731733c8476dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Fri, 26 Jul 2024 23:02:56 +0200 Subject: [PATCH] fix: VertexAI KeyError 'location' (#2983) (cherry picked from commit bce072bb767fe1c7b9bbb7aa2720a65bb2b02e99) --- .../langflow/components/embeddings/VertexAIEmbeddings.py | 6 +++--- .../base/langflow/components/models/VertexAiModel.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/base/langflow/components/embeddings/VertexAIEmbeddings.py b/src/backend/base/langflow/components/embeddings/VertexAIEmbeddings.py index 7149c61730a..5628203d8db 100644 --- a/src/backend/base/langflow/components/embeddings/VertexAIEmbeddings.py +++ b/src/backend/base/langflow/components/embeddings/VertexAIEmbeddings.py @@ -17,7 +17,7 @@ class VertexAIEmbeddingsComponent(LCModelComponent): value="", file_types=["json"], ), - MessageTextInput(name="location", display_name="Location", advanced=True), + MessageTextInput(name="location", display_name="Location", value="us-central1", advanced=True), MessageTextInput(name="project", display_name="Project", info="The project ID.", advanced=True), IntInput(name="max_output_tokens", display_name="Max Output Tokens", advanced=True), IntInput(name="max_retries", display_name="Max Retries", value=1, advanced=True), @@ -53,7 +53,7 @@ def build_embeddings(self) -> Embeddings: return VertexAIEmbeddings( credentials=gcloud_credentials, location=self.location, - max_output_tokens=self.max_output_tokens, + max_output_tokens=self.max_output_tokens or None, max_retries=self.max_retries, model_name=self.model_name, n=self.n, @@ -62,6 +62,6 @@ def build_embeddings(self) -> Embeddings: stop=self.stop_sequences or None, streaming=self.streaming, temperature=self.temperature, - top_k=self.top_k, + top_k=self.top_k or None, top_p=self.top_p, ) diff --git a/src/backend/base/langflow/components/models/VertexAiModel.py b/src/backend/base/langflow/components/models/VertexAiModel.py index b52650b0bdf..76f91cdad98 100644 --- a/src/backend/base/langflow/components/models/VertexAiModel.py +++ b/src/backend/base/langflow/components/models/VertexAiModel.py @@ -21,7 +21,7 @@ class ChatVertexAIComponent(LCModelComponent): ), MessageTextInput(name="model_name", display_name="Model Name", value="gemini-1.5-pro"), StrInput(name="project", display_name="Project", info="The project ID.", advanced=True), - StrInput(name="location", display_name="Location", advanced=True), + StrInput(name="location", display_name="Location", value="us-central1", advanced=True), IntInput(name="max_output_tokens", display_name="Max Output Tokens", advanced=True), IntInput(name="max_retries", display_name="Max Retries", value=1, advanced=True), FloatInput(name="temperature", value=0.0, display_name="Temperature"), @@ -60,11 +60,11 @@ def build_model(self) -> LanguageModel: credentials=credentials, location=location, project=project, - max_output_tokens=self.max_output_tokens, + max_output_tokens=self.max_output_tokens or None, max_retries=self.max_retries, model_name=self.model_name, temperature=self.temperature, - top_k=self.top_k, + top_k=self.top_k or None, top_p=self.top_p, verbose=self.verbose, ),