vllm.utils.jsontree ¶
Helper functions to work with nested JSON structures.
Functions:
-
json_count_leaves–Count the number of leaves in a nested JSON structure.
-
json_iter_leaves–Iterate through each leaf in a nested JSON structure.
-
json_map_leaves–Apply a function to each leaf in a nested JSON structure.
-
json_reduce_leaves–Apply a function of two arguments cumulatively to each leaf in a
Attributes:
JSONTree = dict[str, 'JSONTree[_T]'] | list['JSONTree[_T]'] | tuple['JSONTree[_T]', ...] | _T module-attribute ¶
A nested JSON structure where the leaves need not be JSON-serializable.
_JSONTree = dict[str, 'JSONTree[_T]'] | list['JSONTree[_T]'] | tuple['JSONTree[_T]', ...] | dict[str, _T] | list[_T] | tuple[_T, ...] | _T module-attribute ¶
Same as JSONTree but with additional Union members to satisfy overloads.
json_count_leaves(value) ¶
json_iter_leaves(value) ¶
Iterate through each leaf in a nested JSON structure.
Source code in vllm/utils/jsontree.py
json_map_leaves(func, value) ¶
Apply a function to each leaf in a nested JSON structure.
Source code in vllm/utils/jsontree.py
json_reduce_leaves(func, value, initial=...) ¶
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.