fix(cohere): strongly type mapping parameters and drop unused helper branch

This commit is contained in:
Yusuf Efe 2026-09-16 03:45:55 +03:00
parent fd0723c0da
commit a0a4300f0e
2 changed files with 8 additions and 13 deletions

View file

@ -261,11 +261,6 @@ def remove_index_from_tool_calls(
for tool_call in _tool_calls:
if isinstance(tool_call, dict) and "index" in tool_call: # Type guard to ensure it's a dict
tool_call.pop("index", None)
elif hasattr(tool_call, "index"):
try:
delattr(tool_call, "index")
except Exception:
pass
def remove_items_at_indices(items: list[Any] | None, indices: Iterable[int]) -> None:

View file

@ -170,10 +170,10 @@ class CohereV2ChatConfig(OpenAIGPTConfig):
self,
model: str,
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
headers: dict,
) -> dict:
optional_params: dict[str, object],
litellm_params: dict[str, object],
headers: dict[str, object],
) -> dict[str, object]:
data: Final = super().transform_request(model, messages, optional_params, litellm_params, headers)
messages_to_send: Final = data.get("messages")
if messages_to_send is not None:
@ -185,10 +185,10 @@ class CohereV2ChatConfig(OpenAIGPTConfig):
self,
model: str,
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
headers: dict,
) -> dict:
optional_params: dict[str, object],
litellm_params: dict[str, object],
headers: dict[str, object],
) -> dict[str, object]:
data: Final = await super().async_transform_request(model, messages, optional_params, litellm_params, headers)
messages_to_send: Final = data.get("messages")
if messages_to_send is not None: