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 202874c0e3f8f..dd1e906c43243 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 @@ -166,7 +166,10 @@ def messages_to_anthropic_messages( if "cache_control" in message.additional_kwargs else TextBlockParam(text=block.text, type="text") ) - content.append(content_) + + # avoid empty text blocks + if content_["text"]: + content.append(content_) elif isinstance(block, ImageBlock): # FUTURE: Claude does not support URLs, so we need to always convert to base64 img_bytes = block.resolve_image(as_base64=True).read() 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 5ada78ac87def..9756e0e500716 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.0" +version = "0.6.1" [tool.poetry.dependencies] python = ">=3.9,<4.0"