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

Function extract_and_validate_json

eval/run_predict_minicpm.py:80–90  ·  view source on GitHub ↗
(input_string)

Source from the content-addressed store, hash-verified

78
79
80def extract_and_validate_json(input_string):
81 try:
82 json_obj = json.loads(input_string)
83 jsonschema.validate(json_obj, EXTRACT_SCHEMA)
84 return json_obj
85 except json.JSONDecodeError as e:
86 print("Error, JSON is NOT valid.")
87 return input_string
88 except Exception as e:
89 print(f"Error, JSON is NOT valid according to the schema.{input_string}", e)
90 return input_string
91
92def load_image(episode, image_path, data_name):
93 # resize the image proportionally so that the longer side is at most 1120

Callers 1

run_episodeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected