From a63eb58f1bf48831d95d90188cd9f5c4ca18904e Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sun, 2 Mar 2025 08:36:29 -0800 Subject: [PATCH] fix(anthropic/chat/transformation.py): fix headers to be a set avoid duplicates --- litellm/llms/anthropic/chat/transformation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index a45b9271141..383c1cd3e53 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -126,13 +126,13 @@ class AnthropicConfig(BaseConfig): user_anthropic_beta_headers: Optional[List[str]] = None, ) -> dict: - betas = [] + betas = set() if prompt_caching_set: - betas.append("prompt-caching-2024-07-31") + betas.add("prompt-caching-2024-07-31") if computer_tool_used: - betas.append("computer-use-2024-10-22") + betas.add("computer-use-2024-10-22") if pdf_used: - betas.append("pdfs-2024-09-25") + betas.add("pdfs-2024-09-25") headers = { "anthropic-version": anthropic_version or "2023-06-01", "x-api-key": api_key, @@ -141,7 +141,7 @@ class AnthropicConfig(BaseConfig): } if user_anthropic_beta_headers is not None: - betas.extend(user_anthropic_beta_headers) + betas.update(user_anthropic_beta_headers) # Don't send any beta headers to Vertex, Vertex has failed requests when they are sent if is_vertex_request is True: