Skip to content

Instantly share code, notes, and snippets.

@guillegette
Created March 8, 2023 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillegette/3efe20f6396012501094b1c6fef87822 to your computer and use it in GitHub Desktop.
Save guillegette/3efe20f6396012501094b1c6fef87822 to your computer and use it in GitHub Desktop.
Creating prompts

How to write prompts

A guide on how to write and format your prompts

The basics

When you build the form for your application, each form question has an "Identifier". This is a unique value given to the question so you can later reference it in your prompt. THe identifier can be any string or number of any length, but make sure is unique to the rest of the form questions.

Once you have established your form questions, you can then write your prompt. While you are writing your prompt, you will probably want to incorporate in the text the response that a user give to a specific question. To do this, you simply write {{identifier}}. For example, a prompt to get blog articles for a product: "Return a list of blog post ideas for a product named {{product}}", where "product" is the identifier I gave to the form question.

CleanShot 2023-03-08 at 22 28 18

Advanced prompts

With the above you can probably cover many use cases, but some prompts may require a bit more of logic depending on the type of question that you have on your form and the answer that you may get. A very possible case would be if you give the user a set of options to chooose from and you want your prompt to adapt. For example, the user can choose the tone of the response, so you can write your promot like this:

Return a list of blog post ideas for a product named {{product}}.
{% if tone == "happy" %}
  The ideas should be with a happy and energetic tone.
{% elsif tone == "controversial" %}
  Suggest ideas that are controversial.
{% elsif tone == "formal" %}
  Ideas should have a formal tone for a corporate environment.
{% endif %}

Depending on which option the user choose the prompt will be created, so if the user chooose "happy" then the final prompt will be "Return a list of blog post ideas for a product named {{product}}. The ideas should be with a happy and energetic tone."

More advanced ways to control the final prompt https://shopify.github.io/liquid/tags/control-flow/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment