mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-06 07:48:06 +00:00
fix(cohere): type _parse_tool_call_delta without growing basedpyright counts
The reassigned Final local and the untyped chunk lookups added basedpyright errors past the base ceiling. Narrow them with casts; per-rule counts for the file are now at or below the merge-base. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a4c7d57c2c
commit
a3dd9c1f4f
1 changed files with 6 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
from typing import Final, Literal
|
||||
from typing import Final, Literal, cast
|
||||
|
||||
from litellm.llms.base_llm.base_utils import BaseLLMModelInfo
|
||||
from litellm.llms.base_llm.chat.transformation import BaseLLMException
|
||||
|
|
@ -236,12 +236,12 @@ class CohereV2ModelResponseIterator:
|
|||
|
||||
def _parse_tool_call_delta(self, chunk: dict, index: int) -> ChatCompletionToolCallChunk | None:
|
||||
"""Parse tool-call-start and tool-call-delta chunks to extract tool calls."""
|
||||
tool_call: Final = chunk.get("delta", {}).get("message", {}).get("tool_calls") or {}
|
||||
if isinstance(tool_call, list):
|
||||
tool_call = tool_call[0] if tool_call else {}
|
||||
function: Final = tool_call.get("function") or {}
|
||||
delta: Final = cast("dict[str, dict[str, object]]", chunk.get("delta") or {})
|
||||
raw: Final = delta.get("message", {}).get("tool_calls") or {}
|
||||
tool_call: Final = cast("dict[str, object]", (raw[0] if raw else {}) if isinstance(raw, list) else raw)
|
||||
function: Final = cast("dict[str, str]", tool_call.get("function") or {})
|
||||
return {
|
||||
"id": tool_call.get("id"),
|
||||
"id": cast("str", tool_call.get("id")),
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": function.get("name"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue