From e62cee758da34466ba3118a018ae17c35b3f6c8f Mon Sep 17 00:00:00 2001 From: dotrunghieu96 Date: Fri, 3 Jan 2025 10:50:17 +0700 Subject: [PATCH 1/3] Update _anthropic_utils.py update the type image input from `image_url` to `image` for compliance with the anthropic latest api --- libs/vertexai/langchain_google_vertexai/_anthropic_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py b/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py index fd3721d2c..429933e2f 100644 --- a/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py +++ b/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py @@ -100,7 +100,7 @@ def _format_message_anthropic(message: Union[HumanMessage, AIMessage]): if block["type"] == "image_url": # convert format new_block["source"] = _format_image(block["image_url"]["url"]) - content.append(new_block) + content.append({"type": "image", "source": source}) continue if block["type"] == "tool_use": From 63239034be73d5843177513b8921c3d6011ce7ca Mon Sep 17 00:00:00 2001 From: dotrunghieu96 Date: Fri, 3 Jan 2025 11:14:06 +0700 Subject: [PATCH 2/3] Update _anthropic_utils.py --- libs/vertexai/langchain_google_vertexai/_anthropic_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py b/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py index 429933e2f..bac602892 100644 --- a/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py +++ b/libs/vertexai/langchain_google_vertexai/_anthropic_utils.py @@ -99,7 +99,7 @@ def _format_message_anthropic(message: Union[HumanMessage, AIMessage]): if block["type"] == "image_url": # convert format - new_block["source"] = _format_image(block["image_url"]["url"]) + source = _format_image(block["image_url"]["url"]) content.append({"type": "image", "source": source}) continue From 65597282f72f7c8f4f9f717cfd76e8a2f9383ffe Mon Sep 17 00:00:00 2001 From: dotrunghieu96 Date: Tue, 7 Jan 2025 14:03:21 +0700 Subject: [PATCH 3/3] Update unit test case for _format_messages_anthropic --- libs/vertexai/tests/unit_tests/test_anthropic_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vertexai/tests/unit_tests/test_anthropic_utils.py b/libs/vertexai/tests/unit_tests/test_anthropic_utils.py index 7f83bfb3e..dafc193d1 100644 --- a/libs/vertexai/tests/unit_tests/test_anthropic_utils.py +++ b/libs/vertexai/tests/unit_tests/test_anthropic_utils.py @@ -160,7 +160,7 @@ "role": "user", "content": [ { - "type": "image_url", + "type": "image", "source": { "type": "base64", "media_type": "image/png",