-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from MeetKai/fix-jinja
Fix jinja templates
- Loading branch information
Showing
13 changed files
with
169 additions
and
49 deletions.
There are no files selected for viewing
28 changes: 16 additions & 12 deletions
28
functionary/prompt_template/jinja_templates/v2.llama3.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
{# version=v2.llama3 #}{%- if not tools -%} | ||
{%- set tools = [] -%} | ||
{%- endif -%} | ||
{{ bos_token + '<|start_header_id|>system<|end_header_id|>\n\n' + generate_schema_from_functions(tools) + '<|eot_id|>' -}} | ||
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n\n' + generate_schema_from_functions(tools) + '<|eot_id|>' -}} | ||
{%- if tools|length > 0 and tools|selectattr("type", "equalto", "code_interpreter")|list|length > 0 -%} | ||
{{ '<|start_header_id|>system<|end_header_id|>\n\nWhen you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at \'/mnt/data\' can be used to save and persist user files.<|eot_id|>' }} | ||
{{- '<|start_header_id|>system<|end_header_id|>\n\nWhen you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at \'/mnt/data\' can be used to save and persist user files.<|eot_id|>' -}} | ||
{%- else -%} | ||
{{ "<|start_header_id|>system<|end_header_id|>\n\nA chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. The assistant calls functions with appropriate input when necessary<|eot_id|>" }} | ||
{{- "<|start_header_id|>system<|end_header_id|>\n\nA chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. The assistant calls functions with appropriate input when necessary<|eot_id|>" -}} | ||
{%- endif -%} | ||
{%- for message in messages -%} | ||
{%- if message['role'] == 'user' or message['role'] == 'system' -%} | ||
{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' }} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' -}} | ||
{%- elif message['role'] == 'tool' -%} | ||
{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + 'name=' + message['name'] + '\n' + message['content'] + '<|eot_id|>' }} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + 'name=' + message['name'] + '\n' + message['content'] + '<|eot_id|>' -}} | ||
{%- else -%} | ||
{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'}} | ||
{%- if message['content'] -%} | ||
{{ message['content'] }} | ||
{%- if (message['content'] and message['content']|length > 0) or ('tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0) -%} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'-}} | ||
{%- endif -%} | ||
{%- if 'tool_calls' in message and message['tool_calls'] -%} | ||
{%- if message['content'] and message['content']|length > 0 -%} | ||
{{- message['content'] -}} | ||
{%- endif -%} | ||
{%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0 -%} | ||
{%- for tool_call in message['tool_calls'] -%} | ||
{{ '<|reserved_special_token_249|>' + tool_call['function']['name'] + '\n' + tool_call['function']['arguments'] }} | ||
{{- '<|reserved_special_token_249|>' + tool_call['function']['name'] + '\n' + tool_call['function']['arguments'] -}} | ||
{%- endfor -%} | ||
{%- endif -%} | ||
{{ '<|eot_id|>' }} | ||
{%- if (message['content'] and message['content']|length > 0) or ('tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0) -%} | ||
{{- '<|eot_id|>' -}} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}{% endif %} | ||
{% if add_generation_prompt %}{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
{# version=v2 #}{%- if not tools -%} | ||
{%- set tools = [] -%} | ||
{%- endif -%} | ||
{{ bos_token + '<|from|>system\n<|recipient|>all\n<|content|>' + generate_schema_from_functions(tools) -}} | ||
{{- bos_token + '<|from|>system\n<|recipient|>all\n<|content|>' + generate_schema_from_functions(tools) -}} | ||
{%- if tools|length > 0 and tools|selectattr("type", "equalto", "code_interpreter")|list|length > 0 -%} | ||
{{ '\n<|from|>system\n<|recipient|>all\n<|content|>When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at \'/mnt/data\' can be used to save and persist user files.' }} | ||
{{- '\n<|from|>system\n<|recipient|>all\n<|content|>When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at \'/mnt/data\' can be used to save and persist user files.' -}} | ||
{%- else -%} | ||
{{ "\n<|from|>system\n<|recipient|>all\n<|content|>A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. The assistant calls functions with appropriate input when necessary" }} | ||
{{- "\n<|from|>system\n<|recipient|>all\n<|content|>A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. The assistant calls functions with appropriate input when necessary" -}} | ||
{%- endif -%} | ||
{%- for message in messages -%} | ||
{%- if message['role'] == 'user' or message['role'] == 'system' -%} | ||
{{ '\n<|from|>' + message['role'] + '\n<|recipient|>all\n<|content|>' + message['content'] }} | ||
{{- '\n<|from|>' + message['role'] + '\n<|recipient|>all\n<|content|>' + message['content'] -}} | ||
{%- elif message['role'] == 'tool' -%} | ||
{{ '\n<|from|>' + message['name'] + '\n<|recipient|>all\n<|content|>' + message['content'] }} | ||
{{- '\n<|from|>' + message['name'] + '\n<|recipient|>all\n<|content|>' + message['content'] -}} | ||
{%- else -%} | ||
{%- if message['content'] -%} | ||
{{ "\n<|from|>" + message['role'] + "\n<|recipient|>all\n<|content|>" + message['content'] }} | ||
{% set print_stop = false %} | ||
{%- if message['content'] and message['content']|length > 0 -%} | ||
{{- "\n<|from|>" + message['role'] + "\n<|recipient|>all\n<|content|>" + message['content'] -}} | ||
{% set print_stop = true %} | ||
{%- endif -%} | ||
{%- if 'tool_calls' in message and message['tool_calls'] -%} | ||
{%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0 -%} | ||
{%- for tool_call in message['tool_calls'] -%} | ||
{{ '\n<|from|>' + message['role'] + '\n<|recipient|>' + tool_call['function']['name'] + '\n<|content|>' + tool_call['function']['arguments'] }} | ||
{{- '\n<|from|>' + message['role'] + '\n<|recipient|>' + tool_call['function']['name'] + '\n<|content|>' + tool_call['function']['arguments'] -}} | ||
{%- endfor -%} | ||
{% set print_stop = true %} | ||
{%- endif -%} | ||
{%- if print_stop -%} | ||
{{- "<|stop|>" -}} | ||
{%- endif -%} | ||
{{ "<|stop|>" }} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
{% if add_generation_prompt %}{{ '\n<|from|>assistant\n<|recipient|>' }}{% endif %} | ||
{% if add_generation_prompt %}{{- '\n<|from|>assistant\n<|recipient|>' -}}{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 15 additions & 11 deletions
26
functionary/prompt_template/jinja_templates/v3.llama3.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
{# version=v3.llama3 #}{%- if not tools -%} | ||
{%- set tools = [] -%} | ||
{%- endif -%} | ||
{{ bos_token + '<|start_header_id|>system<|end_header_id|>\n\nYou are capable of executing available function(s) if required.\nOnly execute function(s) when absolutely necessary.\nAsk for the required input to:recipient==all\nUse JSON for function arguments.\nRespond in this format:\n>>>${recipient}\n${content}\nAvailable functions:\n' + generate_schema_from_functions(tools) + '<|eot_id|>' -}} | ||
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n\nYou are capable of executing available function(s) if required.\nOnly execute function(s) when absolutely necessary.\nAsk for the required input to:recipient==all\nUse JSON for function arguments.\nRespond in this format:\n>>>${recipient}\n${content}\nAvailable functions:\n' + generate_schema_from_functions(tools) + '<|eot_id|>' -}} | ||
{%- if tools|length > 0 and tools|selectattr("type", "equalto", "code_interpreter")|list|length > 0 -%} | ||
{{ '<|start_header_id|>system<|end_header_id|>\n\nWhen you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at \'/mnt/data\' can be used to save and persist user files.<|eot_id|>' }} | ||
{{- '<|start_header_id|>system<|end_header_id|>\n\nWhen you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at \'/mnt/data\' can be used to save and persist user files.<|eot_id|>' -}} | ||
{%- endif -%} | ||
{%- for message in messages -%} | ||
{%- if message['role'] == 'user' or message['role'] == 'system' -%} | ||
{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' }} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' -}} | ||
{%- elif message['role'] == 'tool' -%} | ||
{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' }} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' -}} | ||
{%- else -%} | ||
{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'}} | ||
{%- if message['content'] -%} | ||
{{ '>>>all\n' + message['content'] }} | ||
{%- if (message['content'] and message['content']|length > 0) or ('tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0) -%} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'-}} | ||
{%- endif -%} | ||
{%- if 'tool_calls' in message and message['tool_calls'] -%} | ||
{%- if message['content'] and message['content']|length > 0 -%} | ||
{{- '>>>all\n' + message['content'] -}} | ||
{%- endif -%} | ||
{%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0 -%} | ||
{%- for tool_call in message['tool_calls'] -%} | ||
{{ '>>>' + tool_call['function']['name'] + '\n' + tool_call['function']['arguments'] }} | ||
{{- '>>>' + tool_call['function']['name'] + '\n' + tool_call['function']['arguments'] -}} | ||
{%- endfor -%} | ||
{%- endif -%} | ||
{{ '<|eot_id|>' }} | ||
{%- if (message['content'] and message['content']|length > 0) or ('tool_calls' in message and message['tool_calls'] and message['tool_calls']|length > 0) -%} | ||
{{- '<|eot_id|>' -}} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n>>>' }}{% endif %} | ||
{% if add_generation_prompt %}{{- '<|start_header_id|>assistant<|end_header_id|>\n\n>>>' -}}{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.