MCPcopy
hub / github.com/langchain-ai/langchain / dumps

Function dumps

libs/core/langchain_core/load/dump.py:16–41  ·  view source on GitHub ↗

Return a json string representation of an object. Args: obj: The object to dump pretty: Whether to pretty print the json. If true, the json will be indented with 2 spaces (if no indent is provided as part of kwargs) **kwargs: Additional arguments to pass to j

(obj: Any, *, pretty: bool = False, **kwargs: Any)

Source from the content-addressed store, hash-verified

14
15
16def dumps(obj: Any, *, pretty: bool = False, **kwargs: Any) -> str:
17 """Return a json string representation of an object.
18
19 Args:
20 obj: The object to dump
21 pretty: Whether to pretty print the json. If true, the json will be
22 indented with 2 spaces (if no indent is provided as part of kwargs)
23 **kwargs: Additional arguments to pass to json.dumps
24
25 Returns:
26 A json string representation of the object
27 """
28 if "default" in kwargs:
29 raise ValueError("`default` should not be passed to dumps")
30 try:
31 if pretty:
32 indent = kwargs.pop("indent", 2)
33 return json.dumps(obj, default=default, indent=indent, **kwargs)
34 else:
35 return json.dumps(obj, default=default, **kwargs)
36 except TypeError:
37 if pretty:
38 indent = kwargs.pop("indent", 2)
39 return json.dumps(to_json_not_implemented(obj), indent=indent, **kwargs)
40 else:
41 return json.dumps(to_json_not_implemented(obj), **kwargs)
42
43
44def dumpd(obj: Any) -> Any:

Callers 15

reciprocal_rank_fusionFunction · 0.90
_dumps_generationsFunction · 0.90
_execute_testFunction · 0.90
_execute_testFunction · 0.90
test_loads_openai_llmFunction · 0.90
test_loads_openai_chatFunction · 0.90
test_fallbacksFunction · 0.90
test_prompt_with_llmFunction · 0.90

Calls 2

to_json_not_implementedFunction · 0.90
popMethod · 0.80

Tested by 15

_execute_testFunction · 0.72
_execute_testFunction · 0.72
test_loads_openai_llmFunction · 0.72
test_loads_openai_chatFunction · 0.72
test_fallbacksFunction · 0.72
test_prompt_with_llmFunction · 0.72
test_combining_sequencesFunction · 0.72