Skip to content

Commit

Permalink
fix notebook explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Oct 30, 2024
1 parent 8d5d277 commit ea57bea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cookbook/Prompt_Caching_with_Anthropic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
"</a>\n",
"\n",
"Prompt caching allows you to store and reuse context within your prompt saving time and money. When using the prompt cache feature from Anthropic, the chat messages have to be expressed in blocks rather than simple text, so that for each block you can define the cache behaviour.\n",
"Prompt caching allows you to store and reuse context within your prompt saving time and money. When using the prompt cache feature from Anthropic, the chat messages have to be expressed in blocks rather than simple text, so that you can designate one of the for being cached.\n",
"\n",
"Let's see how Banks makes this super easy."
]
Expand Down Expand Up @@ -75,7 +75,7 @@
"source": [
"With Banks we can define which part of the prompt specifically will be cached. \n",
"Directly from the prompt template text, we can use the `cache_control` built-in filter to tell Anthropic that\n",
"we want to cache the whole text resulting from the `{{ book }}` template block."
"we want to cache the prompt up to and including the `{{ book }}` template block."
]
},
{
Expand All @@ -98,9 +98,11 @@
"{% chat role=\"user\" %}\n",
"Analyze this book:\n",
"\n",
"{# Only this part of the message content (the book content) will be cached #}\n",
"{# Only this part of the message content (including the book content) will be cached #}\n",
"{{ book | cache_control(\"ephemeral\") }}\n",
"\n",
"{# This part won't be cached instead #}\n",
"\n",
"What is the title of this book? Only output the title.\n",
"{% endchat %}\n",
"\"\"\"\n",
Expand Down

0 comments on commit ea57bea

Please sign in to comment.