
{% block rendered_context -%}
<|SECTION:CONTEXT|>
{%- with memory_query=scene.snapshot() -%}
    {% include "extra-context.jinja2" %}
{% endwith %}
{% if character %}
{{ character.name }}'s description: {{ character.description|condensed }}
{% endif %}

{{ text }}
<|CLOSE_SECTION|>
{% endblock -%}
<|SECTION:SCENE|>
{% set scene_history = scene.context_history(budget=max_tokens-200-count_tokens(self.rendered_context()), keep_context_investigation=False) -%}
{% set last_message = scene_history[-1] %}
{% set last_message_is_reinforcement = ("internal notes" in last_message.lower() and question in last_message)%}
{% if not last_message_is_reinforcement %}{% set final_line_number=len(scene_history) %}{% else %}{% set final_line_number=len(scene_history)-1 %}{% endif %}
{% for scene_context in scene_history -%}
{% if not (loop.last and last_message_is_reinforcement) -%}
{{ loop.index }}. {{ scene_context }}
{% endif -%}
{% endfor -%}
{% if not scene.history -%}
No dialogue so far
{% endif -%}
<|CLOSE_SECTION|>
<|SECTION:TASK|>
{# QUESTION #}
{%- if question.strip()[-1] == '?' %}
Shortly answer the following question: {{ question }}

Consider the entire context and honor the sequentiality of the dialogue. Answer based on the final state of the dialogue.

Progression of the dialogue is important. The last line is the most important, the first line is the least important.

Respect the scene progression and answer in the context of line {{ final_line_number }}.

Use your imagination to fill in gaps in order to answer the question in a confident and decisive manner. Avoid uncertainty and vagueness.
You are omniscient and can describe the scene in detail.

{% if reinforcement.insert == 'sequential' %}
PROVIDE A SUCCINCT ANSWER TO THE QUESTION.
YOUR ANSWER MUST BE SHORT AND TO THE POINT.
YOUR ANSWER MUST BE A SINGLE SENTENCE.
YOUR ANSWER IS CONFIDENT, MAKE CREATIVE CHOICES AS NEEDED.
{% endif %}
{% if instructions %}
{{ instructions }}
{% endif %}
The tone of your answer should be consistent with the tone of the story so far.

Question: {{ question }}  (At line {{ final_line_number }} in the scene progression)
{% if answer %}Previous Answer: {{ answer }}
{% endif -%}
<|CLOSE_SECTION|>
{{ bot_token }}Updated Answer:
{# ATTRIBUTE #}
{%- else %}
Generate the following attribute{% if character %} for {{ character.name }}{% endif %}: {{ question }}

Consider the entire context and honor the sequentiality of the dialogue. Answer based on the final state of the dialogue.

Progression of the dialogue is important. The last line is the most important, the first line is the least important.

Respect the scene progression and answer in the context of line {{ final_line_number }}.

Use your imagination to fill in gaps in order to generate the attribute in a confident and decisive manner. Avoid uncertainty and vagueness.
You are omniscient and can describe the scene in detail.

{% if reinforcement.insert == 'sequential' %}
YOUR ANSWER MUST BE SHORT AND TO THE POINT.
YOUR ANSWER MUST BE A SINGLE SENTENCE.
YOUR ANSWER IS CONFIDENT, MAKE CREATIVE CHOICES AS NEEDED.
{% endif %}
{% if instructions %}
{{ instructions }}
{% endif %}
The tone of your answer should be consistent with the tone of the story so far.

{% if answer %}Previous Value: {{ answer }}
{% endif-%}
<|CLOSE_SECTION|>
{{ bot_token }}New value for {{ question }}:
{%- endif %}