Skip to content

prompt caching SPIKE #109

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

Closed
wants to merge 1 commit into from
Closed

prompt caching SPIKE #109

wants to merge 1 commit into from

Conversation

adenta
Copy link

@adenta adenta commented Apr 14, 2025

No description provided.

@@ -13,6 +13,8 @@
url: /guides/tools
- title: Streaming
url: /guides/streaming
- title: Prompt Caching
Copy link
Author

Choose a reason for hiding this comment

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

Think Cline got a little overzealous w/ documentation

@@ -67,6 +67,29 @@ def supports_json_mode?(model_id)
def supports_extended_thinking?(model_id)
model_id.match?(/claude-3-7-sonnet/)
end

Copy link
Author

Choose a reason for hiding this comment

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

I imagine there is an existing philosophy how to use this data I am unaware of

@@ -26,16 +26,22 @@ def initialize(model: nil, provider: nil)
end

def ask(message = nil, with: {}, &block)
add_message role: :user, content: Content.new(message, with)
# Extract cache_control from the with hash if present
Copy link
Author

Choose a reason for hiding this comment

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

I'm unsure if this is how we want to handle things. this essentailly adds global functionality for an anthropic specific concept.

cache_control: true)

# Add a PDF document with cache control
chat.ask("Please analyze this document:",
Copy link
Author

Choose a reason for hiding this comment

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

this API seems fine to me. We need to tag the messages with "this is where to cache", so the with option seems like a fine place for that.

@crmne
Copy link
Owner

crmne commented Apr 20, 2025

What's a \prompt caching SPIKE?

@adenta
Copy link
Author

adenta commented Apr 20, 2025

It makes things hella cheap

https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching

Some models do it automatically, some don’t

I’m unsure if I’m editing the library code in a sensible way, what do you think?

@crmne
Copy link
Owner

crmne commented Apr 23, 2025

Ok, cool. Can you please change the title and description of your PR?

@adenta adenta changed the title \prompt caching SPIKE prompt caching SPIKE Apr 23, 2025
@adenta
Copy link
Author

adenta commented Apr 23, 2025

I don't think this PR should be merged, its just a spike

I believe this PR is the current thing that would accomplish the same goal, closing this PR

@adenta adenta closed this Apr 23, 2025
@adenta adenta deleted the prompt-caching branch April 23, 2025 20:54
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