diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index b442d27c91e..c1b2cb2985e 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -75,12 +75,12 @@ from litellm.types.utils import Message as LitellmMessage from litellm.utils import ( ModelResponse, Usage, - _supports_factory, add_dummy_tool, any_assistant_message_has_thinking_blocks, get_max_tokens, has_tool_call_blocks, last_assistant_with_tool_calls_has_no_thinking_blocks, + supports_mid_conversation_system, supports_reasoning, token_counter, ) @@ -1911,10 +1911,8 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): optional_params["system"] = anthropic_system_message_list conversation: Final = place_mid_conversation_system( later_messages, - supports_mid_conversation_system=_supports_factory( - model=model, - custom_llm_provider=self.custom_llm_provider, - key="supports_mid_conversation_system", + supports_mid_conversation_system=supports_mid_conversation_system( + model=model, custom_llm_provider=self.custom_llm_provider ), ) # Format rest of message according to anthropic guidelines diff --git a/litellm/utils.py b/litellm/utils.py index c2770a1a26d..727ea140ee4 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2722,6 +2722,15 @@ def supports_reasoning(model: str, custom_llm_provider: str | None = None) -> bo return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_reasoning") +def supports_mid_conversation_system(model: str, custom_llm_provider: str | None = None) -> bool: + """ + Check if the given model accepts role=system messages after the first turn and return a boolean value. + """ + return _supports_factory( + model=model, custom_llm_provider=custom_llm_provider, key="supports_mid_conversation_system" + ) + + def supports_native_structured_output(model: str, custom_llm_provider: str | None = None) -> bool: """ Check if the given model supports native structured outputs and return a boolean value.