OpenAI Alchemy: Turn a sentence into an email

In previous posts I showed how OpenAI’s API can be used to grasp the context of text to continue lists, expand dialog or summarize to different reading levels. I’d like to show one of the API’s other superpowers: Its ability to expand a small thought into a larger expression. This can be used to turn a few key facts into an email or one line of text into a passage in a story. The applications range from business writing to creative fiction.

Here’s an example of a context that will turn one sentence into an entire email using the information you provide. When I provide this to the API as an example it shows how I’d like the sentence to be expanded into an email:


Thank John for the book.

"""
 
Dear John,

Thank you so much for the book. I really appreciate it.

I hope to hang out soon.

Your friend,

Andrew

###

(I provide three more examples similar to the one above.)

When I provide it this input:


Ask Smith Co. if they have new hyperdrives in stock.

I get this response:


Dear Sir/Madam,

Do you have any new hyperdrives in stock?

Thank you.

Sincerely,

Andrew Mayne

If I ask a more informal question like this:


Ask Kathy to send me the photos from our trip to Disneyland.

I get this:


Dear Kathy,

I want to ask if you could please send me the photos from our trip to Disneyland.

I would like to see the fun we had.

Thank you so much.

Sincerely,

Andrew

That’s all it takes to build a simple app that can turn a one-sentence expression into an entire email. With a few more examples and some variables you can create even more sophisticated responses.