Skip to content

Advanced: multiple prompts and variables

Formulaic supports chaining together multiple prompts into a sequence. Short, concise prompts are often more consistent in language models, so by chaining many small prompts together, you may get more reliable outputs.

Let’s add another prompt.

Browse to the Daily Motivator Formula. While it’s published on the Explore screen, the easiest way to find it is to click Dashboard in the navigation menu and the find it under Published Formulas.

  • Find the Daily Motivator Formula card and Click the Prompts icon.
  • You are now back to Edit Mode for the the Daily Motivator Formula.

Add more prompts

  • Click the Add prompt button. A new text input appears.
  • Enter Now translate that slogan into Spanish
  • Click Run Formula.

Screenshot: the second response translates our slogan into Spanish

Great! You can see that prompt chaining is sequential and we have 4 messages, two sent by your Formula and two responses from the language model:

  • Your Formula sends the first message to the language model asking for a motivating slogan for the desired occasion.
  • The model’s first response message is a motivating slogan
  • After receiving the response, your Formula sends the second message asking for a Spanish translation
  • The model’s second response is the Spanish translation

Remember, you may get slightly different responses when you run different models or even when you run the same model multiple times. This is normal for generative language models.

Add more variables

The second prompt we just created will always translate the output into Spanish. Now let’s add a second variable to allow translation into any language

First, we need to edit our second prompt to add a new variable reference:

  • Delete the word “Spanish” from the end of our prompt and add a placeholder for a variable named “language” enclosed in triple curly braces: {{{language}}}

Next, we need to create the new Variable that we reference in the prompt

  • Click Create Variable
  • For Name, Enter language
  • For Description: The language you want to translate into
  • For default Value, Enter French
  • Click Save to save our changes

Screenshot: we have created a second variable for language

Run your new multi-variable, multi-prompt Formula

Let’s try running it.

  • For occasion, Enter It's rainy and cold outside
  • For language, Enter Latin

creenshot: we see our new slogan in Latin!

Go create something special and share it with the community!