| 377 | |
| 378 | |
| 379 | def extract_and_validate_json(input_string): |
| 380 | # if input_string == "": |
| 381 | # raise ValueError("Error, empty output.") |
| 382 | try: |
| 383 | json_obj = json.loads(input_string) |
| 384 | # validate JSON data against Schema |
| 385 | jsonschema.validate(json_obj, ACTION_THOUGHT_SCHEMA) |
| 386 | return json_obj |
| 387 | except json.JSONDecodeError as e: |
| 388 | print("Error, JSON is NOT valid.",input_string,"over") |
| 389 | return input_string |
| 390 | except Exception as e: |
| 391 | print("Error, JSON is NOT valid according to the schema.",input_string,"over") |
| 392 | return input_string |
| 393 | |
| 394 | def load_image(episode,image_path,history_list,use_low_instruction): |
| 395 | return (episode,image_path,history_list,use_low_instruction) |