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

Function parse_tool_output

utils/parse_tool.py:5–17  ·  view source on GitHub ↗
(output)

Source from the content-addressed store, hash-verified

3
4
5def parse_tool_output(output):
6
7 tool_pattern = r"<action>\{(.*?)\}</action>"
8 matches = re.findall(tool_pattern, output, re.DOTALL)
9 parsed_tools = []
10 for match in matches:
11 try:
12 # tool_data = json.loads("{" + match.strip() + "}")
13 tool_data = json.loads(match.strip())
14 parsed_tools.append(tool_data)
15 except json.JSONDecodeError as e:
16 print(f"Error decoding JSON: {e}")
17 return parsed_tools
18
19def extract_json(select_response):
20 select_response = select_response.replace('```json', '').replace('```', '')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected