From 72e1a850a895f116ca604ab7839753c1dbbd058d Mon Sep 17 00:00:00 2001 From: Connor McLean Date: Tue, 17 Dec 2024 10:28:56 -0700 Subject: [PATCH] update anthropic type imports --- .../llama_index/llms/anthropic/utils.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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" ), )