refine code for isinstance

This commit is contained in:
geekan 2023-12-19 18:50:55 +08:00 committed by better629
parent fc829edc45
commit 06d8dccc16
4 changed files with 4 additions and 4 deletions

View file

@ -203,7 +203,7 @@ class OutputParser:
result = ast.literal_eval(structure_text)
# Ensure the result matches the specified data type
if isinstance(result, list) or isinstance(result, dict):
if isinstance(result, (list, dict)):
return result
raise ValueError(f"The extracted structure is not a {data_type}.")