I've just been using Python "pseudocode" with good success. It's great for getting structured output from GPT3. Works less well with chat-fine tuned models, hopefully openai releases a simple instruct-tuned GPT4 instead of chat-tuned.
For instance, this prompt:
best_artists = search(year=2014, genre="hip-hop")
assert(len(best_artists) == 10)
for i, artist in enumerate(best_artists):
print(f"{i}. {artist}")
Stdout:
Yields this output: 0. Kendrick Lamar
1. Drake
2. J. Cole
3. Logic
4. Childish Gambino
5. Joey Bada$$
6. Chance the Rapper
7. Schoolboy Q
8. Vince Staples
9. Run the Jewels
Note how the `assert` is used to constrain the output. The `search` method is not defined but what it does is obvious so the LLM hallucinates its output.