From the course: Building with the Claude API by Anthropic

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Prompt caching in action

Prompt caching in action

Time to get our hands dirty with prompt caching. I've created a new notebook called 003 Caching. You will of course find it attached to this lecture. Inside of here you'll find a section called Prompt with 6K Tokens. So this is meant to serve as a system prompt. We're going to use it in a little bit. In addition, there is a Tool Schema section. It has several different tool schemas to find inside of it. All these different tool schemas put together total up to about 1.7K tokens. We're going to work on updating our chat function, which is inside the cell up here called helper functions, we're going to make sure that our chat function always enables prompt caching for our tool schemas and our system prompt by default. So let me show you how you would do that. Inside the helper function cell, I'm going to scroll down to our chat function. Here it is right here. I'm going to scroll down a little bit further and you'll notice I added in two to-do items. First, if a tools list is provided…

Contents