{# AI Intent + AI Change Summary section — shared include for watch edit and tag/group edit. Required template context: llm_configured — bool: LLM provider is configured in settings form — the WTForms form (must have .llm_intent and .llm_change_summary fields) Optional (watch edit only): watch — the Watch object (for processor check and prefilter display) llm_group_overrides — dict returned by _resolve_llm_group_overrides(): {'llm_intent': {'value': str, 'group_name': str} | None, 'llm_change_summary': {'value': str, 'group_name': str} | None} Present only in watch edit context; absent in tag edit context. Usage in watch edit (edit.html): {% include "edit/include_llm_intent.html" %} Usage in tag edit (edit-tag.html): {% include "edit/include_llm_intent.html" %} (watch is not set → tag mode: no processor check, no examples, different description) #} {% from '_helpers.html' import render_field %} {# Processor check only applies in watch-edit context (llm_group_overrides present). #} {# In tag/group edit context the AI section is always visible. #} {% if llm_group_overrides is defined %} {% set is_text_json_diff = not watch.get('processor') or watch.get('processor') == 'text_json_diff' %} {% else %} {% set is_text_json_diff = true %} {% endif %} {% if is_text_json_diff %} {# ── Configured: show the intent + summary fields ────────────────── #} {% if llm_configured %}

✨ {{ _('AI') }}

{# — AI Change Intent — #}

{{ _('AI — Notify when…') }}

{% if watch is defined and watch %} {{ _('Describe what you care about. The AI evaluates every detected change against this and only notifies you when it matches.') }} {% else %} {{ _('Set a change intent for all watches in this tag/group. Each watch can override with its own.') }} {% endif %}

{% if watch is defined and watch and llm_group_overrides is defined and llm_group_overrides.llm_intent %} {% set intent_placeholder = _("From group '%(name)s': %(value)s", name=llm_group_overrides.llm_intent.group_name, value=llm_group_overrides.llm_intent.value) %} {% elif watch is defined and watch %} {% set intent_placeholder = _('e.g. Alert me when the price drops below $300, or a new product is launched. Ignore footer and navigation changes.') %} {% else %} {% set intent_placeholder = _('e.g. Flag price changes or new product launches across all watches in this group') %} {% endif %} {{ render_field(form.llm_intent, placeholder=intent_placeholder, rows=5, class="pure-input-1") }}
{% if watch is defined and watch %}
{{ _('Examples:') }}
{% if watch.get('llm_prefilter') %}
{{ _('AI pre-filter active: %(filter)s — narrows content scope before evaluation', filter=watch.get('llm_prefilter')|e) | safe }}
{% endif %} {% endif %}
{# — AI Change Summary — #}

{{ _('AI Change Summary') }}

{% if watch is defined and watch %} {{ _('When a change is detected, the AI describes it according to your instructions and replaces %(diff)s in your notification. Use %(raw_diff)s if you still want the original diff.', diff='{{diff}}', raw_diff='{{raw_diff}}') | safe }} {% else %} {{ _('Describe how changes should be summarised in notifications for all watches in this group.') }} {% endif %}

{% if watch is defined and watch and llm_group_overrides is defined and llm_group_overrides.llm_change_summary %} {% set summary_placeholder = _("From group '%(name)s': %(value)s", name=llm_group_overrides.llm_change_summary.group_name, value=llm_group_overrides.llm_change_summary.value) %} {% else %} {% set summary_placeholder = form.llm_change_summary.render_kw['placeholder'] %} {% endif %} {{ render_field(form.llm_change_summary, placeholder=summary_placeholder, rows=5, class="pure-input-1") }}
{{ _('Modify default prompt') }}
{% if watch is defined and watch %}
{{ _('Examples:') }}
{% endif %}
{# ── Not configured: greyed-out prompt to configure ──────────────── #} {% else %}

✨ {{ _('AI') }}

{% if watch is defined and watch %} {{ _('Configure an AI / LLM provider in Settings → AI / LLM to enable AI Change Intent and AI Change Summary.', url=url_for('settings.settings_page') + '#ai') | safe }} {% else %} {{ _('Configure an AI / LLM provider in Settings → AI / LLM to enable AI features for this group.', url=url_for('settings.settings_page') + '#ai') | safe }} {% endif %}

{% endif %} {% endif %}{# is_text_json_diff #}