vllm.utils.jsontree ¶
 Helper functions to work with nested JSON structures.
  JSONTree  module-attribute  ¶
 JSONTree: TypeAlias = (
    dict[str, "JSONTree[_T]"]
    | list["JSONTree[_T]"]
    | tuple["JSONTree[_T]", ...]
    | _T
)
A nested JSON structure where the leaves need not be JSON-serializable.
  _JSONTree  module-attribute  ¶
 _JSONTree: TypeAlias = (
    dict[str, "JSONTree[_T]"]
    | list["JSONTree[_T]"]
    | tuple["JSONTree[_T]", ...]
    | dict[str, _T]
    | list[_T]
    | tuple[_T, ...]
    | _T
)
Same as JSONTree but with additional Union members to satisfy overloads.
  json_count_leaves ¶
     json_iter_leaves ¶
  Iterate through each leaf in a nested JSON structure.
Source code in vllm/utils/jsontree.py
   json_map_leaves ¶
 json_map_leaves(
    func: Callable[[Tensor], Tensor],
    value: BatchedTensorInputs,
) -> BatchedTensorInputs
json_map_leaves(
    func: Callable[[_T], _U],
    value: BatchedTensorInputs | _JSONTree[_T],
) -> BatchedTensorInputs | _JSONTree[_U]
Apply a function to each leaf in a nested JSON structure.
Source code in vllm/utils/jsontree.py
   json_reduce_leaves ¶
 json_reduce_leaves(
    func: Callable[..., _U" backlink-type="used-by" backlink-anchor="vllm.utils.jsontree.json_reduce_leaves" optional hover>_U | _U],
    value: _JSONTree[_U" backlink-type="used-by" backlink-anchor="vllm.utils.jsontree.json_reduce_leaves" optional hover>_U],
    initial: _U = cast(_U, ...),
) -> _T | _U
Apply a function of two arguments cumulatively to each leaf in a nested JSON structure, from left to right, so as to reduce the sequence to a single value.