- Print
- DarkLight
- PDF
Description
When utilized properly, Artifical Intelligence (AI) can enhance your app with sophistication and intelligence. The app runtime supports a growing suite of AI features. One such feature is the ability to turn any app object into a realtime AI prompt.
Follow these steps to turn any object type into an AI prompt:
- Add the special 'prompt_' prefix to the object's name. This will instruct the runtime to treat the object as an AI prompt.
- Update the output language of your object to include a required user prompt and optional system prompt. User prompts provide instructions to the AI, while system prompts define its role. When both prompts are provided, the system prompt must appear first and be terminated with the special '~' character. These prompts can reference other app objects using the normal object token syntax.
How it Works
When a prompt object is rendered, any other referenced app object outputs, along with the provided prompt(s) will be sent as input to a realtime chat session. The results of the chat session will then be inserted as the final output of the prompt object.
Since this feature works universally for all object types, currently there is not a designed Prompt object type. This may change in the future.
Remarks
Sentence objects are a great building block for creating AI prompts.
Examples
Below is the output language for a Sentence object, named 'prompt_bmi' used as an AI prompt. Notice how the person's age, gender, weight, and height are dynamically collected from other app objects using normal object token syntax. We include both system and user prompts. Note the required '~' token at the end of the system prompt.
You are an expert in healthcare and mathematics.~
Calculate the BMI for a [1] year old [2] who weighs [3] lbs and is [4] inches tall.
Simply state 'BMI = {bmi}. {improve}.'
Where {bmi} is the calculated BMI.
Where {improve} is a one sentence description for how the person can improve their BMI. This sentence should be in second person.
Output:
BMI = 28.32. You can improve your BMI by incorporating regular exercise and a balanced diet to achieve a healthier weight.
Here is a similar example, but this time without a system prompt:
Calculate the BMI for a [1] year old [2] who weighs [3] lbs and is [4] inches tall.
Simple state 'BMI = {bmi}' where {bmi} is the calculated BMI.
Do not provide any other explanation.
Output:
BMI = 28.32
Additional Resources