You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
23
+
{%- endif -%}
24
+
{%- endfor -%}
25
+
26
+
{#- Main loop over all messages in the conversation history -#}
27
+
{%- formessageinloop_messages -%}
28
+
{#- Normalize roles for model prompt formatting -#}
29
+
{%- if (message['role'] == 'assistant') -%}
30
+
{%- setrole = "model" -%}
31
+
{%- elif (message['role'] == 'tool') -%}
32
+
{%- setrole = "user" -%}
33
+
{%- else -%}
34
+
{%- setrole = message['role'] -%}
35
+
{%- endif -%}
36
+
{#- Mark the start of a message block with the appropriate role -#}
37
+
{{ '<start_of_turn>' + role + '\n' -}}
38
+
39
+
{#- Insert system message content (if present) at the beginning of the first message. -#}
40
+
{%- ifloop.first -%}
41
+
{{ first_user_prefix }}
42
+
{#- Append system message with tool information if using tools in message request. -#}
43
+
{%- iftoolsisnotnone -%}
44
+
{{- "Tools (functions) are available. If you decide to invoke one or more of the tools, you must respond with a python list of the function calls.\n" -}}
{{- "Do not use variables. DO NOT USE MARKDOWN SYNTAX. You SHOULD NOT include any other text in the response if you call a function. If none of the functions can be used, point it out. If you lack the parameters required by the function, also point it out.\n" -}}
47
+
{{- "Here is a list of functions in JSON format that you can invoke.\n" -}}
48
+
{{- tools | tojson(indent=4) -}}
49
+
{{- "\n\n" -}}
50
+
{%- endif -%}
51
+
{%- endif -%}
52
+
53
+
{#- Format model tool calls (turns where model indicates they want to call a tool) -#}
54
+
{%- if'tool_calls'inmessage -%}
55
+
{#- Opening bracket for tool call list. -#}
56
+
{{- '[' -}}
57
+
{#- For each tool call -#}
58
+
{%- fortool_callinmessage.tool_calls -%}
59
+
{#- Get tool call function. -#}
60
+
{%- iftool_call.functionisdefined -%}
61
+
{%- settool_call = tool_call.function -%}
62
+
{%- endif -%}
63
+
{#- Function name & opening parenthesis. -#}
64
+
{{- tool_call.name + '(' -}}
65
+
66
+
{#-- Handle arguments as list (positional) or dict (named) --#}
0 commit comments