From c77d4bf74dd994bf382b76c16d688998cba4b8f5 Mon Sep 17 00:00:00 2001 From: Jeffrey Fong Date: Thu, 19 Sep 2024 14:39:49 +0000 Subject: [PATCH 1/5] fix v2 null and empty assistant content --- .../prompt_template/jinja_templates/v2.txt | 27 +++++++++++-------- tests/test_case.json | 14 ++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/functionary/prompt_template/jinja_templates/v2.txt b/functionary/prompt_template/jinja_templates/v2.txt index ff7dc86..c2c8712 100644 --- a/functionary/prompt_template/jinja_templates/v2.txt +++ b/functionary/prompt_template/jinja_templates/v2.txt @@ -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 %} \ No newline at end of file +{% if add_generation_prompt %}{{- '\n<|from|>assistant\n<|recipient|>' -}}{% endif %} \ No newline at end of file diff --git a/tests/test_case.json b/tests/test_case.json index aff6fa4..3a6d4f9 100644 --- a/tests/test_case.json +++ b/tests/test_case.json @@ -160,6 +160,20 @@ { "role": "assistant", "content": "The final list is: 0,1,2,3,5" + }, + { + "role": "assistant", + "content": "", + "metadata": { + "masked": true + } + }, + { + "role": "assistant", + "content": null, + "metadata": { + "masked": true + } } ] } From de7744bb202cc235855f5f8ab46ec1c80440add1 Mon Sep 17 00:00:00 2001 From: Jeffrey Fong Date: Thu, 19 Sep 2024 14:56:49 +0000 Subject: [PATCH 2/5] fix jinja for all other versions --- .../jinja_templates/v2.llama3.txt | 28 +++++++++++-------- .../jinja_templates/v3-llama3.1.txt | 14 ++++++---- .../jinja_templates/v3.llama3.txt | 26 +++++++++-------- .../jinja_templates/v3.llava_llama.txt | 12 +++++--- tests/test_case_vision.json | 14 ++++++++++ 5 files changed, 61 insertions(+), 33 deletions(-) diff --git a/functionary/prompt_template/jinja_templates/v2.llama3.txt b/functionary/prompt_template/jinja_templates/v2.llama3.txt index 4796a9a..9989755 100644 --- a/functionary/prompt_template/jinja_templates/v2.llama3.txt +++ b/functionary/prompt_template/jinja_templates/v2.llama3.txt @@ -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 %} \ No newline at end of file +{% if add_generation_prompt %}{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}{% endif %} \ No newline at end of file diff --git a/functionary/prompt_template/jinja_templates/v3-llama3.1.txt b/functionary/prompt_template/jinja_templates/v3-llama3.1.txt index 29d64a2..0f4e47e 100644 --- a/functionary/prompt_template/jinja_templates/v3-llama3.1.txt +++ b/functionary/prompt_template/jinja_templates/v3-llama3.1.txt @@ -19,9 +19,9 @@ {{- "\nYou have access to the following functions:\n\n" }} {%- for t in tools %} {%- if "type" in t -%} - {{ "Use the function '"|safe + t["function"]["name"] + "' to '"|safe + t["function"]["description"] + "'\n"|safe + t["function"] | tojson() }} + {{ "Use the function '"|safe + t["function"]["name"] + "' to '"|safe + t["function"]["description"] + "'\n"|safe + t["function"] | tojson() | safe }} {%- else -%} - {{ "Use the function '"|safe + t["name"] + "' to '"|safe + t["description"] + "'\n"|safe + t | tojson() }} + {{ "Use the function '"|safe + t["name"] + "' to '"|safe + t["description"] + "'\n"|safe + t | tojson() | safe }} {%- endif -%} {{- "\n\n" }} {%- endfor %} @@ -35,11 +35,13 @@ {%- elif message['role'] == 'tool' -%} {{ '<|start_header_id|>ipython<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' }} {%- else -%} - {{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'}} - {%- if 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 message['content'] and message['content']|length > 0 -%} {{ message['content'] }} {%- 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'] -%} {%- if tool_call["function"]["name"] == "python" -%} {{ '<|python_tag|>' + tool_call['function']['arguments'] }} @@ -48,7 +50,7 @@ {%- endif -%} {%- endfor -%} {{ '<|eom_id|>' }} - {%- else -%} + {%- elif message['content'] and message['content']|length > 0 -%} {{ '<|eot_id|>' }} {%- endif -%} {%- endif -%} diff --git a/functionary/prompt_template/jinja_templates/v3.llama3.txt b/functionary/prompt_template/jinja_templates/v3.llama3.txt index 5a1d8a5..aad78b2 100644 --- a/functionary/prompt_template/jinja_templates/v3.llama3.txt +++ b/functionary/prompt_template/jinja_templates/v3.llama3.txt @@ -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 %} \ No newline at end of file +{% if add_generation_prompt %}{{- '<|start_header_id|>assistant<|end_header_id|>\n\n>>>' -}}{% endif %} \ No newline at end of file diff --git a/functionary/prompt_template/jinja_templates/v3.llava_llama.txt b/functionary/prompt_template/jinja_templates/v3.llava_llama.txt index c3abf5a..4402341 100644 --- a/functionary/prompt_template/jinja_templates/v3.llava_llama.txt +++ b/functionary/prompt_template/jinja_templates/v3.llava_llama.txt @@ -25,16 +25,20 @@ {%- elif message['role'] == 'tool' -%} {{ '<|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'] -%} + {%- 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 message['content'] and message['content']|length > 0 -%} {{ '>>>all\n' + message['content'] }} {%- 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'] -%} {{ '>>>' + 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 %} \ No newline at end of file diff --git a/tests/test_case_vision.json b/tests/test_case_vision.json index d858d88..7743c00 100644 --- a/tests/test_case_vision.json +++ b/tests/test_case_vision.json @@ -167,6 +167,20 @@ { "role": "assistant", "content": "The final list is: 0,1,2,3,5" + }, + { + "role": "assistant", + "content": "", + "metadata": { + "masked": true + } + }, + { + "role": "assistant", + "content": null, + "metadata": { + "masked": true + } } ] } From b083f455cf58b88571972022e6cf44a8f8fcb433 Mon Sep 17 00:00:00 2001 From: jeffreymeetkai <104876655+jeffreymeetkai@users.noreply.github.com> Date: Thu, 19 Sep 2024 23:05:42 +0800 Subject: [PATCH 3/5] Update test_case.json --- tests/test_case.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/test_case.json b/tests/test_case.json index 3a6d4f9..1f24c3c 100644 --- a/tests/test_case.json +++ b/tests/test_case.json @@ -167,13 +167,6 @@ "metadata": { "masked": true } - }, - { - "role": "assistant", - "content": null, - "metadata": { - "masked": true - } } ] } From 5786bb439f219d658c3e37b016a4179a9210a251 Mon Sep 17 00:00:00 2001 From: Jeffrey Fong Date: Fri, 20 Sep 2024 05:21:10 +0000 Subject: [PATCH 4/5] readjust test cases --- tests/prompt_test_v2.llama3.txt | 12 +++++++++++- tests/prompt_test_v2.txt | 14 +++++++++++++- tests/prompt_test_v3-llama3.1.txt | 10 +++++++++- tests/prompt_test_v3.llama3.txt | 12 +++++++++++- tests/prompt_test_v3.llava_llama.txt | 12 +++++++++++- tests/test_case.json | 24 +++++++++++++++++++++--- tests/test_case_vision.json | 25 ++++++++++++++++++------- 7 files changed, 94 insertions(+), 15 deletions(-) diff --git a/tests/prompt_test_v2.llama3.txt b/tests/prompt_test_v2.llama3.txt index 2d4948f..2f6f2a2 100644 --- a/tests/prompt_test_v2.llama3.txt +++ b/tests/prompt_test_v2.llama3.txt @@ -64,4 +64,14 @@ l<|eot_id|><|start_header_id|>tool<|end_header_id|> name=python [0,1,2,3,5,]<|eot_id|><|start_header_id|>assistant<|end_header_id|> -The final list is: 0,1,2,3,5<|eot_id|> \ No newline at end of file +The final list is: 0,1,2,3,5<|eot_id|><|start_header_id|>user<|end_header_id|> + +Thanks! What is the weather in San Francisco?<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +<|reserved_special_token_249|>get_weather +{"location": "San Francisco, CA"}<|eot_id|><|start_header_id|>tool<|end_header_id|> + +name=get_weather +{"result": {"temperature": 20}}<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +The temperature in San Francisco is: 20 degree Celcious<|eot_id|> \ No newline at end of file diff --git a/tests/prompt_test_v2.txt b/tests/prompt_test_v2.txt index faf07f3..54a75dd 100644 --- a/tests/prompt_test_v2.txt +++ b/tests/prompt_test_v2.txt @@ -84,4 +84,16 @@ l<|stop|> <|content|>[0,1,2,3,5,] <|from|>assistant <|recipient|>all -<|content|>The final list is: 0,1,2,3,5<|stop|> \ No newline at end of file +<|content|>The final list is: 0,1,2,3,5<|stop|> +<|from|>user +<|recipient|>all +<|content|>Thanks! What is the weather in San Francisco? +<|from|>assistant +<|recipient|>get_weather +<|content|>{"location": "San Francisco, CA"}<|stop|> +<|from|>get_weather +<|recipient|>all +<|content|>{"result": {"temperature": 20}} +<|from|>assistant +<|recipient|>all +<|content|>The temperature in San Francisco is: 20 degree Celcious<|stop|> \ No newline at end of file diff --git a/tests/prompt_test_v3-llama3.1.txt b/tests/prompt_test_v3-llama3.1.txt index a576c2f..43d768a 100644 --- a/tests/prompt_test_v3-llama3.1.txt +++ b/tests/prompt_test_v3-llama3.1.txt @@ -70,4 +70,12 @@ l<|eom_id|><|start_header_id|>ipython<|end_header_id|> [0,1,2,3,5,]<|eot_id|><|start_header_id|>assistant<|end_header_id|> -The final list is: 0,1,2,3,5<|eot_id|> \ No newline at end of file +The final list is: 0,1,2,3,5<|eot_id|><|start_header_id|>user<|end_header_id|> + +Thanks! What is the weather in San Francisco?<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +{"location": "San Francisco, CA"}<|eom_id|><|start_header_id|>ipython<|end_header_id|> + +{"result": {"temperature": 20}}<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +The temperature in San Francisco is: 20 degree Celcious<|eot_id|> \ No newline at end of file diff --git a/tests/prompt_test_v3.llama3.txt b/tests/prompt_test_v3.llama3.txt index 476f4fd..eacef49 100644 --- a/tests/prompt_test_v3.llama3.txt +++ b/tests/prompt_test_v3.llama3.txt @@ -74,4 +74,14 @@ l<|eot_id|><|start_header_id|>tool<|end_header_id|> [0,1,2,3,5,]<|eot_id|><|start_header_id|>assistant<|end_header_id|> >>>all -The final list is: 0,1,2,3,5<|eot_id|> \ No newline at end of file +The final list is: 0,1,2,3,5<|eot_id|><|start_header_id|>user<|end_header_id|> + +Thanks! What is the weather in San Francisco?<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +>>>get_weather +{"location": "San Francisco, CA"}<|eot_id|><|start_header_id|>tool<|end_header_id|> + +{"result": {"temperature": 20}}<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +>>>all +The temperature in San Francisco is: 20 degree Celcious<|eot_id|> \ No newline at end of file diff --git a/tests/prompt_test_v3.llava_llama.txt b/tests/prompt_test_v3.llava_llama.txt index 54b85ce..7e3c067 100644 --- a/tests/prompt_test_v3.llava_llama.txt +++ b/tests/prompt_test_v3.llava_llama.txt @@ -74,4 +74,14 @@ l<|eot_id|><|start_header_id|>tool<|end_header_id|> [0,1,2,3,5,]<|eot_id|><|start_header_id|>assistant<|end_header_id|> >>>all -The final list is: 0,1,2,3,5<|eot_id|> \ No newline at end of file +The final list is: 0,1,2,3,5<|eot_id|><|start_header_id|>user<|end_header_id|> + +Thanks! What is the weather in San Francisco?<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +>>>get_weather +{"location": "San Francisco, CA"}<|eot_id|><|start_header_id|>tool<|end_header_id|> + +{"result": {"temperature": 20}}<|eot_id|><|start_header_id|>assistant<|end_header_id|> + +>>>all +The temperature in San Francisco is: 20 degree Celcious<|eot_id|> \ No newline at end of file diff --git a/tests/test_case.json b/tests/test_case.json index 1f24c3c..97aba6f 100644 --- a/tests/test_case.json +++ b/tests/test_case.json @@ -161,12 +161,30 @@ "role": "assistant", "content": "The final list is: 0,1,2,3,5" }, + { + "role": "user", + "content": "Thanks! What is the weather in San Francisco?" + }, { "role": "assistant", "content": "", - "metadata": { - "masked": true - } + "tool_calls": [ + { + "function": { + "name": "get_weather", + "arguments": "{\"location\": \"San Francisco, CA\"}" + } + } + ] + }, + { + "role": "tool", + "content": "{\"result\": {\"temperature\": 20}}", + "name": "get_weather" + }, + { + "role": "assistant", + "content": "The temperature in San Francisco is: 20 degree Celcious" } ] } diff --git a/tests/test_case_vision.json b/tests/test_case_vision.json index 7743c00..2a35200 100644 --- a/tests/test_case_vision.json +++ b/tests/test_case_vision.json @@ -168,19 +168,30 @@ "role": "assistant", "content": "The final list is: 0,1,2,3,5" }, + { + "role": "user", + "content": "Thanks! What is the weather in San Francisco?" + }, { "role": "assistant", "content": "", - "metadata": { - "masked": true - } + "tool_calls": [ + { + "function": { + "name": "get_weather", + "arguments": "{\"location\": \"San Francisco, CA\"}" + } + } + ] + }, + { + "role": "tool", + "content": "{\"result\": {\"temperature\": 20}}", + "name": "get_weather" }, { "role": "assistant", - "content": null, - "metadata": { - "masked": true - } + "content": "The temperature in San Francisco is: 20 degree Celcious" } ] } From 0c694f138c93f4feb01ef413bc32853275738f7e Mon Sep 17 00:00:00 2001 From: jeffreymeetkai <104876655+jeffreymeetkai@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:29:24 +0800 Subject: [PATCH 5/5] Update test_prompt_creation.py --- tests/test_prompt_creation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_prompt_creation.py b/tests/test_prompt_creation.py index f741982..31cfb7d 100644 --- a/tests/test_prompt_creation.py +++ b/tests/test_prompt_creation.py @@ -102,6 +102,7 @@ def test_final_prompt_generation(self): test_case["messages"], tools_or_functions ) print(created_prompt) + self.assertEqual( final_prompt.strip(), created_prompt.strip(),