From 3cb8e23dfe5ce5fdd75779df86bfad2414613e04 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 30 Aug 2025 11:23:18 -0700 Subject: [PATCH] Revert "Merge pull request #14026 from TomeHirata/citation-supported-text" This reverts commit afa687182a3e992fad59e0784bc1ed0809d0dc17, reversing changes made to 55186dad4c989fa3082dbb98e2b8be875ebe8005. --- litellm/llms/anthropic/chat/handler.py | 2 -- litellm/llms/anthropic/chat/transformation.py | 10 +--------- .../test_anthropic_completion.py | 18 +++++------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.py index 253f5d9be2c..5618c50923e 100644 --- a/litellm/llms/anthropic/chat/handler.py +++ b/litellm/llms/anthropic/chat/handler.py @@ -743,8 +743,6 @@ class ModelResponseIterator: ) text, tool_use = self._handle_json_mode_chunk(text=text, tool_use=tool_use) - if type_chunk: - provider_specific_fields["chunk_type"] = type_chunk returned_chunk = ModelResponseStream( choices=[ diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 378ca75da5f..ce874bfde9a 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -797,15 +797,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): if content.get("citations") is not None: if citations is None: citations = [] - citations.append( - [ - { - **citation, - "supported_text": content.get("text", ""), - } - for citation in content["citations"] - ] - ) + citations.append(content["citations"]) if thinking_blocks is not None: reasoning_content = "" for block in thinking_blocks: diff --git a/tests/llm_translation/test_anthropic_completion.py b/tests/llm_translation/test_anthropic_completion.py index f4bd7531b0b..45702a261e2 100644 --- a/tests/llm_translation/test_anthropic_completion.py +++ b/tests/llm_translation/test_anthropic_completion.py @@ -920,14 +920,6 @@ def test_anthropic_citations_api(): citations = resp.choices[0].message.provider_specific_fields["citations"] assert citations is not None - if citations: - citation = citations[0][0] - assert "supported_text" in citation - assert "cited_text" in citation - assert "document_index" in citation - assert "document_title" in citation - assert "start_char_index" in citation - assert "end_char_index" in citation def test_anthropic_citations_api_streaming(): @@ -963,11 +955,11 @@ def test_anthropic_citations_api_streaming(): has_citations = False for chunk in resp: print(f"returned chunk: {chunk}") - if provider_specific_fields := chunk.choices[0].delta.provider_specific_fields: - if "citation" in provider_specific_fields: - has_citations = True - - assert "chunk_type" in provider_specific_fields + if ( + chunk.choices[0].delta.provider_specific_fields + and "citation" in chunk.choices[0].delta.provider_specific_fields + ): + has_citations = True assert has_citations