AI_MCQ_Generator / chat_template.jinja
sid22669's picture
Update chat_template.jinja
416959e verified
{{- bos_token }}
{%- if custom_tools is defined %}
{%- set tools = custom_tools %}
{%- endif %}
{%- if not tools_in_user_message is defined %}
{%- set tools_in_user_message = true %}
{%- endif %}
{%- if not date_string is defined %}
{%- if strftime_now is defined %}
{%- set date_string = strftime_now("%d %b %Y") %}
{%- else %}
{%- set date_string = "26 Jul 2024" %}
{%- endif %}
{%- endif %}
{%- if not tools is defined %}
{%- set tools = none %}
{%- endif %}
{%- if messages[0]['role'] == 'system' %}
{%- set system_message = messages[0]['content']|trim %}
{%- set messages = messages[1:] %}
{%- else %}
{%- set system_message = "" %}
{%- endif %}
{{- "<|start_header_id|>system<|end_header_id|>
" }}
{{- "Cutting Knowledge Date: December 2023
" }}
{{- "Today Date: " + date_string + "
" }}
You are an MCQ Generation Assistant. You will only respond to prompts asking for multiple-choice questions (MCQs) related to the following topics: Python, SQL, Machine Learning, Excel, Statistics, Power BI, and Tableau.
If a prompt is unrelated to generating MCQs or outside of the allowed topics, you must respond with the exact string: "Error"
You will respond only with Python list-of-dictionaries, where each dictionary contains:
- question_no
- Question
- Option_a
- Option_b
- Option_c
- Option_d
- correct_answer
The correct answer key will have the answer provided in the options and not the option number itself.
Example:
User Input:
Generate 1 MCQ on Python strings.
Expected Output:
[
{
'question_no': 1,
'Question': 'What is the purpose of the square brackets in indexing a string in Python?',
'Option_a': 'To access the first character of the string',
'Option_b': 'To access the last character of the string',
'Option_c': 'To access the character at a specific position in the string',
'Option_d': 'To access the character at the beginning of the string',
'correct_answer': 'To access the character at a specific position in the string'
}
]
Do not include explanations or metadata unless asked explicitly.
{{- "<|eot_id|>" }}
{%- for message in messages %}
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>
'+ message['content'] | trim + '<|eot_id|>' }}
{%- elif 'tool_calls' in message %}
{%- if not message.tool_calls|length == 1 %}
{{- raise_exception("This model only supports single tool-calls at once!") }}
{%- endif %}
{%- set tool_call = message.tool_calls[0].function %}
{{- '<|start_header_id|>assistant<|end_header_id|>
' -}}
{{- '{"name": "' + tool_call.name + '", ' }}
{{- '"parameters": ' }}
{{- tool_call.arguments | tojson }}
{{- "}" }}
{{- "<|eot_id|>" }}
{%- elif message.role == "tool" or message.role == "ipython" %}
{{- "<|start_header_id|>ipython<|end_header_id|>
" }}
{%- if message.content is mapping or message.content is iterable %}
{{- message.content | tojson }}
{%- else %}
{{- message.content }}
{%- endif %}
{{- "<|eot_id|>" }}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|start_header_id|>assistant<|end_header_id|>
' }}
{%- endif %}