[Bug] Catch any errors caused by parsing json schema (#1776)

This commit is contained in:
zolinthecow
2024-10-24 01:54:53 -07:00
committed by GitHub
parent 87a7cfa080
commit 72e7b57a75

View File

@@ -73,9 +73,16 @@ class FSMCache(BaseToolCache):
def init_value(self, key):
key_type, key_string = key
if key_type == "json":
regex = build_regex_from_schema(
key_string, whitespace_pattern=self.constrained_json_whitespace_pattern
)
try:
regex = build_regex_from_schema(
key_string,
whitespace_pattern=self.constrained_json_whitespace_pattern,
)
except NotImplementedError as e:
logger.warning(
f"skip invalid json schema: json_schema={key_string}, {e=}"
)
return None, key_string
elif key_type == "regex":
regex = key_string
else: