{# Assignement in if clause breaks test, we need to declare variables in global scope first: https://github.com/pallets/jinja/issues/1314 #} {% set selected_question = "" %} {% set selected_answer = "" %} {% set random_question_id = -1 %} {% if annotations.type[0] == "multipleQAs" %} {% set random_question_id = range(0, annotations.qaPairs[0].question | length) | choice%} {% set selected_question = annotations.qaPairs[0].question[random_question_id]%} {% set selected_answer = annotations.qaPairs[0].answer[random_question_id] | choice%} {% else %} {% set selected_question = question %} {% set selected_answer = annotations.answer[0] | choice %} {% endif %} Here's a question-answer pair: {{question}} {{selected_answer}}. Is the question ambiguous? If so, generate a better question suitable for the answer. Otherwise, output the same question.
Pensando...
