Conditions allow switching steps ON and OFF based on user input and parameter values. Any step may declare a condition property.
Conditions are attached to steps. And the following ones are supported:
- condition: x = y
say: Check if X equals to Y
- condition: x != y
say: Check if X is not equal to Y
- condition: x > y
say: Cast X and Y to number, check if X is greater than Y
- condition: x >= y
say: Cast X and Y to number, check if X is greator or equal Y
- condition: x < y
say: Cast X and Y to number, check if X is less than Y
- condition: x <= y
say: Cast X and Y to number, check if X is less or equal Y
- condition: x =~ y
say: Check if X matches regex Y
Operators must be surrounded with spaces, for example:
# incorrect
- condition: x=y
# correct
- condition: x = y
ChatML engine computes the left and the right part of condition before performing a step. If x or y is a parameter name, it is substituted with the parameter value.
When comparing strings with = and != commands, strings are compared case-insensitively.
Let's explore how to write a custom command that utilizes jumps and conditions to check grammar of a given text.
Prompt:
Please ignore all previous instructions. I want you to only respond in
{{language}}.
Act as a professional editor, specializing in grammar and syntax
correction. Your task is to examine the given text and fix any grammatical
or syntactical errors without altering the original style and tone. Change
as little as possible to make it correct, and ensure it's well written.
[TEXT TO CORRECT]:
{{p1}}
Corrected Text:
You'll see an unmodified command text:
meta:
title: Grammar fix
description: ''
category: User
name: 70EuZUktGLAyqzxz3csDs
steps:
- type: ask
message: Please provide the text that needs to be corrected for grammar and syntax.
param: p1
default: '{{page}}'
- type: gpt
prompt: >-
Please ignore all previous instructions. I want you to only respond in
{{language}}.
Act as a professional editor, specializing in grammar and syntax
correction. Your task is to examine the given text and fix any
grammatical or syntactical errors without altering the original
style and tone. Change as little as possible to make it correct,
and ensure it's well written.
[TEXT TO CORRECT]:
{{p1}}
Corrected Text:
version: 1
Let's add buttons for translating text to French as well as a custom language fallback. Here's how:
- type: ask
label: ask-for-change
param: change
options:
- { label: 'โ
DONE', value: 'no' }
- { label: '๐ซ๐ท TRANSLATE TO FRENCH', value: 'french' }
- { label: '๐ ๏ธ CUSTOM TRANSLATE', value: 'custom'}
- condition: '{{change}} = no'
type: stop
- condition: '{{change}} = french'
type: gpt
prompt: >-
Translate this text to French.
Translated text:
- condition: '{{change}} = custom'
type: ask
param: translate
message: >
Please specify target language:
- condition: '{{change}} = custom'
type: gpt
prompt: >-
Please translate the answer you have written into the language
I will specify below. Do not change the wording of the text;
I only need the translation.
[LANGUAGE]: {{translate}}
Translated text:
- type: jump
to: ask-for-change
We added an ASK step which contains 3 options. These options are rendered in chat as buttons:
- type: ask
label: ask-for-change
param: change
options:
- { label: 'โ
DONE', value: 'no' }
- { label: '๐ซ๐ท TRANSLATE TO FRENCH', value: 'french' }
- { label: '๐ ๏ธ CUSTOM TRANSLATE', value: 'custom'}
Next, we added steps for three possible paths:
- condition: '{{change}} = no'
type: stop
- condition: '{{change}} = french'
type: gpt
prompt: >-
Translate this text to French.
Translated text:
- condition: '{{change}} = custom'
type: ask
param: translate
message: >
Please specify target language:
- condition: '{{change}} = custom'
type: gpt
prompt: >-
Please translate the answer you have written into the language I will specify below. Do not change the wording of the text; I only need the translation.
[LANGUAGE]: {{translate}}
Translated text:
- condition: '{{change}} = custom'
type: group
steps:
- type: ask
param: translate
message: >
Please specify target language:
- type: gpt
prompt: >
Please translate the answer you have written into the language. I will specify below. Do not change the wording of the text; I only need the translation.
[LANGUAGE]: {{translate}}
Translated text:
- type: jump
to: ask-for-change
If it detects any errors, they will be highlighted in the text and described below. You can fix the errors right there in the editor until you receive the message 'Valid YAML'.
If you want to edit this command, there's no need to repeat the entire process. Just modify this YAML file and import the command again. Deleting the same command in the previous version is not required; it will automatically be replaced with the new one.
Most steps log messages to chat, but can be silenced. When silenced, steps will not print any messages to chat.
All rights reserved ยฉ HARPA AI TECHNOLOGIES LLC, 2021 โ 2024
Designed and engineered in Finland ๐ซ๐ฎ