diff --git a/griptape/engines/extraction/json_extraction_engine.py b/griptape/engines/extraction/json_extraction_engine.py index 56815bc06..5fc64f838 100644 --- a/griptape/engines/extraction/json_extraction_engine.py +++ b/griptape/engines/extraction/json_extraction_engine.py @@ -18,7 +18,7 @@ @define class JsonExtractionEngine(BaseExtractionEngine): - JSON_PATTERN = r"(?s)[^\[]*(\[.*\])" + JSON_PATTERN = r"(?s)(\{.*?\}|\[.*?\])" template_schema: dict = field(default=Factory(dict), kw_only=True) system_template_generator: J2 = field( diff --git a/griptape/templates/engines/extraction/json/user.j2 b/griptape/templates/engines/extraction/json/user.j2 index 984977d9a..00e162d15 100644 --- a/griptape/templates/engines/extraction/json/user.j2 +++ b/griptape/templates/engines/extraction/json/user.j2 @@ -1,4 +1,4 @@ -Extract information from the Text based on the Extraction Template JSON Schema into an array of JSON objects. +Extract information from the Text based on the Extraction Template JSON Schema into valid JSON. Text: """{{ text }}""" -JSON array: +JSON: