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

vertexai: Add context caching to VertexAI class #645

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kardiff18
Copy link
Contributor

PR Description

  • Add support for context caching to VertexAI class (currently it is only supported by ChatVertexAI)
  • Refactor is_gemini_advanced into utils (to be used by both VertexAI and ChatVertexAI)

Type

🆕 New Feature
🧹 Refactoring
✅ Test

@@ -215,6 +215,11 @@ class _VertexAICommon(_VertexAIBase):
model_name will be used to determine the model family
"""

cached_content: Optional[str] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm sorry, but how would it be different from

cached_content: Optional[str] = None
?

@kardiff18
Copy link
Contributor Author

The issue today is that you cannot use VertexAI when using context caching, you can only use ChatVertexAI. If you try to use VertexAI with the cache it does not work.

So, the former PR that you linked it adds the parameter to the ChatVertexAI class, whereas this PR is adding it to VertexAI and therefore had to add it to the base model. Does that help?

@lkuligin
Copy link
Collaborator

The issue today is that you cannot use VertexAI when using context caching, you can only use ChatVertexAI. If you try to use VertexAI with the cache it does not work.

So, the former PR that you linked it adds the parameter to the ChatVertexAI class, whereas this PR is adding it to VertexAI and therefore had to add it to the base model. Does that help?

I'm wondering whether we should keep VertexAI at all. It's pretty outdated already and the gap will be increasing. Why do you need this class instead of ChatVertexAI?

@kardiff18
Copy link
Contributor Author

That's valid! My customer had attempted to use VertexAI at first since there was no multi-turn for the use case. After realizing context caching wasn't being properly used (there was no error message, we just knew the cache wasn't being invoked since the LLM response clearly was not using the cached instructions), I realized the issue was that they used VertexAI and not ChatVertexAI. I got them to switch over easily to ChatVertexAI after finding the issue.

That being said, I didn't know if anyone else was trying to use VertexAI without knowing it wasn't working properly due to a lack of error message, so I implemented it. We don't need this merge request, but I was just trying to help out others. We also mainly use ChatVertexAI for everything else. So in sum, I don't really think VertexAI is needed as well, so you're welcome to just ignore this PR if you think you'll be deprecating the class entirely.

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.

2 participants