-
Notifications
You must be signed in to change notification settings - Fork 461
feat(models): allow SystemContentBlocks in LiteLLMModel #1141
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| # Apply cache control to the immediately preceding content block | ||
| # for LiteLLM/Anthropic compatibility | ||
| if system_content: | ||
| system_content[-1]["cache_control"] = {"type": "ephemeral"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know the other types? What if we set type to block["cachePoint"].get("type", "ephemeral")?
| "totalTokens": event["data"].total_tokens, | ||
| } | ||
|
|
||
| # Only LiteLLM over Anthropic supports cache cache write tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "cache cache ..."
Description
This is the followup to
feat(models): add SystemContentBlock support for provider-agnostic caching#1112. We are now processing SystemContentBlocks within LiteLLM which enables prompt caching.Note, this will be breaking for some integrators. At launch, it was a mistake to not apply kwargs to all public methods. This leaves us with two options.
For the sake of maintainability, and the expectation that very few people will be extending the OpenAIModel as a base model, the proposal in this PR is to add kwargs to the existing public methods. This will enable future changes in a backwards compatible way.
Related Issues
#937
Documentation PR
To come after the merge.
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.