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

fix: further anthropic caching improvements #318

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Dec 10, 2024

Important

Improves caching by adjusting cache control settings for user messages in gptme/llm/llm_anthropic.py and simplifies an import statement.

  • Behavior:
    • Adjusts cache control settings in _prepare_messages_for_api() to set cache points at the last two user messages, following Anthropic's documentation.
  • Imports:
    • Simplifies import statement for PromptCachingBetaTextBlockParam by removing unnecessary line breaks.

This description was created by Ellipsis for c18a179. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to c18a179 in 19 seconds

More details
  • Looked at 56 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. gptme/llm/llm_anthropic.py:22
  • Draft comment:
    Unnecessary line breaks in import statement removed for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The import statement was unnecessarily split across multiple lines, which is not a violation but a style preference. The change improves readability.
2. gptme/llm/llm_anthropic.py:339
  • Draft comment:
    Removed unused loop variable i for cleaner code.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The loop variable i was removed as it was not used in the loop body. This is a good change as it removes unnecessary code.
3. gptme/llm/llm_anthropic.py:355
  • Draft comment:
    Cache control is now correctly applied to the last two user messages, aligning with Anthropic documentation.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The previous logic incorrectly applied cache control only to the last message. The new logic correctly applies it to the last two user messages, as per the Anthropic documentation.

Workflow ID: wflow_VSwLwiAiVVAEOJcR


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 73.73%. Comparing base (8757108) to head (c18a179).
Report is 3 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
gptme/llm/llm_anthropic.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #318      +/-   ##
==========================================
+ Coverage   72.51%   73.73%   +1.22%     
==========================================
  Files          67       67              
  Lines        4911     5106     +195     
==========================================
+ Hits         3561     3765     +204     
+ Misses       1350     1341       -9     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 71.99% <85.71%> (+1.39%) ⬆️
openai/gpt-4o-mini 69.48% <0.00%> (+0.09%) ⬆️

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.

@ErikBjare ErikBjare merged commit 65efc3e into master Dec 10, 2024
7 checks passed
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