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

feat: add Context Caching to Gemini plugins #1297

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

Conversation

cabljac
Copy link
Contributor

@cabljac cabljac commented Nov 14, 2024

TODO:

  • testing, address comments from self review

Checklist (if applicable):

  • Tested - manually
  • Changelog updated
  • Docs updated

@cabljac cabljac force-pushed the @invertase/context-caching-0.9 branch from 1421561 to 87b0185 Compare November 18, 2024 14:09
@cabljac cabljac changed the title feat: context caching on Google AI plugin (0.9) feat: Context Caching Nov 18, 2024
@cabljac cabljac changed the title feat: Context Caching feat: add Context Caching to Gemini plugins Nov 18, 2024
@cabljac cabljac force-pushed the @invertase/context-caching-0.9 branch from 87b0185 to 7f44d4c Compare November 18, 2024 14:13
@cabljac cabljac force-pushed the @invertase/context-caching-0.9 branch from b7a621b to 6106b6f Compare November 18, 2024 14:34
@cabljac
Copy link
Contributor Author

cabljac commented Nov 18, 2024

Should wait for this fix:

googleapis/nodejs-vertexai#469

@cabljac cabljac force-pushed the @invertase/context-caching-0.9 branch from 6106b6f to 754f8f1 Compare November 18, 2024 14:44
@cabljac cabljac marked this pull request as ready for review November 18, 2024 15:45
@cabljac cabljac requested a review from pavelgj November 18, 2024 17:03
) => {
return fromGeminiCandidate(candidate, jsonMode);
};
let cache: CachedContent | null = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can we avoid this

};
let cache: CachedContent | null = null;

// TODO: fix casting
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix todo

cache = handleContextCacheResponse.cache;
}

let genModel: GenerativeModel | null = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix this

request: any,
modelVersion: string
): boolean {
if (!modelVersion || !CONTEXT_CACHE_SUPPORTED_MODELS.includes(modelVersion)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this probably shouldn't throw - we should probably just return false

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 should probably throw if they try to use cache (cache is in metadata etc) but the model version is wrong. We don't want to accidentally cost them lots of tokens.

/**
* Clears all caches using the cache manager.
*/
export async function clearAllCaches(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this isnt actually used

@cabljac cabljac removed the request for review from pavelgj November 20, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant