The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
feat(core): support vertexai standard content (#33521)
ccurmeeb19e1252749
diff --git a/libs/core/langchain_core/messages/block_translators/google_vertexai.py b/libs/core/langchain_core/messages/block_translators/google_vertexai.pyindex f4e8f7ec0a..016f146164 100644--- a/libs/core/langchain_core/messages/block_translators/google_vertexai.py+++ b/libs/core/langchain_core/messages/block_translators/google_vertexai.py@@ -1,37 +1,9 @@"""Derivations of standard content blocks from Google (VertexAI) content."""-import warnings--from langchain_core.messages import AIMessage, AIMessageChunk-from langchain_core.messages import content as types--WARNED = False---def translate_content(message: AIMessage) -> list[types.ContentBlock]: # noqa: ARG001- """Derive standard content blocks from a message with Google (VertexAI) content."""- global WARNED # noqa: PLW0603- if not WARNED:- warning_message = (- "Content block standardization is not yet fully supported for Google "- "VertexAI."- )- warnings.warn(warning_message, stacklevel=2)- WARNED = True- raise NotImplementedError---def translate_content_chunk(message: AIMessageChunk) -> list[types.ContentBlock]: # noqa: ARG001- """Derive standard content blocks from a chunk with Google (VertexAI) content."""- global WARNED # noqa: PLW0603- if not WARNED:- warning_message = (- "Content block standardization is not yet fully supported for Google "- "VertexAI."- )- warnings.warn(warning_message, stacklevel=2)- WARNED = True- raise NotImplementedError+from langchain_core.messages.block_translators.google_genai import (+ translate_content,+ translate_content_chunk,+)def _register_google_vertexai_translator() -> None:diff --git a/libs/core/tests/unit_tests/messages/test_ai.py b/libs/core/tests/unit_tests/messages/test_ai.pyindex 6ced0a59e0..742f23b68b 100644--- a/libs/core/tests/unit_tests/messages/test_ai.py+++ b/libs/core/tests/unit_tests/messages/test_ai.py@@ -1,7 +1,5 @@from typing import cast-import pytest-from langchain_core.load import dumpd, loadfrom langchain_core.messages import AIMessage, AIMessageChunkfrom langchain_core.messages import content as types@@ -484,20 +482,6 @@ def test_content_blocks() -> None:]-def test_provider_warns() -> None:- # Test that major providers warn if content block standardization is not yet- # implemented.- # This test should be removed when all major providers support content block- # standardization.- message = AIMessage(- "Hello.", response_metadata={"model_provider": "google_vertexai"}- )- with pytest.warns(match="not yet fully supported for Google VertexAI"):- content_blocks = message.content_blocks-- assert content_blocks == [{"type": "text", "text": "Hello."}]--def test_content_blocks_reasoning_extraction() -> None:"""Test best-effort reasoning extraction from `additional_kwargs`."""message = AIMessage(