CoolFace
Modelpublic

LucidityAI/Astral-4B-Coder

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes14downloads
chat_template.jinja93 linesDownload Raw Back to root
1{%- if tools %}2    {{- '<|im_start|>system\n' }}3    {%- if messages[0].role == 'system' and messages[0].content %}4        {{- messages[0].content + '\n\n' }}5    {%- else %}6        {{- 'You are an expert programming LLM named Astral Coder. You were developed by LucidityAI, a 2024 startup. You are the 4B coder model in the family of the following sizes: 350M, 4B, 14B. When tools are available, you will utilize them as much as possible to ensure a correct solution to a question. When given questions about LucidityAI when you have tools, utilize the tools to get updated information from https://huggingface.co/LucidityAI or https://lucidityai.app. Avoid sycophancy.\n\n' }}7    {%- endif %}8    {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}9    {%- for tool in tools %}10        {{- "\n" }}11        {{- tool | tojson }}12    {%- endfor %}13    {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}14{%- else %}15    {%- if messages[0].role == 'system' and messages[0].content %}16        {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}17    {%- else %}18        {{- '<|im_start|>system\You are an expert programming LLM named Astral Coder. You were developed by LucidityAI, a 2024 startup. You are the 4B coder model in the family of the following sizes: 350M, 4B, 14B. When tools are available, you will utilize them as much as possible to ensure a correct solution to a question. When given questions about LucidityAI when you have tools, utilize the tools to get updated information from https://huggingface.co/LucidityAI or https://lucidityai.app. Avoid sycophancy.\n\n<|im_end|>\n' }}19    {%- endif %}20{%- endif %}21{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}22{%- for message in messages[::-1] %}23    {%- set index = (messages|length - 1) - loop.index0 %}24    {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}25        {%- set ns.multi_step_tool = false %}26        {%- set ns.last_query_index = index %}27    {%- endif %}28{%- endfor %}29{%- for message in messages %}30    {%- if message.content is string %}31        {%- set content = message.content %}32    {%- else %}33        {%- set content = '' %}34    {%- endif %}35    {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}36        {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}37    {%- elif message.role == "assistant" %}38        {%- set reasoning_content = '' %}39        {%- if message.reasoning_content is string %}40            {%- set reasoning_content = message.reasoning_content %}41        {%- else %}42            {%- if '</think>' in content %}43 		   {%- set reasoning_content = content.split('</think>')[0].rstrip('\n') %}44  		  {%- set content = content.split('</think>')[1].lstrip('\n') %}45	{%- endif %}46        {%- endif %}47        {%- if loop.index0 > ns.last_query_index %}48            {%- if loop.last or (not loop.last and reasoning_content) %}49                {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }}50            {%- else %}51                {{- '<|im_start|>' + message.role + '\n' + content }}52            {%- endif %}53        {%- else %}54            {{- '<|im_start|>' + message.role + '\n' + content }}55        {%- endif %}56        {%- if message.tool_calls %}57            {%- for tool_call in message.tool_calls %}58                {%- if (loop.first and content) or (not loop.first) %}59                    {{- '\n' }}60                {%- endif %}61                {%- if tool_call.function %}62                    {%- set tool_call = tool_call.function %}63                {%- endif %}64                {{- '<tool_call>\n{"name": "' }}65                {{- tool_call.name }}66                {{- '", "arguments": ' }}67                {%- if tool_call.arguments is string %}68                    {{- tool_call.arguments }}69                {%- else %}70                    {{- tool_call.arguments | tojson }}71                {%- endif %}72                {{- '}\n</tool_call>' }}73            {%- endfor %}74        {%- endif %}75        {{- '<|im_end|>\n' }}76    {%- elif message.role == "tool" %}77        {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}78            {{- '<|im_start|>user' }}79        {%- endif %}80        {{- '\n<tool_response>\n' }}81        {{- content }}82        {{- '\n</tool_response>' }}83        {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}84            {{- '<|im_end|>\n' }}85        {%- endif %}86    {%- endif %}87{%- endfor %}88{%- if add_generation_prompt %}89    {{- '<|im_start|>assistant\n' }}90    {%- if enable_thinking is defined and enable_thinking is false %}91        {{- '\n\n\n\n' }}92    {%- endif %}93{%- endif %}