mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-22 01:55:27 -04:00
[PR #614] [MERGED] feat: Anthropic cache control = with token count updates #1461
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-official-plugins/pull/614
Author: @mendybraun
Created: 3/30/2025
Status: ✅ Merged
Merged: 4/1/2025
Merged by: @crazywoola
Base:
main← Head:anthropic-cache_control📝 Commits (3)
eb253efUpdate models/anthropic from upstream4d2fa67Added cache control for antropic models1b5ca15Merge branch 'main' into anthropic-cache_control📊 Changes
2 files changed (+190 additions, -51 deletions)
View changed files
📝
models/anthropic/manifest.yaml(+1 -1)📝
models/anthropic/models/llm/llm.py(+189 -50)📄 Description
Related Issue or Context
https://github.com/langgenius/dify/issues/7382
Type of Change
Version Control (if applicable)
Versionfield, not in Meta section)Test Evidence (if applicable)
Screenshots or Video/GIF:
Add a
<cache>tag at the end of thesystem/usermessage and it will add a"cache_control": {"type": "ephemeral"}to that block.the prompt token count will be updated to reflect the discounted amount (or added amount for cache read).
Without any

<cache>tag:Same prompt text with
<cache>tag (cache write = 25% more)Same prompt text with
<cache>tag (cache read = 90% less)see the difference in token count...
Environment Verification
Local Deployment Environment
Local Deployment Dify Version: 1.1.2
SaaS Environment
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.