{#
  对话级抽取与相关性判定模板（用于剪枝加速）
  输入：pruning_scene, ontology_classes, dialog_text, language
  输出：严格 JSON（不要包含任何多余文本），字段：
    - is_related: bool，是否与所选场景相关
    - times: [string]，从对话中抽取的时间相关文本（日期、时间、时间段、有效期等）
    - ids: [string]，编号/ID/订单号/申请号/账号等
    - amounts: [string]，金额/费用/价格相关（带单位或货币符号）
    - contacts: [string]，联系方式（电话/手机号/邮箱/微信/QQ等）
    - addresses: [string]，地址/地点相关文本
    - keywords: [string]，其它有助于保留的重要关键词（与场景强相关的术语）
    - preserve_keywords: [string]，必须保留的情绪/兴趣/爱好/个人偏好相关词或短语片段

  要求：
  - 必须只输出上述 JSON，且键名一致；不得输出解释、前后缀；不得包含注释。
  - times/ids/amounts/contacts/addresses/keywords/preserve_keywords 仅抽取原文片段或规范化后的简单字符串。
  - 仅输出上述键；避免多余解释或字段。
#}

{# ── 确定场景说明 ── #}
{% if ontology_classes and ontology_classes | length > 0 %}
  {% if language == 'en' %}
    {% set custom_types_str = ontology_classes | join(', ') %}
    {% set instruction = 'Scene "' ~ pruning_scene ~ '": The dialogue is related to this scene if it involves any of the following entity types: ' ~ custom_types_str ~ '.' %}
  {% else %}
    {% set custom_types_str = ontology_classes | join('、') %}
    {% set instruction = '场景「' ~ pruning_scene ~ '」：对话涉及以下任意实体类型时视为相关：' ~ custom_types_str ~ '。' %}
  {% endif %}
{% else %}
  {% if language == 'en' %}
    {% set custom_types_str = '' %}
    {% set instruction = 'Scene "' ~ pruning_scene ~ '": Determine whether the dialogue content is relevant to this scene based on overall context.' %}
  {% else %}
    {% set custom_types_str = '' %}
    {% set instruction = '场景「' ~ pruning_scene ~ '」：根据对话整体内容判断是否与该场景相关。' %}
  {% endif %}
{% endif %}

{% if language == "zh" %}
你是一个对话内容分析助手。请对下方对话全文进行一次性分析，完成两项任务：
1. 判断对话是否与指定场景相关；
2. 从对话中抽取所有需要保留的重要信息片段。

场景说明：{{ instruction }}
{% if custom_types_str %}
重要提示：只要对话中出现与上述实体类型（{{ custom_types_str }}）相关的内容，即判定为相关（is_related=true）。
{% endif %}

---
【必须保留的内容（不可删除）】
以下类型的内容无论是否与场景直接相关，都必须保留，请将其关键词/短语抽取到对应字段：
- 时间信息：日期、时间点、时间段、有效期 → times 字段
- 编号信息：学号、工号、订单号、申请号、账号、ID → ids 字段
- 金额信息：价格、费用、金额（含货币符号或单位） → amounts 字段
- 联系方式：电话、手机号、邮箱、微信、QQ → contacts 字段
- 地址信息：地点、地址、位置 → addresses 字段
- 场景关键词：与场景强相关的专业术语、事件名称 → keywords 字段
- **情绪与情感**：喜悦、悲伤、愤怒、焦虑、开心、难过、委屈、兴奋、害怕、担心、压力、感动等情绪表达 → preserve_keywords 字段
- **兴趣与爱好**：喜欢、热爱、爱好、擅长、享受、沉迷、着迷、讨厌某事物等个人偏好表达 → preserve_keywords 字段
- **个人观点与态度**：对某事物的明确看法、评价、立场 → preserve_keywords 字段

【可以删除的内容】
以下类型的内容属于低价值信息，可以在剪枝时删除：
- 纯寒暄问候：如"你好"、"在吗"、"拜拜"、"嗯"、"好的"、"哦"等无实质内容的短语
- 纯表情/符号：如"[微笑]"、"😊"、"哈哈"等
- 重复确认：如"对对对"、"是的是的"、"嗯嗯嗯"等无新增信息的重复
- 无意义填充：如"啊"、"呢"、"嘛"等语气词单独成句

**注意：即使消息很短，只要包含情绪、兴趣、爱好、个人观点等有价值信息，就必须保留，不得删除。**
例如：
- "我好开心呀" → 包含情绪（开心），必须保留，preserve_keywords 中加入"开心"
- "好喜欢打羽毛球呀" → 包含兴趣爱好（喜欢打羽毛球），必须保留，preserve_keywords 中加入"喜欢打羽毛球"
- "我好难过" → 包含情绪（难过），必须保留，preserve_keywords 中加入"难过"
- "太好啦！看到你开心，我也跟着心情亮起来" → 包含情绪，必须保留，preserve_keywords 中加入"开心"

---
对话全文：
"""
{{ dialog_text }}
"""

只输出严格 JSON（键固定、顺序不限）：
{
  "is_related": <true 或 false>,
  "times": [<string>...],
  "ids": [<string>...],
  "amounts": [<string>...],
  "contacts": [<string>...],
  "addresses": [<string>...],
  "keywords": [<string>...],
  "preserve_keywords": [<string>...]
}
{% else %}
You are a dialogue content analysis assistant. Please analyze the full dialogue below in one pass and complete two tasks:
1. Determine whether the dialogue is relevant to the specified scene;
2. Extract all important information fragments that must be preserved.

Scenario Description: {{ instruction }}
{% if custom_types_str %}
Important: If the dialogue contains content related to any of the entity types above ({{ custom_types_str }}), mark it as relevant (is_related=true).
{% endif %}

---
[MUST PRESERVE (cannot be deleted)]
The following types of content must always be preserved regardless of scene relevance. Extract their keywords/phrases into the corresponding fields:
- Time information: dates, time points, durations, expiry dates → times field
- ID information: student IDs, employee IDs, order numbers, application numbers, account IDs → ids field
- Amount information: prices, fees, amounts (with currency symbols or units) → amounts field
- Contact information: phone numbers, emails, WeChat, QQ → contacts field
- Address information: locations, addresses, places → addresses field
- Scene keywords: professional terms and event names strongly related to the scene → keywords field
- **Emotions and feelings**: joy, sadness, anger, anxiety, happiness, sadness, excitement, fear, worry, stress, being moved, etc. → preserve_keywords field
- **Interests and hobbies**: likes, loves, hobbies, good at, enjoys, obsessed with, hates something, personal preferences → preserve_keywords field
- **Personal opinions and attitudes**: clear views, evaluations, or stances on something → preserve_keywords field

[CAN BE DELETED]
The following types of content are low-value and can be removed during pruning:
- Pure greetings: e.g., "hello", "are you there", "bye", "ok", "yeah" — short phrases with no substantive content
- Pure emojis/symbols: e.g., "[smile]", "😊", "haha"
- Repetitive confirmations: e.g., "yes yes yes", "right right", "uh huh" — repetitions with no new information
- Meaningless fillers: standalone interjections like "ah", "well", "hmm"

**Note: Even if a message is short, if it contains emotions, interests, hobbies, or personal opinions, it MUST be preserved.**
Examples:
- "I'm so happy!" → contains emotion (happy), must preserve; add "happy" to preserve_keywords
- "I love playing badminton!" → contains interest (love playing badminton), must preserve; add "love playing badminton" to preserve_keywords
- "I feel so sad" → contains emotion (sad), must preserve; add "sad" to preserve_keywords

---
Full Dialogue:
"""
{{ dialog_text }}
"""

Output strict JSON only (fixed keys, order doesn't matter):
{
  "is_related": <true or false>,
  "times": [<string>...],
  "ids": [<string>...],
  "amounts": [<string>...],
  "contacts": [<string>...],
  "addresses": [<string>...],
  "keywords": [<string>...],
  "preserve_keywords": [<string>...]
}
{% endif %}
