JSON Utilities¶
trulens_eval.utils.json
¶
Json utilities and serialization utilities dealing with json.
Attributes¶
Classes¶
Functions¶
obj_id_of_obj
¶
obj_id_of_obj(obj: dict, prefix='obj')
Create an id from a json-able structure/definition. Should produce the same name if definition stays the same.
json_str_of_obj
¶
Encode the given json object as a string.
json_default
¶
Produce a representation of an object which does not have a json serializer.
jsonify_for_ui
¶
jsonify_for_ui(*args, **kwargs)
Options for jsonify common to UI displays.
Redacts keys and hides special fields introduced by trulens.
jsonify
¶
jsonify(obj: Any, dicted: Optional[Dict[int, JSON]] = None, instrument: Optional['Instrument'] = None, skip_specials: bool = False, redact_keys: bool = False, include_excluded: bool = True) -> JSON
Convert the given object into types that can be serialized in json.
PARAMETER | DESCRIPTION |
---|---|
obj |
the object to jsonify.
TYPE:
|
dicted |
the mapping from addresses of already jsonifed objects (via id) to their json. |
instrument |
instrumentation functions for checking whether to recur into
components of
TYPE:
|
skip_specials |
remove specially keyed structures from the json. These have keys that start with "__tru_".
TYPE:
|
redact_keys |
redact secrets from the output. Secrets are detremined by
TYPE:
|
include_excluded |
include fields that are annotated to be excluded by pydantic.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JSON
|
The jsonified version of the given object. Jsonified means that the the |
JSON
|
object is either a JSON base type, a list, or a dict with the containing |
JSON
|
elements of the same. |