Skip to content

Instantly share code, notes, and snippets.

@spech66
Last active April 6, 2023 05:30
Show Gist options
  • Save spech66/8a44110ef0b3ab620f3188ccd9e678dd to your computer and use it in GitHub Desktop.
Save spech66/8a44110ef0b3ab620f3188ccd9e678dd to your computer and use it in GitHub Desktop.
Let OpenAI chatgpt-4 output data in JSON and CSV format

ChatGPT allows specifying output formats like JSON or CSV. Test at the OpenAI Playground.

JSON

USER

Classify the following items as fruit or vegetable: apple, banana, cucumber.
Output the data as JSON in the format [{"name": "Apple", "type": "Fruit/Vegetable"}]

ASSISTANT

[{"name": "Apple", "type": "Fruit"}, {"name": "Banana", "type": "Fruit"}, {"name": "Cucumber", "type": "Vegetable"}]

CSV

USER

Classify the following items as fruit or vegetable: apple, banana, cucumber. Output the data as CSV in the format "name", "type"

ASSISTANT

"apple", "fruit"
"banana", "fruit"
"cucumber", "vegetable"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment