The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
google-vertexai[patch]: serializable citation metadata, release 0.0.4 (#17145)
Erick Friis52be84a603f8
diff --git a/libs/partners/google-vertexai/langchain_google_vertexai/_utils.py b/libs/partners/google-vertexai/langchain_google_vertexai/_utils.pyindex 4f0bdf3723..feedd701a6 100644--- a/libs/partners/google-vertexai/langchain_google_vertexai/_utils.py+++ b/libs/partners/google-vertexai/langchain_google_vertexai/_utils.py@@ -5,6 +5,7 @@ from importlib import metadatafrom typing import Any, Callable, Dict, Optional, Unionimport google.api_core+import proto # type: ignore[import-untyped]from google.api_core.gapic_v1.client_info import ClientInfofrom google.cloud import storagefrom langchain_core.callbacks import (@@ -114,7 +115,11 @@ def get_generation_info(}for rating in candidate.safety_ratings],- "citation_metadata": candidate.citation_metadata,+ "citation_metadata": (+ proto.Message.to_dict(candidate.citation_metadata)+ if candidate.citation_metadata+ else None+ ),}# https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/text-chat#response_bodyelse:diff --git a/libs/partners/google-vertexai/pyproject.toml b/libs/partners/google-vertexai/pyproject.tomlindex f9d2f890cb..a9283e2d5c 100644--- a/libs/partners/google-vertexai/pyproject.toml+++ b/libs/partners/google-vertexai/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "langchain-google-vertexai"-version = "0.0.3"+version = "0.0.4"description = "An integration package connecting GoogleVertexAI and LangChain"authors = []readme = "README.md"diff --git a/libs/partners/google-vertexai/tests/integration_tests/test_tools.py b/libs/partners/google-vertexai/tests/integration_tests/test_tools.pyindex a688476bfc..f239727eca 100644--- a/libs/partners/google-vertexai/tests/integration_tests/test_tools.py+++ b/libs/partners/google-vertexai/tests/integration_tests/test_tools.py@@ -1,6 +1,6 @@import osimport re-from typing import List, Union+from typing import Any, List, Unionfrom langchain_core.agents import AgentAction, AgentActionMessageLog, AgentFinishfrom langchain_core.messages import AIMessageChunk@@ -44,11 +44,11 @@ class _TestOutputParser(BaseOutputParser):def test_tools() -> None:- from langchain.agents import AgentExecutor # type: ignore[import-not-found]- from langchain.agents.format_scratchpad import ( # type: ignore[import-not-found]+ from langchain.agents import AgentExecutor+ from langchain.agents.format_scratchpad import (format_to_openai_function_messages,)- from langchain.chains import LLMMathChain # type: ignore[import-not-found]+ from langchain.chains import LLMMathChainllm = ChatVertexAI(model_name="gemini-pro")math_chain = LLMMathChain.from_llm(llm=llm)@@ -67,8 +67,8 @@ def test_tools() -> None:)llm_with_tools = llm.bind(functions=tools)- agent = (- { # type: ignore[var-annotated]+ agent: Any = (+ {"input": lambda x: x["input"],"agent_scratchpad": lambda x: format_to_openai_function_messages(x["intermediate_steps"]@@ -115,7 +115,7 @@ def test_multiple_tools() -> None:from langchain.agents import AgentExecutorfrom langchain.agents.format_scratchpad import format_to_openai_function_messagesfrom langchain.chains import LLMMathChain- from langchain.utilities import ( # type: ignore[import-not-found]+ from langchain.utilities import (GoogleSearchAPIWrapper,)@@ -149,8 +149,8 @@ def test_multiple_tools() -> None:)llm_with_tools = llm.bind(functions=tools)- agent = (- { # type: ignore[var-annotated]+ agent: Any = (+ {"input": lambda x: x["input"],"agent_scratchpad": lambda x: format_to_openai_function_messages(x["intermediate_steps"]diff --git a/libs/partners/google-vertexai/tests/unit_tests/test_chat_models.py b/libs/partners/google-vertexai/tests/unit_tests/test_chat_models.pyindex 052cf559f0..6bcbb6e5ab 100644--- a/libs/partners/google-vertexai/tests/unit_tests/test_chat_models.py+++ b/libs/partners/google-vertexai/tests/unit_tests/test_chat_models.py@@ -187,7 +187,7 @@ def test_default_params_gemini() -> None:StubGeminiResponse(text="Goodbye",content=Mock(parts=[Mock(function_call=None)]),- citation_metadata=Mock(),+ citation_metadata=None,)]mock_chat = MagicMock()