MCPcopy Create free account
hub / github.com/Alibaba-NLP/ViDoRAG / extract_json

Function extract_json

utils/parse_tool.py:19–27  ·  view source on GitHub ↗
(select_response)

Source from the content-addressed store, hash-verified

17 return parsed_tools
18
19def extract_json(select_response):
20 select_response = select_response.replace('```json', '').replace('```', '')
21 start_index = select_response.find('{')
22 end_index = select_response.rfind('}')
23 if start_index != -1 and end_index != -1 and start_index < end_index:
24 json_str = select_response[start_index:end_index + 1]
25 return json.loads(json_str)
26 else:
27 return json.loads(select_response)

Callers 3

runMethod · 0.90
runMethod · 0.90
runMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected