Skip to content

The agent engineering platform.

ChatVertexAI broken - Fix error with sending context in params (#6652)

Hassan Ouda9e52134d3020
diff --git a/langchain/chat_models/vertexai.py b/langchain/chat_models/vertexai.py
index b9440476cb..5770da6e11 100644
--- a/langchain/chat_models/vertexai.py
+++ b/langchain/chat_models/vertexai.py
@@ -129,8 +129,9 @@ class ChatVertexAI(_VertexAICommon, BaseChatModel):
context = history.system_message.content if history.system_message else None
params = {**self._default_params, **kwargs}
if not self.is_codey_model:
- params["context"] = context
- chat = self.client.start_chat(**params)
+ chat = self.client.start_chat(context=context, **params)
+ else:
+ chat = self.client.start_chat(**params)
for pair in history.history:
chat._history.append((pair.question.content, pair.answer.content))
response = chat.send_message(question.content, **params)