mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
Third batch of the fifth basedpyright Any reduction round. Every change is typing-only and leaves runtime behavior identical. Provider transformation configs, video and rerank base classes, OTel metadata and the guardrail and realtime type modules move their payload, header and optional-parameter annotations from Any to object, Mapping[str, object] or the concrete model the call site already produces. Repositories and endpoints that reached Prisma through an untyped handle now name the actions they call with the repo's own TableActions protocol. The pydantic field retypes were checked against pydantic to confirm object and Any validate, serialize and generate JSON schema identically.
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
from collections.abc import Mapping
|
|
from typing import Final, cast, get_type_hints
|
|
|
|
from litellm.types.vector_store_files import (
|
|
VectorStoreFileCreateRequest,
|
|
VectorStoreFileListQueryParams,
|
|
VectorStoreFileUpdateRequest,
|
|
)
|
|
|
|
|
|
class VectorStoreFileRequestUtils:
|
|
"""Helper utilities for constructing vector store file requests."""
|
|
|
|
@staticmethod
|
|
def _filter_params(params: Mapping[str, object], model: type[object]) -> dict[str, object]:
|
|
valid_keys: Final = get_type_hints(model).keys()
|
|
return {key: value for key, value in params.items() if key in valid_keys and value is not None}
|
|
|
|
@staticmethod
|
|
def get_create_request_params(
|
|
params: Mapping[str, object],
|
|
) -> VectorStoreFileCreateRequest:
|
|
filtered: Final = VectorStoreFileRequestUtils._filter_params(params=params, model=VectorStoreFileCreateRequest)
|
|
return cast(VectorStoreFileCreateRequest, filtered)
|
|
|
|
@staticmethod
|
|
def get_list_query_params(params: Mapping[str, object]) -> VectorStoreFileListQueryParams:
|
|
filtered = VectorStoreFileRequestUtils._filter_params(params=params, model=VectorStoreFileListQueryParams)
|
|
return cast(VectorStoreFileListQueryParams, filtered)
|
|
|
|
@staticmethod
|
|
def get_update_request_params(
|
|
params: Mapping[str, object],
|
|
) -> VectorStoreFileUpdateRequest:
|
|
filtered: Final = VectorStoreFileRequestUtils._filter_params(params=params, model=VectorStoreFileUpdateRequest)
|
|
return cast(VectorStoreFileUpdateRequest, filtered)
|