-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
Unable to use ChatVertexAI as provider due to default chat's ChatPromptTemplate #264
Comments
@michaelchia Hey Michael, I had sent a reply but it appears to have been lost by GitHub 😭. Sorry for the late response. The reason we add the empty AI message is to indicate that to the LLM that it should generate a response to the prompt instead of generating a continuation of the prompt. From our extensive testing with the providers we offer, we determined this to be necessary for certain providers like AI21 and Cohere. The empty AI message is also part of LangChain's default prompt template for conversation chains: https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/chains/conversation/prompt.py Hence, I'm very surprised that the ChatVertexAI provider explicitly raises an error when the last message is an AI message, as this goes against the self-consistency of LangChain itself. Though I haven't used it, a glance at the code suggests that ChatVertexAI would fail with the default conversation chain. Since VertexAI seems to be the exception, I'm inclined to argue that the solution to this issue would be to add a custom Pydantic attribute on the ChatVertexAI provider to indicate it should not include an empty AI message suffixed. Then our backend will make sure to check that attribute before building the prompt template. |
Yep, Makes sense. I will argue not bothering even adding this extra attribute on your end, adds unnecessary complexity. Seems like a VertexAI issue that should be solved within their langchain object. On my end, I have a workaround that isn't too hacky (overriding the _generate method to remove that extra AIMessage). Thanks for the consideration. |
Haha, part of the reason we subclass all of the LangChain providers we offer is precisely to work around upstream issues until they're patched. We are inclined to add VertexAI to Jupyter AI, so for other users, the additional attribute would be necessary. |
See also #226 for customizing prompts for models/providers. |
Hi @dlqqq - Will from the LangChain team here - love what you all are doing with Jupyter AI! We'd love to set up a slack channel with your team to make sure we can prioritize fixes like this and that the modules you are using stably support the project. If you send an email to support@langchain.dev we'll open that line of communication. Thank you! I know Piyush has made a lot of contributions to the project as well :) |
Problem
jupyter-ai/packages/jupyter-ai/jupyter_ai/chat_handlers/default.py
Lines 35 to 52 in 0f61906
https://github.com/hwchase17/langchain/blob/8f5eca236fa399bab81ee7a533cc37efd27a257d/langchain/chat_models/vertexai.py#L122-L126
Proposed Solution
The text was updated successfully, but these errors were encountered: