From 934319fc28a44bd51a92a6b1c60349976f40cbe5 Mon Sep 17 00:00:00 2001 From: khallbobo <871838+khallbobo@users.noreply.github.com> Date: Sat, 3 Jun 2023 18:17:38 -0400 Subject: [PATCH] Add parameters to send_message() call for vertexai chat models (PaLM2) (#5566) # Ensure parameters are used by vertexai chat models (PaLM2) The current version of the google aiplatform contains a bug where parameters for a chat model are not used as intended. See https://github.com/googleapis/python-aiplatform/issues/2263 Params can be passed both to start_chat() and send_message(); however, the parameters passed to start_chat() will not be used if send_message() is called without the overrides. This is due to the defaults in send_message() being global values rather than None (there is code in send_message() which would use the params from start_chat() if the param passed to send_message() evaluates to False, but that won't happen as the defaults are global values). Fixes # 5531 @hwchase17 @agola11 --- langchain/chat_models/vertexai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/chat_models/vertexai.py b/langchain/chat_models/vertexai.py index 87cf0ee9..4f78b310 100644 --- a/langchain/chat_models/vertexai.py +++ b/langchain/chat_models/vertexai.py @@ -122,7 +122,7 @@ class ChatVertexAI(_VertexAICommon, BaseChatModel): chat = self.client.start_chat(context=context, **self._default_params) for pair in history.history: chat._history.append((pair.question.content, pair.answer.content)) - response = chat.send_message(question.content) + response = chat.send_message(question.content, **self._default_params) text = self._enforce_stop_words(response.text, stop) return ChatResult(generations=[ChatGeneration(message=AIMessage(content=text))])