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

vertex Ai chat is broken right now. That is because context is in params
and chat.send_message doesn't accept that as a params.

- Closes issue [ChatVertexAI Error: _ChatSessionBase.send_message() got
an unexpected keyword argument 'context'
#6610](https://github.com/hwchase17/langchain/issues/6610)
This commit is contained in:
Hassan Ouda
2023-06-23 16:38:21 -04:00
committed by GitHub
parent c2b25c17c5
commit 9e52134d30

View File

@@ -129,7 +129,8 @@ class ChatVertexAI(_VertexAICommon, BaseChatModel):
context = history.system_message.content if history.system_message else None context = history.system_message.content if history.system_message else None
params = {**self._default_params, **kwargs} params = {**self._default_params, **kwargs}
if not self.is_codey_model: if not self.is_codey_model:
params["context"] = context chat = self.client.start_chat(context=context, **params)
else:
chat = self.client.start_chat(**params) chat = self.client.start_chat(**params)
for pair in history.history: for pair in history.history:
chat._history.append((pair.question.content, pair.answer.content)) chat._history.append((pair.question.content, pair.answer.content))