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

Enable gemini context caching #3207

Draft
wants to merge 8 commits into
base: 0.2
Choose a base branch
from
Draft

Enable gemini context caching #3207

wants to merge 8 commits into from

Conversation

yeounoh
Copy link

@yeounoh yeounoh commented Jul 24, 2024

Why are these changes needed?

Gemini model API introduced a new context caching feature that caches the prompt prefix. This PR implements enabled this new feature in GeminiClient to help reduce the cost of using the latest gemini models. Note that this is a gemini specific feature and used for caching the prompt prefix, not agent's input and output.

Related issue number

Addresses/closes #3038

Checks

@yeounoh yeounoh marked this pull request as draft July 24, 2024 23:05
@yeounoh
Copy link
Author

yeounoh commented Jul 24, 2024

@yeounoh please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@yeounoh yeounoh marked this pull request as ready for review July 25, 2024 07:18
@Hk669 Hk669 requested a review from BeibinLi July 25, 2024 13:26
@codecov-commenter
Copy link

codecov-commenter commented Jul 26, 2024

Codecov Report

Attention: Patch coverage is 43.47826% with 26 lines in your changes missing coverage. Please review.

Project coverage is 13.82%. Comparing base (6279247) to head (37cd8b5).
Report is 47 commits behind head on main.

Files Patch % Lines
autogen/oai/gemini.py 43.47% 26 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3207       +/-   ##
===========================================
- Coverage   32.90%   13.82%   -19.09%     
===========================================
  Files          94       97        +3     
  Lines       10235    10849      +614     
  Branches     2193     2488      +295     
===========================================
- Hits         3368     1500     -1868     
- Misses       6580     9313     +2733     
+ Partials      287       36      -251     
Flag Coverage Δ
unittests 13.78% <43.47%> (-19.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yeounoh yeounoh marked this pull request as draft July 26, 2024 17:12
@yeounoh
Copy link
Author

yeounoh commented Jul 26, 2024

It's failing to build due to missing google package. I will add a notebook to demonstrate the usage, before review.

@BeibinLi
Copy link
Collaborator

@yeounoh In your test case, you can move the "import" line into the existing "try...catch..." clause.

@ekzhu
Copy link
Collaborator

ekzhu commented Oct 1, 2024

@yeounoh Is this PR ready to be reviewed?

@ekzhu ekzhu changed the base branch from main to 0.2 October 2, 2024 18:27
@jackgerrits jackgerrits added the 0.2 Issues which are related to the pre 0.4 codebase label Oct 4, 2024
@rysweet rysweet added the awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster label Oct 10, 2024
@rysweet
Copy link
Collaborator

rysweet commented Oct 12, 2024

Hi @yeounoh - we've rebased and updated this for you. there are a couple of conflicts still. If you think this is ready for review please update to resolve the conflicts and then we will review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.2 Issues which are related to the pre 0.4 codebase awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: context caching for gemini-1.5
8 participants