Closed younes-io closed 6 months ago
🤖
Hey @younes-io, good to see you again! Thanks for presenting this detailed issue. I'm diving into it and will have a full response for you shortly. Hang tight!
FYI I use
Name: guidance Version: 0.0.64
Did you mention to fix this?
I got this with both stabilityai/stablelm-zephyr-3b and zephyr 7b
🤖
Based on the error message you provided, it seems like the issue is with the JSON object that is being parsed. The error message indicates that there is an issue with the JSON object at line 2, column 31. The error message suggests that a ',' or '}' was expected, but a '
Looking at the JSON object in your error message:
{
"name": "{gen 'name' stop='"'}",
"artist": "{gen 'artist' stop='"'}",
"songs": [{#geneach 'songs' stop=']'}{#unless @first}, {/unless}{
"title": "{gen 'title' stop='"'}",
"length_seconds": "{gen 'length_seconds' stop='"'}",
}{/geneach}],
}
It seems like the issue might be with the {gen 'name' stop='"'}
and {gen 'artist' stop='"'}
parts of the JSON object. The {gen ...}
syntax seems to be a placeholder for generating some value, but it's not valid JSON syntax. This could be why the parser is failing.
The parse_json_markdown
function in llama_index/output_parsers/utils.py
is designed to parse a JSON object embedded within a markdown text block. The expected format of the JSON object is a valid JSON object or array that can be parsed by Python's json.loads
function or PyYAML's yaml.safe_load
function.
If the JSON object or array cannot be parsed by json.loads
, the function tries to parse it with yaml.safe_load
, which is less strict and allows for trailing commas. If this also fails, it raises an OutputParserException
.
So, the expected format of the JSON object is a valid JSON or YAML syntax that can be parsed by Python's json.loads
or PyYAML's yaml.safe_load
function. It should be embedded within a markdown text block, surrounded by "json" and "
".
You can find more details about this in the llama_index/output_parsers/utils.py file.
To resolve this issue, you might need to ensure that the JSON object being passed to the parse_json_markdown
function is a valid JSON object. If the {gen ...}
syntax is a placeholder, you might need to replace it with a valid value before passing it to the function.
I hope this helps! If you have any more questions or need further clarification, feel free to ask.
Bug Description
@Harsha-Nori:
When I execute the code below taken from the official docs.
I get this log:
Version
Version: 0.9.13
Steps to Reproduce
Execute the code above in a notebook (python 3.9.18)
Relevant Logs/Tracbacks