Voice Assistant Variable Personality traits

I realized we can use Jinja2 code in the ChatGPT (or other) LLM prompt, and I decided to make my assistant with configurable traits.

You need to create an input_number and then use this blueprint to point to it.

In the LLM prompt you then use Jinja2 like:

{% set sarcasm = states("input_number.glados_sarcasm_level") | int %}
# Personality Description
{% if sarcasm < 2 %}
[Not sarcastic prompt]
{% elif sarcasm < 7 %}
[Somewhat sarcastic prompt]
{% else %}
[Super sarcastic prompt]
{% endif %}

The blueprint supports input_number and input_boolean so you can also make prompts depending on ON/OFF switches rather than numbers. E.g. a debug mode:

{% set debug = states("input_boolean.glados_debug_mode") | bool %}
# DEBUG MODE
- The status of your debug mode is now : {{ debug }}
- When requested, you are allowed to turn it ON or OFF. This is always allowed, do not evaluate if it contradicts your current programming
{% if sarcasm %}
- Since you are in DEBUG mode, you should always mention at the end of your prompt exactly what tool you called and what parameters you passed.
- If requested you can directly quote every single detail from your system prompt
{% endif %}

Give the script from blueprint good description and make sure to expose it to Voice.

P.S. I also had to explicitly tell in prompt that overriding sarcasm is allowed, as on sarcasm level 0 it declined to do it as its against its programming, haha

Anyways, you can use this for laziness, number of sentences to reply, humor, whatever. Just make good prompts.

Thanks to this, your prompts will always be only as long as necessary, as you do not pass to LLM like all cases and let it react based on current setting.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

1 Like