Skip to content

The agent engineering platform.

google-vertexai[patch]: Fixed SafetySettings handling in streaming API in VertexAI (#17278)

Ruben Hakopian96b5711a0ce3
diff --git a/libs/partners/google-vertexai/langchain_google_vertexai/chat_models.py b/libs/partners/google-vertexai/langchain_google_vertexai/chat_models.py
index 48709faebd..096f18006f 100644
--- a/libs/partners/google-vertexai/langchain_google_vertexai/chat_models.py
+++ b/libs/partners/google-vertexai/langchain_google_vertexai/chat_models.py
@@ -510,8 +510,13 @@ class ChatVertexAI(_VertexAICommon, BaseChatModel):
# set param to `functions` until core tool/function calling implemented
raw_tools = params.pop("functions") if "functions" in params else None
tools = _format_tools_to_vertex_tool(raw_tools) if raw_tools else None
+ safety_settings = params.pop("safety_settings", None)
responses = chat.send_message(
- message, stream=True, generation_config=params, tools=tools
+ message,
+ stream=True,
+ generation_config=params,
+ safety_settings=safety_settings,
+ tools=tools,
)
for response in responses:
message = _parse_response_candidate(response.candidates[0])