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

Method keys

libs/community/langchain_community/tools/json/tool.py:42–60  ·  view source on GitHub ↗

Return the keys of the dict at the given path. Args: text: Python representation of the path to the dict (e.g. data["key1"][0]["key2"]).

(self, text: str)

Source from the content-addressed store, hash-verified

40 return cls(dict_=dict_)
41
42 def keys(self, text: str) -> str:
43 """Return the keys of the dict at the given path.
44
45 Args:
46 text: Python representation of the path to the dict (e.g. data["key1"][0]["key2"]).
47 """
48 try:
49 items = _parse_input(text)
50 val = self.dict_
51 for i in items:
52 if i:
53 val = val[i]
54 if not isinstance(val, dict):
55 raise ValueError(
56 f"Value at path `{text}` is not a dict, get the value directly."
57 )
58 return str(list(val.keys()))
59 except Exception as e:
60 return repr(e)
61
62 def value(self, text: str) -> str:
63 """Return the value of the dict at the given path.

Callers 15

test_json_spec_keysFunction · 0.95
normalizeMethod · 0.80
add_textsMethod · 0.80
test_get_tools_successFunction · 0.80
teardown_classMethod · 0.80
build_extraMethod · 0.80
_xml_to_function_callFunction · 0.80
construct_instanceMethod · 0.80
aconstruct_instanceMethod · 0.80

Calls 2

listFunction · 0.85
_parse_inputFunction · 0.70

Tested by

no test coverage detected