response = await query_engine.aquery(script_prompt) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/llama_index/indices/query/base.py", line 30, in aquery response = await self._aquery(str_or_query_bundle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/llama_index/query_engine/sub_question_query_engine.py", line 124, in _aquery sub_questions = await self._question_gen.agenerate( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/llama_index/question_gen/llm_generators.py", line 78, in agenerate parse = self._prompt.output_parser.parse(prediction) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/llama_index/question_gen/output_parser.py", line 10, in parse json_dict = parse_json_markdown(output) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/llama_index/output_parsers/utils.py", line 18, in parse_json_markdown raise OutputParserException(f"Got invalid JSON object. Error: {e}") llama_index.output_parsers.base.OutputParserException: Got invalid JSON object. Error: Unterminated string starting at: line 49 column 22 (char 4229)
text-davinci-003
, gpt-3.5
and gpt-4
and was getting the same JSONDecodError
. I put in some light debugging and it appears regardless of model-type, it was not generating valid JSON and generating the exact same length partial JSON each time. SubQuestionQueryEngine
class was instantiated I was not setting the service context in the right way. I was setting the service context in the ResponseSythesizer
object, but it needs to be set in LLMQuestionGenerator
object. That fixed the issue for me (at least the JSONDecodeError). Maybe it makes sense to set the default to higher than 256 as most use cases for a compare and contrast query will involve several files? Or at least being clear this could be an issue.from llama_index import set_global_service_context set_global_service_context(service_context)