Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

HassanOuda
Copy link
Contributor

@HassanOuda HassanOuda commented Jun 23, 2023

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.

@dev2049

@vercel
Copy link

vercel bot commented Jun 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2023 2:28pm

@vercel vercel bot temporarily deployed to Preview June 23, 2023 14:19 Inactive
@vercel vercel bot temporarily deployed to Preview June 23, 2023 14:28 Inactive
@HassanOuda HassanOuda changed the title Fix error with sending context in params ChatVertexAI broken - Fix error with sending context in params Jun 23, 2023
@HassanOuda
Copy link
Contributor Author

HassanOuda commented Jun 23, 2023

@dev2049 Hi, can you look at this quickly? When you merged the last update on VertexAI to add in Codey, I think you added by mistake the context in the params but send_message function doesn't accept that in params. Can we fix this ASAP? we cannot use chat-bison at all now, currently its broken.

Thanks!

@@ -129,8 +129,9 @@ def _generate(
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is functionally equivalent, no? we're only adding "context" to params if it's not a codey model

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The start_chat logic is equivalent, but the error is caused by chat.send_message(question.content, **params). In the previous version, context was added, but context isn't a valid argument for either session types (ChatSession and CodeChatSession). With this new change, context is never added to params

Here's the API reference for ChatSession.send_message: https://cloud.google.com/python/docs/reference/aiplatform/latest/vertexai.preview.language_models.ChatSession

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, because you are using params variable in a different function, send_message just a few lines after and that's causing the issue. That function doesn't support context in params for any chat models for vertexai. Only chat-bison supports context at start chat function only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see, thanks for explaining!

@dev2049
Copy link
Contributor

dev2049 commented Jun 23, 2023

in issue error seems to happen with chat-bison, which isn't code model

@dev2049 dev2049 merged commit 9e52134 into langchain-ai:master Jun 23, 2023
@dev2049
Copy link
Contributor

dev2049 commented Jun 23, 2023

0.0.212 is out with the fix, apologies for the issue and thanks for the fix!

@carolynlphillips
Copy link

Thanks for getting this one out! We needed this fix too!

This was referenced Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants