diff --git a/llama-index-integrations/llms/llama-index-llms-anthropic/llama_index/llms/anthropic/utils.py b/llama-index-integrations/llms/llama-index-llms-anthropic/llama_index/llms/anthropic/utils.py index dd1e906c43243..07020f68ccdb0 100644 --- a/llama-index-integrations/llms/llama-index-llms-anthropic/llama_index/llms/anthropic/utils.py +++ b/llama-index-integrations/llms/llama-index-llms-anthropic/llama_index/llms/anthropic/utils.py @@ -12,13 +12,9 @@ TextBlock, ) -from anthropic.types import MessageParam, TextBlockParam, ImageBlockParam +from anthropic.types import MessageParam, TextBlockParam, ImageBlockParam, CacheControlEphemeralParam from anthropic.types.tool_result_block_param import ToolResultBlockParam from anthropic.types.tool_use_block_param import ToolUseBlockParam -from anthropic.types.beta.prompt_caching import ( - PromptCachingBetaTextBlockParam, - PromptCachingBetaCacheControlEphemeralParam, -) HUMAN_PREFIX = "\n\nHuman:" ASSISTANT_PREFIX = "\n\nAssistant:" @@ -156,10 +152,10 @@ def messages_to_anthropic_messages( for block in message.blocks: if isinstance(block, TextBlock): content_ = ( - PromptCachingBetaTextBlockParam( + TextBlockParam( text=block.text, type="text", - cache_control=PromptCachingBetaCacheControlEphemeralParam( + cache_control=CacheControlEphemeralParam( type="ephemeral" ), )