vllm.jsontree
Helper functions to work with nested JSON structures.
JSONTree
module-attribute
¶
JSONTree = Union[
dict[str, "JSONTree[_T]"],
list["JSONTree[_T]"],
tuple["JSONTree[_T]", ...],
_T,
]
A nested JSON structure where the leaves need not be JSON-serializable.
json_iter_leaves
¶
Iterate through each leaf in a nested JSON structure.
Source code in vllm/jsontree.py
json_map_leaves
¶
Apply a function to each leaf in a nested JSON structure.
Source code in vllm/jsontree.py
json_reduce_leaves
¶
json_reduce_leaves(
func: Callable[..., Union[_T" optional hover>_T, _U]],
value: JSONTree[_T],
initial: _U = ...,
) -> Union[_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.