mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
fix(nvidia_nim): cast untyped top_n before runtime validation
This commit is contained in:
parent
8f991d41cc
commit
37dfda2117
1 changed files with 2 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Final, Literal
|
||||
from typing import Final, Literal, cast
|
||||
|
||||
import httpx
|
||||
from pydantic import ConfigDict, TypeAdapter
|
||||
|
|
@ -210,7 +210,7 @@ class NvidiaNimRerankConfig(BaseRerankConfig):
|
|||
if "documents" not in optional_rerank_params:
|
||||
raise ValueError("documents is required for Nvidia NIM rerank")
|
||||
|
||||
top_n: Final[object] = optional_rerank_params.get("top_n")
|
||||
top_n: Final[object] = cast(object, optional_rerank_params.get("top_n")) # cast-ok: untyped provider parameter is validated below
|
||||
if top_n is not None:
|
||||
if isinstance(top_n, bool) or not isinstance(top_n, int) or top_n < 1:
|
||||
raise ValueError(f"top_n must be a positive integer, got: {top_n!r}")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue