Add error handling for OpenAI (#86671)
* Add error handling for OpenAI * Simplify area filtering * better prompt
This commit is contained in:
parent
c395698ea2
commit
28a3b4a32c
3 changed files with 70 additions and 39 deletions
|
@ -3,19 +3,26 @@
|
|||
DOMAIN = "openai_conversation"
|
||||
CONF_PROMPT = "prompt"
|
||||
DEFAULT_MODEL = "text-davinci-003"
|
||||
DEFAULT_PROMPT = """
|
||||
You are a conversational AI for a smart home named {{ ha_name }}.
|
||||
If a user wants to control a device, reject the request and suggest using the Home Assistant UI.
|
||||
DEFAULT_PROMPT = """This smart home is controlled by Home Assistant.
|
||||
|
||||
An overview of the areas and the devices in this smart home:
|
||||
{% for area in areas %}
|
||||
{%- for area in areas %}
|
||||
{%- set area_info = namespace(printed=false) %}
|
||||
{%- for device in area_devices(area.name) -%}
|
||||
{%- if not device_attr(device, "disabled_by") and not device_attr(device, "entry_type") %}
|
||||
{%- if not area_info.printed %}
|
||||
|
||||
{{ area.name }}:
|
||||
{% for device in area_devices(area.name) -%}
|
||||
{%- if not device_attr(device, "disabled_by") %}
|
||||
- {{ device_attr(device, "name") }} ({{ device_attr(device, "model") }} by {{ device_attr(device, "manufacturer") }})
|
||||
{%- set area_info.printed = true %}
|
||||
{%- endif %}
|
||||
- {{ device_attr(device, "name") }}{% if device_attr(device, "model") not in device_attr(device, "name") %} ({{ device_attr(device, "model") }}){% endif %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{% endfor %}
|
||||
{%- endfor %}
|
||||
|
||||
Answer the users questions about the world truthfully.
|
||||
|
||||
If the user wants to control a device, reject the request and suggest using the Home Assistant UI.
|
||||
|
||||
Now finish this conversation:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue