#Prompting and parsing to use Completion endpoint answer in code
3 messages · Page 1 of 1 (latest)
You can say "respond in json" its like a dict
For a list you can say "respond in array format"
Then you can convert it to a list
Using the json module
import json
response = "['1', '2', '3']"
converted_response = json.loads(resposne)
print(converted_response)
I need to test json.loads more, was getting errors. For now I've got it working, handling the response with eval(). The prompt I'm using says:
"Show headings as a Python list of strings enclosed in square brackets, like this:
['A', 'B', 'C', ...]
subheads_list ="