-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
.Net: Add CachedContent Property to GeminiPromptExecutionSettings #10268
Conversation
@microsoft-github-policy-service agree company="Carepatron" |
@RogerBarreto / @markwallace-microsoft / @dmytrostruk would love to hear your thoughts. |
dotnet/src/Connectors/Connectors.Google/Core/Gemini/Models/GeminiRequest.cs
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.Google/GeminiPromptExecutionSettings.cs
Show resolved
Hide resolved
@davidpene Thanks very much for the contribution, suggest adding missing UnitTests ensuring the new request property is behaving correctly when serializing, deserializing and going over the http, suggest adding an integration test ensuring it as well (keep the integration test Skipped for the project but ensure it works as expected when runningh locally) For reference check: |
Appreciate the feedback @RogerBarreto - all done ✅ |
Motivation and Context
Why is this change required?
This change introduces a new
CachedContent
field to theGeminiPromptExecutionSettings
class. The addition enables context caching, a feature that optimizes the handling of repeated static content in requests with high input token counts.What problem does it solve?
Repeatedly processing substantial, static context data (e.g., lengthy documents, audio files, or video files) in requests can be resource-intensive and costly. Context caching addresses this by allowing the reuse of shared context across multiple requests, improving performance and cost-efficiency.
What scenario does it contribute to?
Context caching is particularly well-suited for scenarios where a substantial initial context is repeatedly referenced by shorter requests. Use cases include:
No open issues are linked to this change.
Description
This PR adds a
CachedContent
field to theGeminiPromptExecutionSettings
class. The field allows users to reference cached context items such as text blocks, audio files, or video files in prompt requests.Key features:
By enabling context caching, users can optimize cost and resource usage for workflows requiring substantial and repeat context data.
Contribution Checklist
Demo
Notes
v1beta1
endpointv1beta1
endpoint