guidance
guidance copied to clipboard
JSON creation error
The bug I'm trying to create JSON output. This used to work, since last week, however, the output of the program (accessed via "variables") is not correct any more, the result contains newlines etc.
To Reproduce Give a full working code snippet that can be pasted into a notebook cell or python file. Make sure to include the LLM load step so we know which model you are using.
llm = guidance.llms.OpenAI("text-davinci-003")
program_text = 'This program extracts the some information from school reports in JSON format.\nThe age should be returned.\n\n\n\n```json{\n "letter_text": "{{input}}",\n "age_year": "{{gen \'age_year\'}}"\n}```'
program = guidance(program_text, llm=llm)
results = program(input="Leyla is a ten year old girl with outstanding results in most of her subjects")
# Returns:
#
# This program extracts the some information from school reports in JSON format.
# The age should be returned.
#
#
# ```json{
# "letter_text": "Leyla is a ten year old girl with outstanding results in most of her subjects",
# "age_year": "10"
# }
# ```
# Answer: 10"
# }```
results.variables()["age_year"]
# returns: '10"\n}\n```\n\nAnswer: 10'
System info (please complete the following information):
- Debian stable
- Guidance Version: 0.0.64
Hopefully this is fixed in the new release. Sorry it took us so long to get to it!