diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index 4cd8a689afa..9949639ffc6 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -7,7 +7,7 @@ import re import xml.etree.ElementTree as ET from collections.abc import Iterator, Mapping, Sequence from enum import Enum -from typing import Any, Final, TypedDict, cast, overload +from typing import Any, Final, TypeAlias, TypedDict, cast, overload from jinja2.sandbox import ImmutableSandboxedEnvironment @@ -2307,7 +2307,7 @@ def _drop_unsignable_thinking_blocks( # mutable-ok: anthropic_messages_pt's callers have always appended to the list it returns -_AnthropicMessageList = list[AllAnthropicPassThroughMessageValues] +_AnthropicMessageList: TypeAlias = list[AllAnthropicPassThroughMessageValues] def anthropic_messages_pt( diff --git a/litellm/llms/anthropic/mid_conversation_system.py b/litellm/llms/anthropic/mid_conversation_system.py index 766faf66312..8b1c2b0c6d2 100644 --- a/litellm/llms/anthropic/mid_conversation_system.py +++ b/litellm/llms/anthropic/mid_conversation_system.py @@ -26,7 +26,7 @@ Anthropic wire shape is built later by ``anthropic_messages_pt``. from collections.abc import Iterator, Mapping, Sequence from itertools import groupby -from typing import Final, Literal +from typing import Final, Literal, TypeAlias from litellm.types.llms.anthropic import AnthropicMessagesSystemMessageParam, AnthropicSystemMessageContent from litellm.types.llms.openai import ( @@ -44,8 +44,8 @@ CONVERTED_SYSTEM_NOTE: Final = ( _USER_TYPE_ROLES: Final = frozenset({"user", "tool", "function"}) _TOOL_ROLES: Final = frozenset({"tool", "function"}) -_MessageKind = Literal["system", "tool", "user", "other"] -_TextPart = tuple[str, ChatCompletionCachedContent | None] +_MessageKind: TypeAlias = Literal["system", "tool", "user", "other"] +_TextPart: TypeAlias = tuple[str, ChatCompletionCachedContent | None] def _as_mapping(value: object) -> Mapping[str, object] | None: