mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(mypy): fix remaining type errors after first pass
- Perplexity: avoid TypedDict spread by using dict() conversion - Vertex batch_embed: use Any type for request_data variable - route_llm_request: sync route_request Literal with base_process_llm_request - Presidio: cast chunks from internal generators to ModelResponseStream - key_management: properly handle None case for object_permission_dict - completion_transformation: use isinstance check for list type narrowing Co-authored-by: yuneng-jiang <yuneng-jiang@users.noreply.github.com>
This commit is contained in:
parent
8f854a35e7
commit
bd9df9a78c
6 changed files with 33 additions and 12 deletions
|
|
@ -71,8 +71,11 @@ class PerplexityResponsesConfig(OpenAIResponsesAPIConfig):
|
|||
result: List[Any] = []
|
||||
for item in input:
|
||||
if isinstance(item, dict) and "type" not in item:
|
||||
item = {**item, "type": "message"}
|
||||
result.append(item)
|
||||
new_item = dict(item) # convert to plain dict to avoid TypedDict checking
|
||||
new_item["type"] = "message"
|
||||
result.append(new_item)
|
||||
else:
|
||||
result.append(item)
|
||||
return result
|
||||
return input
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class GoogleBatchEmbeddings(VertexLLM):
|
|||
)
|
||||
|
||||
### TRANSFORMATION (sync path) ###
|
||||
request_data: Dict[str, Any]
|
||||
request_data: Any
|
||||
if use_embed_content:
|
||||
resolved_files = {}
|
||||
if api_key:
|
||||
|
|
|
|||
|
|
@ -1242,7 +1242,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomGuardrail):
|
|||
async for chunk in self._stream_apply_output_masking(
|
||||
response, request_data
|
||||
):
|
||||
yield chunk
|
||||
yield cast(ModelResponseStream, chunk)
|
||||
return
|
||||
|
||||
metadata = (request_data.get("metadata") or {}) if request_data else {}
|
||||
|
|
@ -1257,7 +1257,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomGuardrail):
|
|||
return
|
||||
|
||||
async for chunk in self._stream_pii_unmasking(response, request_data):
|
||||
yield chunk
|
||||
yield cast(ModelResponseStream, chunk)
|
||||
|
||||
@staticmethod
|
||||
def _preserve_usage_from_last_chunk(
|
||||
|
|
|
|||
|
|
@ -1776,11 +1776,13 @@ async def _validate_mcp_servers_for_key_update(
|
|||
user_api_key_cache=user_api_key_cache,
|
||||
check_db_only=True,
|
||||
)
|
||||
object_permission_dict = (
|
||||
data.object_permission.model_dump()
|
||||
if data.object_permission is not None and hasattr(data.object_permission, "model_dump")
|
||||
else data.object_permission
|
||||
)
|
||||
object_permission_dict: Optional[dict] = None
|
||||
if data.object_permission is not None:
|
||||
object_permission_dict = (
|
||||
data.object_permission.model_dump()
|
||||
if hasattr(data.object_permission, "model_dump")
|
||||
else dict(data.object_permission) # type: ignore[arg-type]
|
||||
)
|
||||
await validate_key_mcp_servers_against_team(
|
||||
object_permission=object_permission_dict,
|
||||
team_obj=effective_team_obj,
|
||||
|
|
|
|||
|
|
@ -173,8 +173,21 @@ async def route_request( # noqa: PLR0915 - Complex routing function, refactorin
|
|||
"agenerate_content",
|
||||
"agenerate_content_stream",
|
||||
"allm_passthrough_route",
|
||||
"acreate_batch",
|
||||
"aretrieve_batch",
|
||||
"alist_batches",
|
||||
"afile_content",
|
||||
"afile_retrieve",
|
||||
"acreate_fine_tuning_job",
|
||||
"acancel_fine_tuning_job",
|
||||
"alist_fine_tuning_jobs",
|
||||
"aretrieve_fine_tuning_job",
|
||||
"avector_store_search",
|
||||
"avector_store_create",
|
||||
"avector_store_retrieve",
|
||||
"avector_store_list",
|
||||
"avector_store_update",
|
||||
"avector_store_delete",
|
||||
"avector_store_file_create",
|
||||
"avector_store_file_list",
|
||||
"avector_store_file_retrieve",
|
||||
|
|
@ -207,6 +220,8 @@ async def route_request( # noqa: PLR0915 - Complex routing function, refactorin
|
|||
"aget_interaction",
|
||||
"adelete_interaction",
|
||||
"acancel_interaction",
|
||||
"asend_message",
|
||||
"call_mcp_tool",
|
||||
"acancel_batch",
|
||||
"afile_delete",
|
||||
"acreate_eval",
|
||||
|
|
|
|||
|
|
@ -410,11 +410,12 @@ class LiteLLMCompletionResponsesConfig:
|
|||
else getattr(new_msg, "role", None)
|
||||
)
|
||||
if new_role == "assistant":
|
||||
new_tcs: list = (
|
||||
_raw_tcs = (
|
||||
new_msg.get("tool_calls")
|
||||
if isinstance(new_msg, dict)
|
||||
else getattr(new_msg, "tool_calls", None)
|
||||
) or []
|
||||
)
|
||||
new_tcs: list = _raw_tcs if isinstance(_raw_tcs, list) else []
|
||||
for tc in new_tcs:
|
||||
LiteLLMCompletionResponsesConfig._add_tool_call_to_assistant(
|
||||
last_msg, tc
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue