From 4691610c04aebb49bcbc3ba140a725ce52319f41 Mon Sep 17 00:00:00 2001 From: "Hristo (Izo) G." <53634432+izo0x90@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:39:00 -0500 Subject: [PATCH 1/2] Fix additional_headers fallback in validate_parms_base (#700) --- libs/vertexai/langchain_google_vertexai/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vertexai/langchain_google_vertexai/_base.py b/libs/vertexai/langchain_google_vertexai/_base.py index e7ffc646..d89d4ed3 100644 --- a/libs/vertexai/langchain_google_vertexai/_base.py +++ b/libs/vertexai/langchain_google_vertexai/_base.py @@ -118,7 +118,7 @@ def validate_params_base(cls, values: dict) -> Any: if values.get("client_cert_source"): client_options.client_cert_source = values["client_cert_source"] values["client_options"] = client_options - additional_headers = values.get("additional_headers", {}) + additional_headers = values.get("additional_headers") or {} values["default_metadata"] = tuple(additional_headers.items()) return values From 953879d066940b7cdc357f9202b01e148a13df48 Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Thu, 23 Jan 2025 20:50:21 +0100 Subject: [PATCH 2/2] fix linting (#708) --- libs/vertexai/langchain_google_vertexai/_base.py | 2 +- libs/vertexai/langchain_google_vertexai/chat_models.py | 2 +- libs/vertexai/langchain_google_vertexai/model_garden.py | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/vertexai/langchain_google_vertexai/_base.py b/libs/vertexai/langchain_google_vertexai/_base.py index d89d4ed3..fe1793f3 100644 --- a/libs/vertexai/langchain_google_vertexai/_base.py +++ b/libs/vertexai/langchain_google_vertexai/_base.py @@ -177,7 +177,7 @@ def _library_version(self) -> str: class _VertexAICommon(_VertexAIBase): client_preview: Any = Field(default=None, exclude=True) #: :meta private: - model_name: str = Field(default=None, alias="model") + model_name: Optional[str] = Field(default=None, alias="model") "Underlying model name." temperature: Optional[float] = None "Sampling temperature, it controls the degree of randomness in token selection." diff --git a/libs/vertexai/langchain_google_vertexai/chat_models.py b/libs/vertexai/langchain_google_vertexai/chat_models.py index 9f341a3b..2018bd06 100644 --- a/libs/vertexai/langchain_google_vertexai/chat_models.py +++ b/libs/vertexai/langchain_google_vertexai/chat_models.py @@ -877,7 +877,7 @@ class Joke(BaseModel): .. code-block:: python - 'The image is of five blueberry scones arranged on a piece of baking paper. \n\nHere is a list of what is in the picture:\n* **Five blueberry scones:** They are scattered across the parchment paper, dusted with powdered sugar. \n* **Two cups of coffee:** Two white cups with saucers. One appears full, the other partially drunk.\n* **A bowl of blueberries:** A brown bowl is filled with fresh blueberries, placed near the scones.\n* **A spoon:** A silver spoon with the words "Let\'s Jam" rests on the paper.\n* **Pink peonies:** Several pink peonies lie beside the scones, adding a touch of color.\n* **Baking paper:** The scones, cups, bowl, and spoon are arranged on a piece of white baking paper, splattered with purple. The paper is crinkled and sits on a dark surface. \n\nThe image has a rustic and delicious feel, suggesting a cozy and enjoyable breakfast or brunch setting. \n' + 'The image is of five blueberry scones arranged on a piece of baking paper. \n\nHere is a list of what is in the picture:\n* **Five blueberry scones:** They are scattered across the parchment paper, dusted with powdered sugar. \n* **Two cups of coffee:** Two white cups with saucers. One appears full, the other partially drunk.\n* **A bowl of blueberries:** A brown bowl is filled with fresh blueberries, placed near the scones.\n* **A spoon:** A silver spoon with the words "Let\'s Jam" rests on the paper.\n* **Pink peonies:** Several pink peonies lie beside the scones, adding a touch of color.\n* **Baking paper:** The scones, cups, bowl, and spoon are arranged on a piece of white baking paper, splattered with purple. The paper is crinkled and sits on a dark surface. \n\nThe image has a rustic and delicious feel, suggesting a cozy and enjoyable breakfast or brunch setting. \n' # codespell:ignore brunch Video input: **NOTE**: Currently only supported for ``gemini-...-vision`` models. diff --git a/libs/vertexai/langchain_google_vertexai/model_garden.py b/libs/vertexai/langchain_google_vertexai/model_garden.py index fd7938d6..8bd92ea2 100644 --- a/libs/vertexai/langchain_google_vertexai/model_garden.py +++ b/libs/vertexai/langchain_google_vertexai/model_garden.py @@ -139,8 +139,6 @@ async def _agenerate( class ChatAnthropicVertex(_VertexAICommon, BaseChatModel): async_client: Any = Field(default=None, exclude=True) #: :meta private: - model_name: Optional[str] = Field(default=None, alias="model") # type: ignore[assignment] - "Underlying model name." max_output_tokens: int = Field(default=1024, alias="max_tokens") access_token: Optional[str] = None stream_usage: bool = True # Whether to include usage metadata in streaming output