mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-08 08:44:23 +01:00
Fix validate_json file error when cwd != project root (#2665)
Co-authored-by: qianchengliang <qianchengliang1@huawei.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Utilities for the json_fixes package."""
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
|
||||
from jsonschema import Draft7Validator
|
||||
@@ -34,7 +35,9 @@ def validate_json(json_object: object, schema_name: object) -> object:
|
||||
:param schema_name:
|
||||
:type json_object: object
|
||||
"""
|
||||
with open(f"autogpt/json_utils/{schema_name}.json", "r") as f:
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
with open(os.path.join(script_dir, f"{schema_name}.json"), "r") as f:
|
||||
schema = json.load(f)
|
||||
validator = Draft7Validator(schema)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user