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

Unable to use ChatVertexAI as provider due to default chat's ChatPromptTemplate #264

Open
michaelchia opened this issue Jul 13, 2023 · 5 comments
Labels
bug Something isn't working @jupyter-ai/chatui

Comments

@michaelchia
Copy link
Collaborator

Problem

Proposed Solution

  • I am not sure what the purpose of the empty AIMessage is. Perhaps review if it is absolutely necessary.
@michaelchia michaelchia added the enhancement New feature or request label Jul 13, 2023
@JasonWeill JasonWeill added bug Something isn't working @jupyter-ai/chatui and removed enhancement New feature or request labels Jul 13, 2023
@dlqqq
Copy link
Member

dlqqq commented Jul 24, 2023

@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.

@michaelchia
Copy link
Collaborator Author

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.

@dlqqq
Copy link
Member

dlqqq commented Jul 24, 2023

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.

@JasonWeill
Copy link
Collaborator

See also #226 for customizing prompts for models/providers.

@JasonWeill JasonWeill added this to the 2.2.0 Release milestone Jul 28, 2023
@hinthornw
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @jupyter-ai/chatui
Projects
None yet
Development

No branches or pull requests

4 participants