#Prompting and parsing to use Completion endpoint answer in code

3 messages · Page 1 of 1 (latest)

ivory iris
#

How do I prompt for specific format of output (e.g. "Give me a list of state capitals, in python list format."). Do I need to parse or convert the response to assign it as list or dict? What's best practice to prompt and use a Completion endpoint answer in code? (Currently using davinci-003.)

topaz swan
ivory iris
#

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 ="