From 72e1a850a895f116ca604ab7839753c1dbbd058d Mon Sep 17 00:00:00 2001 From: Connor McLean Date: Tue, 17 Dec 2024 10:28:56 -0700 Subject: [PATCH 1/5] 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" ), ) From 54715ca67206f4d247a7c5a7ca946d9ce43f3e4c Mon Sep 17 00:00:00 2001 From: Connor McLean Date: Tue, 17 Dec 2024 10:39:46 -0700 Subject: [PATCH 2/5] update anthropic version --- .../llms/llama-index-llms-anthropic/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml index 9756e0e500716..8d5639687efd5 100644 --- a/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml @@ -31,7 +31,7 @@ version = "0.6.1" [tool.poetry.dependencies] python = ">=3.9,<4.0" -anthropic = {extras = ["bedrock", "vertex"], version = ">=0.39.0"} +anthropic = {extras = ["bedrock", "vertex"], version = ">=0.41.0"} llama-index-core = "^0.12.5" [tool.poetry.group.dev.dependencies] From d05e604e300dbb8a7f9ba5d4c5d934eed0f781aa Mon Sep 17 00:00:00 2001 From: Connor McLean Date: Tue, 17 Dec 2024 10:45:47 -0700 Subject: [PATCH 3/5] format and lint --- .../llama_index/llms/anthropic/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 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 07020f68ccdb0..c41eb10d36857 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,7 +12,12 @@ TextBlock, ) -from anthropic.types import MessageParam, TextBlockParam, ImageBlockParam, CacheControlEphemeralParam +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 @@ -155,9 +160,7 @@ def messages_to_anthropic_messages( TextBlockParam( text=block.text, type="text", - cache_control=CacheControlEphemeralParam( - type="ephemeral" - ), + cache_control=CacheControlEphemeralParam(type="ephemeral"), ) if "cache_control" in message.additional_kwargs else TextBlockParam(text=block.text, type="text") From 6886e5dfed51219579673f5fcbc59eec2be0c1fe Mon Sep 17 00:00:00 2001 From: Andrei Fajardo Date: Tue, 17 Dec 2024 15:20:42 -0500 Subject: [PATCH 4/5] vbump --- .../llms/llama-index-llms-anthropic/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml index 8d5639687efd5..dcbf6cd9a6d13 100644 --- a/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml @@ -27,7 +27,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-llms-anthropic" readme = "README.md" -version = "0.6.1" +version = "0.6.2" [tool.poetry.dependencies] python = ">=3.9,<4.0" From f939aa994fb404aea15578dd3bd017f523b39757 Mon Sep 17 00:00:00 2001 From: Logan Markewich Date: Tue, 17 Dec 2024 14:55:18 -0600 Subject: [PATCH 5/5] vbump --- .../llms/llama-index-llms-anthropic/pyproject.toml | 2 +- .../llms/llama-index-llms-bedrock/pyproject.toml | 2 +- .../llms/llama-index-llms-portkey/pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml index dcbf6cd9a6d13..9cd67a3377b62 100644 --- a/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-anthropic/pyproject.toml @@ -27,7 +27,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-llms-anthropic" readme = "README.md" -version = "0.6.2" +version = "0.6.3" [tool.poetry.dependencies] python = ">=3.9,<4.0" diff --git a/llama-index-integrations/llms/llama-index-llms-bedrock/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-bedrock/pyproject.toml index 20f28280db1f3..234830b74eeb9 100644 --- a/llama-index-integrations/llms/llama-index-llms-bedrock/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-bedrock/pyproject.toml @@ -31,7 +31,7 @@ version = "0.3.1" [tool.poetry.dependencies] python = ">=3.9,<4.0" -llama-index-llms-anthropic = "^0.5.0" +llama-index-llms-anthropic = "^0.6.3" boto3 = "^1.34.26" llama-index-core = "^0.12.0" diff --git a/llama-index-integrations/llms/llama-index-llms-portkey/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-portkey/pyproject.toml index 0d29002982a3e..fc36a0bb50a1f 100644 --- a/llama-index-integrations/llms/llama-index-llms-portkey/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-portkey/pyproject.toml @@ -31,7 +31,7 @@ version = "0.3.0" [tool.poetry.dependencies] python = ">=3.9,<4.0" -llama-index-llms-anthropic = "^0.5.0" +llama-index-llms-anthropic = "^0.6.3" portkey-ai = "^1.1.4" portkey = "^0.1.2" llama-index-llms-openai = "^0.3.0"