From 78eda98b6c8a15637712048f10724affcd6210c1 Mon Sep 17 00:00:00 2001 From: Yusuf Efe <120668197+yuefdev@users.noreply.github.com> Date: Sun, 18 Oct 2026 12:35:09 +0300 Subject: [PATCH] fix(cohere): type the legacy request transformer boundary Signed-off-by: Yusuf Efe <120668197+yuefdev@users.noreply.github.com> --- litellm/llms/cohere/chat/v2_transformation.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/litellm/llms/cohere/chat/v2_transformation.py b/litellm/llms/cohere/chat/v2_transformation.py index f5789af60e7..c6b3e6d6d76 100644 --- a/litellm/llms/cohere/chat/v2_transformation.py +++ b/litellm/llms/cohere/chat/v2_transformation.py @@ -174,12 +174,12 @@ class CohereV2ChatConfig(OpenAIGPTConfig): litellm_params: Mapping[str, object], headers: Mapping[str, object], ) -> dict[str, object]: - data: Final = super().transform_request( + data: Final[dict[str, object]] = super().transform_request( # pyright: ignore[reportUnknownMemberType] # untyped parent dictionary contract model, list(messages), dict(optional_params), dict(litellm_params), dict(headers) ) - messages_to_send: Final = data.get("messages") + messages_to_send: Final[Sequence[AllMessageValues] | None] = data.get("messages") # pyright: ignore[reportAssignmentType] # legacy dict erases the message-list type if messages_to_send is not None: - litellm.remove_index_from_tool_calls(messages=messages_to_send) + litellm.remove_index_from_tool_calls(messages=list(messages_to_send)) return data @@ -191,12 +191,12 @@ class CohereV2ChatConfig(OpenAIGPTConfig): litellm_params: Mapping[str, object], headers: Mapping[str, object], ) -> dict[str, object]: - data: Final = await super().async_transform_request( + data: Final[dict[str, object]] = await super().async_transform_request( # pyright: ignore[reportUnknownMemberType] # untyped parent dictionaries model, list(messages), dict(optional_params), dict(litellm_params), dict(headers) ) - messages_to_send: Final = data.get("messages") + messages_to_send: Final[Sequence[AllMessageValues] | None] = data.get("messages") # pyright: ignore[reportAssignmentType] # legacy dict erases the message-list type if messages_to_send is not None: - litellm.remove_index_from_tool_calls(messages=messages_to_send) + litellm.remove_index_from_tool_calls(messages=list(messages_to_send)) return data