MCPcopy Create free account
hub / github.com/OpenBMB/AgentCPM-GUI / load_json_data

Function load_json_data

eval/utils/convert_output.py:14–34  ·  view source on GitHub ↗
(file_path)

Source from the content-addressed store, hash-verified

12
13
14def load_json_data(file_path):
15 data = []
16 # Determine file type, support both JSON and JSONL
17 if file_path.endswith('.json'):
18 # Handle JSON file
19 with open(file_path, 'r') as file:
20 data = json.load(file)
21 elif file_path.endswith('.jsonl'):
22 # Handle JSONL file
23 with open(file_path, 'r') as file:
24 first_line = file.readline().strip()
25 try:
26 json.loads(first_line)
27 data.append(json.loads(first_line))
28 except json.JSONDecodeError:
29 pass
30 for line in file:
31 line = line.strip()
32 if line:
33 data.append(json.loads(line))
34 return data
35
36
37def parse_action(data):

Callers 2

convert2aitzFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected