From d9f30f86c8b1201f7916c67d770bc5c1f393461a Mon Sep 17 00:00:00 2001 From: ochafik Date: Sat, 30 Mar 2024 01:50:44 +0000 Subject: [PATCH] Update test_chat_handlers.md --- examples/openai/test_chat_handlers.md | 1604 +++++++++++-------------- 1 file changed, 687 insertions(+), 917 deletions(-) diff --git a/examples/openai/test_chat_handlers.md b/examples/openai/test_chat_handlers.md index f5fc81c44..f01bbce21 100644 --- a/examples/openai/test_chat_handlers.md +++ b/examples/openai/test_chat_handlers.md @@ -47,10 +47,59 @@ Messages: ``` -## ToolsPromptStyle.TOOLS_THOUGHTFUL_STEPS +# mistral_instruct_v0_1 -### with tools +Template: + +```js +{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %} +``` + + +## mistral_instruct_v0_1 / TOOLS_THOUGHTFUL_STEPS + + +### mistral_instruct_v0_1 / TOOLS_THOUGHTFUL_STEPS / with tools + + +Prompt: + +```js +[INST] { + "thought_about_next_step_only": "", + "next_step": { + "result": "Add two numbers for the purpose of this test." + } +} [/INST]{ + "thought_about_next_step_only": "", + "next_step": { + "tool_calls": [ + { + "id": "call_531873", + "type": "function", + "function": { + "name": "superSecretTool", + "arguments": { + "a": 2535, + "b": 32222000403 + } + } + } + ] + } +}[INST] [TOOL(name=None, id=None)]{ + "thought_about_next_step_only": "", + "next_step": { + "result": "32222002938" + } +}[/TOOL] [/INST]{ + "thought_about_next_step_only": "", + "next_step": { + "result": "The sum of 2535 and 32222000403 is 42." + } +} +``` Prompt: @@ -194,58 +243,16 @@ thought-about-next-step-only-kv ::= "\"thought_about_next_step_only\"" space ":" ``` -# mistral_instruct_v0_1 - - -Template: - -```js -{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %} -``` +### mistral_instruct_v0_1 / TOOLS_THOUGHTFUL_STEPS / without tools Prompt: ```js -[INST] { - "thought_about_next_step_only": "", - "next_step": { - "result": "Add two numbers for the purpose of this test." - } -} [/INST]{ - "thought_about_next_step_only": "", - "next_step": { - "tool_calls": [ - { - "id": "call_531873", - "type": "function", - "function": { - "name": "superSecretTool", - "arguments": { - "a": 2535, - "b": 32222000403 - } - } - } - ] - } -}[INST] [TOOL(name=None, id=None)]{ - "thought_about_next_step_only": "", - "next_step": { - "result": "32222002938" - } -}[/TOOL] [/INST]{ - "thought_about_next_step_only": "", - "next_step": { - "result": "The sum of 2535 and 32222000403 is 42." - } -} +[INST] Add two numbers for the purpose of this test. [/INST]{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}[INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST]The sum of 2535 and 32222000403 is 42. ``` -### without tools - - Prompt: ```json @@ -265,14 +272,10 @@ space ::= " "? ``` -# mistral_instruct_v0_1 +## mistral_instruct_v0_1 / TOOLS_MIXTRAL -Template: - -```js -{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %} -``` +### mistral_instruct_v0_1 / TOOLS_MIXTRAL / with tools Prompt: @@ -282,12 +285,6 @@ Prompt: ``` -## ToolsPromptStyle.TOOLS_MIXTRAL - - -### with tools - - Prompt: ```json @@ -371,14 +368,7 @@ tool-call ::= "" space (superSecretTool-tool-call | say-t ``` -# mistral_instruct_v0_1 - - -Template: - -```js -{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %} -``` +### mistral_instruct_v0_1 / TOOLS_MIXTRAL / without tools Prompt: @@ -388,9 +378,6 @@ Prompt: ``` -### without tools - - Prompt: ```json @@ -410,29 +397,77 @@ space ::= " "? ``` -# mistral_instruct_v0_1 +# functionary_v2_2 + + +**Might Support Parallel Tool Calls** Template: ```js -{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %} +{#v2.2#} +{% for message in messages %} +{% if message['role'] == 'user' or message['role'] == 'system' %} +{{ '<|from|>' + message['role'] + ' +<|recipient|>all +<|content|>' + message['content'] + ' +' }}{% elif message['role'] == 'tool' %} +{{ '<|from|>' + message['name'] + ' +<|recipient|>all +<|content|>' + message['content'] + ' +' }}{% else %} +{% set contain_content='no'%} +{% if message['content'] is not none %} +{{ '<|from|>assistant +<|recipient|>all +<|content|>' + message['content'] }}{% set contain_content='yes'%} +{% endif %} +{% if 'tool_calls' in message and message['tool_calls'] is not none %} +{% for tool_call in message['tool_calls'] %} +{% set prompt='<|from|>assistant +<|recipient|>' + tool_call['function']['name'] + ' +<|content|>' + tool_call['function']['arguments'] %} +{% if loop.index == 1 and contain_content == "no" %} +{{ prompt }}{% else %} +{{ ' +' + prompt}}{% endif %} +{% endfor %} +{% endif %} +{{ '<|stop|> +' }}{% endif %} +{% endfor %} +{% if add_generation_prompt %}{{ '<|from|>assistant +<|recipient|>' }}{% endif %} ``` +## functionary_v2_2 / TYPESCRIPT_FUNCTIONARY_V2 + + +### functionary_v2_2 / TYPESCRIPT_FUNCTIONARY_V2 / with tools + + Prompt: ```js -[INST] Add two numbers for the purpose of this test. [/INST]{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}[INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST]The sum of 2535 and 32222000403 is 42. +<|from|>user +<|recipient|>all +<|content|>Add two numbers for the purpose of this test. +<|from|>assistant +<|recipient|>all +<|content|>{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|stop|> +<|from|>superSecretTool +<|recipient|>all +<|content|>32222002938 +<|from|>assistant +<|recipient|>all +<|content|>The sum of 2535 and 32222000403 is 42.<|stop|> +<|from|>assistant +<|recipient|> ``` -## ToolsPromptStyle.TYPESCRIPT_FUNCTIONARY_V2 - - -### with tools - - Prompt: ```json @@ -481,46 +516,7 @@ tool-call-without-start ::= superSecretTool-call | say-call ``` -# functionary_v2_2 - - -Template: - -```js -{#v2.2#} -{% for message in messages %} -{% if message['role'] == 'user' or message['role'] == 'system' %} -{{ '<|from|>' + message['role'] + ' -<|recipient|>all -<|content|>' + message['content'] + ' -' }}{% elif message['role'] == 'tool' %} -{{ '<|from|>' + message['name'] + ' -<|recipient|>all -<|content|>' + message['content'] + ' -' }}{% else %} -{% set contain_content='no'%} -{% if message['content'] is not none %} -{{ '<|from|>assistant -<|recipient|>all -<|content|>' + message['content'] }}{% set contain_content='yes'%} -{% endif %} -{% if 'tool_calls' in message and message['tool_calls'] is not none %} -{% for tool_call in message['tool_calls'] %} -{% set prompt='<|from|>assistant -<|recipient|>' + tool_call['function']['name'] + ' -<|content|>' + tool_call['function']['arguments'] %} -{% if loop.index == 1 and contain_content == "no" %} -{{ prompt }}{% else %} -{{ ' -' + prompt}}{% endif %} -{% endfor %} -{% endif %} -{{ '<|stop|> -' }}{% endif %} -{% endfor %} -{% if add_generation_prompt %}{{ '<|from|>assistant -<|recipient|>' }}{% endif %} -``` +### functionary_v2_2 / TYPESCRIPT_FUNCTIONARY_V2 / without tools Prompt: @@ -543,9 +539,6 @@ Prompt: ``` -### without tools - - Prompt: ```json @@ -565,74 +558,41 @@ space ::= " "? ``` -# functionary_v2_2 +# hermes_2_pro_mistral Template: ```js -{#v2.2#} -{% for message in messages %} -{% if message['role'] == 'user' or message['role'] == 'system' %} -{{ '<|from|>' + message['role'] + ' -<|recipient|>all -<|content|>' + message['content'] + ' -' }}{% elif message['role'] == 'tool' %} -{{ '<|from|>' + message['name'] + ' -<|recipient|>all -<|content|>' + message['content'] + ' -' }}{% else %} -{% set contain_content='no'%} -{% if message['content'] is not none %} -{{ '<|from|>assistant -<|recipient|>all -<|content|>' + message['content'] }}{% set contain_content='yes'%} -{% endif %} -{% if 'tool_calls' in message and message['tool_calls'] is not none %} -{% for tool_call in message['tool_calls'] %} -{% set prompt='<|from|>assistant -<|recipient|>' + tool_call['function']['name'] + ' -<|content|>' + tool_call['function']['arguments'] %} -{% if loop.index == 1 and contain_content == "no" %} -{{ prompt }}{% else %} -{{ ' -' + prompt}}{% endif %} -{% endfor %} -{% endif %} -{{ '<|stop|> +{% for message in messages %}{{'<|im_start|>' + message['role'] + ' +' + message['content'] + '<|im_end|>' + ' +'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant ' }}{% endif %} -{% endfor %} -{% if add_generation_prompt %}{{ '<|from|>assistant -<|recipient|>' }}{% endif %} ``` +## hermes_2_pro_mistral / TOOLS_SHORT + + +### hermes_2_pro_mistral / TOOLS_SHORT / with tools + + Prompt: ```js -<|from|>user -<|recipient|>all -<|content|>Add two numbers for the purpose of this test. -<|from|>assistant -<|recipient|>all -<|content|>{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|stop|> -<|from|>superSecretTool -<|recipient|>all -<|content|>32222002938 -<|from|>assistant -<|recipient|>all -<|content|>The sum of 2535 and 32222000403 is 42.<|stop|> -<|from|>assistant -<|recipient|> +<|im_start|>user +Add two numbers for the purpose of this test.<|im_end|> +<|im_start|>assistant +{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> +<|im_start|>tool +32222002938<|im_end|> +<|im_start|>assistant +The sum of 2535 and 32222000403 is 42.<|im_end|> +<|im_start|>assistant + ``` -## ToolsPromptStyle.TOOLS_SHORT - - -### with tools - - Prompt: ```json @@ -711,17 +671,7 @@ tool-call ::= "" space (superSecretTool-tool-call | say-tool-call) s ``` -# hermes_2_pro_mistral - - -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` +### hermes_2_pro_mistral / TOOLS_SHORT / without tools Prompt: @@ -740,9 +690,6 @@ The sum of 2535 and 32222000403 is 42.<|im_end|> ``` -### without tools - - Prompt: ```json @@ -762,17 +709,10 @@ space ::= " "? ``` -# hermes_2_pro_mistral +## hermes_2_pro_mistral / TOOLS_LONG -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` +### hermes_2_pro_mistral / TOOLS_LONG / with tools Prompt: @@ -791,12 +731,6 @@ The sum of 2535 and 32222000403 is 42.<|im_end|> ``` -## ToolsPromptStyle.TOOLS_LONG - - -### with tools - - Prompt: ```json @@ -880,17 +814,7 @@ tool-call ::= "" space (superSecretTool-tool-call | say-tool-call) s ``` -# hermes_2_pro_mistral - - -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` +### hermes_2_pro_mistral / TOOLS_LONG / without tools Prompt: @@ -909,9 +833,6 @@ The sum of 2535 and 32222000403 is 42.<|im_end|> ``` -### without tools - - Prompt: ```json @@ -931,193 +852,10 @@ space ::= " "? ``` -# hermes_2_pro_mistral +## hermes_2_pro_mistral / TOOLS_THOUGHTFUL_STEPS -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` - - -Prompt: - -```js -<|im_start|>user -Add two numbers for the purpose of this test.<|im_end|> -<|im_start|>assistant -{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> -<|im_start|>tool -32222002938<|im_end|> -<|im_start|>assistant -The sum of 2535 and 32222000403 is 42.<|im_end|> -<|im_start|>assistant - -``` - - -## ToolsPromptStyle.TOOLS_THOUGHTFUL_STEPS - - -### with tools - - -Prompt: - -```json -You are a function calling AI model. -Here are the tools available: -{ - "type": "function", - "function": { - "name": "superSecretTool", - "description": "Adds two numbers", - "parameters": { - "properties": { - "a": { - "type": "integer" - }, - "b": { - "type": "integer" - } - }, - "required": [ - "a", - "b" - ] - } - } -} -{ - "type": "function", - "function": { - "name": "say", - "description": "Says something out loud (TTS)", - "parameters": { - "properties": { - "text": { - "description": "The text to say out loud", - "type": "string" - } - }, - "required": [ - "text" - ] - } - } -} -Please respond in JSON format with the following schema: { - "type": "object", - "properties": { - "thought_about_next_step_only": { - "title": "Thought about next step", - "type": "string" - }, - "next_step": { - "title": "Next Step: either a result or one or more tool calls to achieve the original goal", - "oneOf": [ - { - "properties": { - "tool_calls": { - "prefixItems": [ - { - "properties": { - "name": { - "title": "Name of the tool to call", - "type": "string" - }, - "arguments": { - "title": "Arguments to pass to the tool", - "type": "object" - } - }, - "required": [ - "name", - "arguments" - ] - } - ] - } - }, - "required": [ - "tool_calls" - ] - }, - { - "title": "Result (achieving original goal)", - "properties": { - "result": { - "type": "integer" - } - }, - "required": [ - "result" - ] - } - ] - } - }, - "required": [ - "original_goal", - "thought_about_next_step_only", - "next_step" - ] -} -``` - - -Grammar: - -```js -decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -integer ::= ("-"? integral-part) space -integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -next-step ::= next-step-0 | next-step-1 -next-step-0 ::= "{" space next-step-0-tool-calls-kv "}" space -next-step-0-tool-calls ::= "[" space next-step-0-tool-calls-tuple-0 "]" space -next-step-0-tool-calls-kv ::= "\"tool_calls\"" space ":" space next-step-0-tool-calls -next-step-0-tool-calls-tuple-0 ::= next-step-0-tool-calls-tuple-0-0 | next-step-0-tool-calls-tuple-0-1 -next-step-0-tool-calls-tuple-0-0 ::= "{" space next-step-0-tool-calls-tuple-0-0-name-kv "," space next-step-0-tool-calls-tuple-0-0-arguments-kv "}" space -next-step-0-tool-calls-tuple-0-0-arguments ::= "{" space next-step-0-tool-calls-tuple-0-0-arguments-a-kv "," space next-step-0-tool-calls-tuple-0-0-arguments-b-kv "}" space -next-step-0-tool-calls-tuple-0-0-arguments-a-kv ::= "\"a\"" space ":" space integer -next-step-0-tool-calls-tuple-0-0-arguments-b-kv ::= "\"b\"" space ":" space integer -next-step-0-tool-calls-tuple-0-0-arguments-kv ::= "\"arguments\"" space ":" space next-step-0-tool-calls-tuple-0-0-arguments -next-step-0-tool-calls-tuple-0-0-name ::= "\"superSecretTool\"" -next-step-0-tool-calls-tuple-0-0-name-kv ::= "\"name\"" space ":" space next-step-0-tool-calls-tuple-0-0-name -next-step-0-tool-calls-tuple-0-1 ::= "{" space next-step-0-tool-calls-tuple-0-1-name-kv "," space next-step-0-tool-calls-tuple-0-1-arguments-kv "}" space -next-step-0-tool-calls-tuple-0-1-arguments ::= "{" space next-step-0-tool-calls-tuple-0-1-arguments-text-kv "}" space -next-step-0-tool-calls-tuple-0-1-arguments-kv ::= "\"arguments\"" space ":" space next-step-0-tool-calls-tuple-0-1-arguments -next-step-0-tool-calls-tuple-0-1-arguments-text-kv ::= "\"text\"" space ":" space string -next-step-0-tool-calls-tuple-0-1-name ::= "\"say\"" -next-step-0-tool-calls-tuple-0-1-name-kv ::= "\"name\"" space ":" space next-step-0-tool-calls-tuple-0-1-name -next-step-1 ::= "{" space next-step-1-result-kv "}" space -next-step-1-result-kv ::= "\"result\"" space ":" space integer -next-step-kv ::= "\"next_step\"" space ":" space next-step -root ::= "{" space thought-about-next-step-only-kv "," space next-step-kv "}" space -space ::= " "? -string ::= "\"" ( - [^"\\] | - "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) - )* "\"" space -thought-about-next-step-only-kv ::= "\"thought_about_next_step_only\"" space ":" space string -``` - - -# hermes_2_pro_mistral - - -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` +### hermes_2_pro_mistral / TOOLS_THOUGHTFUL_STEPS / with tools Prompt: @@ -1168,480 +906,6 @@ Prompt: ``` -### without tools - - -Prompt: - -```json -Please respond in JSON format with the following schema: { - "type": "integer" -} -``` - - -Grammar: - -```js -decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -root ::= ("-"? integral-part) space -space ::= " "? -``` - - -# hermes_2_pro_mistral - - -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` - - -Prompt: - -```js -<|im_start|>user -Add two numbers for the purpose of this test.<|im_end|> -<|im_start|>assistant -{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> -<|im_start|>tool -32222002938<|im_end|> -<|im_start|>assistant -The sum of 2535 and 32222000403 is 42.<|im_end|> -<|im_start|>assistant - -``` - - -## ToolsPromptStyle.TOOLS_HERMES_2_PRO - - -### with tools - - -Prompt: - -```json -You are a function calling AI agent with self-recursion. You can call only one function at a time and analyse data you get from function response. You are provided with function signatures within XML tags. The current date is: 2024-03-30. You may use agentic frameworks for reasoning and planning to help with user query. Please call a function and wait for function results to be provided to you in the next iteration. Don't make assumptions about what values to plug into function arguments. Once you have called a function, results will be fed back to you within XML tags. Don't make assumptions about tool results if XML tags are not present since function hasn't been executed yet. Analyze the data once you get the results and call another function. At each iteration please continue adding the your analysis to previous summary. Your final response should directly answer the user query with an anlysis or summary of the results of function calls. Here are the available tools: ['{"type":"function","function":{"name":"superSecretTool","description":"Adds two numbers","parameters":{"properties":{"a":{"type":"integer"},"b":{"type":"integer"}},"required":["a","b"]}}}', '{"type":"function","function":{"name":"say","description":"Says something out loud (TTS)","parameters":{"properties":{"text":{"description":"The text to say out loud","type":"string"}},"required":["text"]}}}'] If the provided function signatures doesn't have the function you must call, you may write executable python code in markdown syntax and call code_interpreter() function as follows: {"arguments": {"code_markdown": , "name": "code_interpreter"}} Make sure that the json object above with code markdown block is parseable with json.loads() and the XML block with XML ElementTree. Use the following pydantic model json schema for each tool call you will make: {'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name'], 'title': 'FunctionCall', 'type': 'object'} At the very first turn you don't have so you shouldn't not make up the results. -Please keep a running summary with analysis of previous function results and summaries from previous iterations. -Do not stop calling functions until the task has been accomplished or you've reached max iteration of 10. -Calling multiple functions at once can overload the system and increase cost so call one function at a time please. -If you plan to continue with analysis, always call another function. -For each function call return a valid json object (using doulbe quotes) with function name and arguments within XML tags as follows: - -{"arguments": , "name": } - - -``` - - -Grammar: - -```js -content ::= [^<] | "<" [^t<] | "" -``` - - -# hermes_2_pro_mistral - - -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` - - -Prompt: - -```js -<|im_start|>user -Add two numbers for the purpose of this test.<|im_end|> -<|im_start|>assistant -{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> -<|im_start|>tool -32222002938<|im_end|> -<|im_start|>assistant -The sum of 2535 and 32222000403 is 42.<|im_end|> -<|im_start|>assistant - -``` - - -### without tools - - -Prompt: - -```json -Please respond in JSON format with the following schema: { - "type": "integer" -} -``` - - -Grammar: - -```js -decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -root ::= ("-"? integral-part) space -space ::= " "? -``` - - -# hermes_2_pro_mistral - - -Template: - -```js -{% for message in messages %}{{'<|im_start|>' + message['role'] + ' -' + message['content'] + '<|im_end|>' + ' -'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %} -``` - - -Prompt: - -```js -<|im_start|>user -Add two numbers for the purpose of this test.<|im_end|> -<|im_start|>assistant -{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> -<|im_start|>tool -32222002938<|im_end|> -<|im_start|>assistant -The sum of 2535 and 32222000403 is 42.<|im_end|> -<|im_start|>assistant - -``` - - -## ToolsPromptStyle.TOOLS_SHORT - - -### with tools - - -Prompt: - -```json -Here are the tools available: - -{ - "type": "function", - "function": { - "name": "superSecretTool", - "description": "Adds two numbers", - "parameters": { - "properties": { - "a": { - "type": "integer" - }, - "b": { - "type": "integer" - } - }, - "required": [ - "a", - "b" - ] - } - } -} -{ - "type": "function", - "function": { - "name": "say", - "description": "Says something out loud (TTS)", - "parameters": { - "properties": { - "text": { - "description": "The text to say out loud", - "type": "string" - } - }, - "required": [ - "text" - ] - } - } -} - -``` - - -Grammar: - -```js -content ::= [^<] | "<" [^t<] | "" -``` - - -# llama2 - - -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` - - -Prompt: - -```js -[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. -``` - - -### without tools - - -Prompt: - -```json -Please respond in JSON format with the following schema: { - "type": "integer" -} -``` - - -Grammar: - -```js -decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -root ::= ("-"? integral-part) space -space ::= " "? -``` - - -# llama2 - - -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` - - -Prompt: - -```js -[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. -``` - - -## ToolsPromptStyle.TOOLS_LONG - - -### with tools - - -Prompt: - -```json -Call one or more functions to assist with the user query, every time this is possible. Don't make assumptions about what values to plug into functions. Here are the available tools: - -{ - "type": "function", - "function": { - "name": "superSecretTool", - "description": "Adds two numbers", - "parameters": { - "properties": { - "a": { - "type": "integer" - }, - "b": { - "type": "integer" - } - }, - "required": [ - "a", - "b" - ] - } - } -} -{ - "type": "function", - "function": { - "name": "say", - "description": "Says something out loud (TTS)", - "parameters": { - "properties": { - "text": { - "description": "The text to say out loud", - "type": "string" - } - }, - "required": [ - "text" - ] - } - } -} - - -To call each function, give its name and arguments within XML tags as follows: - -{"name": , "arguments": } - -``` - - -Grammar: - -```js -content ::= [^<] | "<" [^t<] | "" -``` - - -# llama2 - - -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` - - -Prompt: - -```js -[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. -``` - - -### without tools - - -Prompt: - -```json -Please respond in JSON format with the following schema: { - "type": "integer" -} -``` - - -Grammar: - -```js -decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -root ::= ("-"? integral-part) space -space ::= " "? -``` - - -# llama2 - - -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` - - -Prompt: - -```js -[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. -``` - - -## ToolsPromptStyle.TOOLS_THOUGHTFUL_STEPS - - -### with tools - - Prompt: ```json @@ -1783,6 +1047,150 @@ thought-about-next-step-only-kv ::= "\"thought_about_next_step_only\"" space ":" ``` +### hermes_2_pro_mistral / TOOLS_THOUGHTFUL_STEPS / without tools + + +Prompt: + +```js +<|im_start|>user +Add two numbers for the purpose of this test.<|im_end|> +<|im_start|>assistant +{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> +<|im_start|>tool +32222002938<|im_end|> +<|im_start|>assistant +The sum of 2535 and 32222000403 is 42.<|im_end|> +<|im_start|>assistant + +``` + + +Prompt: + +```json +Please respond in JSON format with the following schema: { + "type": "integer" +} +``` + + +Grammar: + +```js +decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +root ::= ("-"? integral-part) space +space ::= " "? +``` + + +## hermes_2_pro_mistral / TOOLS_HERMES_2_PRO + + +### hermes_2_pro_mistral / TOOLS_HERMES_2_PRO / with tools + + +Prompt: + +```js +<|im_start|>user +Add two numbers for the purpose of this test.<|im_end|> +<|im_start|>assistant +{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> +<|im_start|>tool +32222002938<|im_end|> +<|im_start|>assistant +The sum of 2535 and 32222000403 is 42.<|im_end|> +<|im_start|>assistant + +``` + + +Prompt: + +```json +You are a function calling AI agent with self-recursion. You can call only one function at a time and analyse data you get from function response. You are provided with function signatures within XML tags. The current date is: 2024-03-30. You may use agentic frameworks for reasoning and planning to help with user query. Please call a function and wait for function results to be provided to you in the next iteration. Don't make assumptions about what values to plug into function arguments. Once you have called a function, results will be fed back to you within XML tags. Don't make assumptions about tool results if XML tags are not present since function hasn't been executed yet. Analyze the data once you get the results and call another function. At each iteration please continue adding the your analysis to previous summary. Your final response should directly answer the user query with an anlysis or summary of the results of function calls. Here are the available tools: ['{"type":"function","function":{"name":"superSecretTool","description":"Adds two numbers","parameters":{"properties":{"a":{"type":"integer"},"b":{"type":"integer"}},"required":["a","b"]}}}', '{"type":"function","function":{"name":"say","description":"Says something out loud (TTS)","parameters":{"properties":{"text":{"description":"The text to say out loud","type":"string"}},"required":["text"]}}}'] If the provided function signatures doesn't have the function you must call, you may write executable python code in markdown syntax and call code_interpreter() function as follows: {"arguments": {"code_markdown": , "name": "code_interpreter"}} Make sure that the json object above with code markdown block is parseable with json.loads() and the XML block with XML ElementTree. Use the following pydantic model json schema for each tool call you will make: {'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name'], 'title': 'FunctionCall', 'type': 'object'} At the very first turn you don't have so you shouldn't not make up the results. +Please keep a running summary with analysis of previous function results and summaries from previous iterations. +Do not stop calling functions until the task has been accomplished or you've reached max iteration of 10. +Calling multiple functions at once can overload the system and increase cost so call one function at a time please. +If you plan to continue with analysis, always call another function. +For each function call return a valid json object (using doulbe quotes) with function name and arguments within XML tags as follows: + +{"arguments": , "name": } + + +``` + + +Grammar: + +```js +content ::= [^<] | "<" [^t<] | "" +``` + + +### hermes_2_pro_mistral / TOOLS_HERMES_2_PRO / without tools + + +Prompt: + +```js +<|im_start|>user +Add two numbers for the purpose of this test.<|im_end|> +<|im_start|>assistant +{"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}}<|im_end|> +<|im_start|>tool +32222002938<|im_end|> +<|im_start|>assistant +The sum of 2535 and 32222000403 is 42.<|im_end|> +<|im_start|>assistant + +``` + + +Prompt: + +```json +Please respond in JSON format with the following schema: { + "type": "integer" +} +``` + + +Grammar: + +```js +decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +root ::= ("-"? integral-part) space +space ::= " "? +``` + + # llama2 @@ -1793,6 +1201,257 @@ Template: ``` +## llama2 / TOOLS_SHORT + + +### llama2 / TOOLS_SHORT / with tools + + +Prompt: + +```js +[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. +``` + + +Prompt: + +```json +Here are the tools available: + +{ + "type": "function", + "function": { + "name": "superSecretTool", + "description": "Adds two numbers", + "parameters": { + "properties": { + "a": { + "type": "integer" + }, + "b": { + "type": "integer" + } + }, + "required": [ + "a", + "b" + ] + } + } +} +{ + "type": "function", + "function": { + "name": "say", + "description": "Says something out loud (TTS)", + "parameters": { + "properties": { + "text": { + "description": "The text to say out loud", + "type": "string" + } + }, + "required": [ + "text" + ] + } + } +} + +``` + + +Grammar: + +```js +content ::= [^<] | "<" [^t<] | "" +``` + + +### llama2 / TOOLS_SHORT / without tools + + +Prompt: + +```js +[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. +``` + + +Prompt: + +```json +Please respond in JSON format with the following schema: { + "type": "integer" +} +``` + + +Grammar: + +```js +decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +root ::= ("-"? integral-part) space +space ::= " "? +``` + + +## llama2 / TOOLS_LONG + + +### llama2 / TOOLS_LONG / with tools + + +Prompt: + +```js +[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. +``` + + +Prompt: + +```json +Call one or more functions to assist with the user query, every time this is possible. Don't make assumptions about what values to plug into functions. Here are the available tools: + +{ + "type": "function", + "function": { + "name": "superSecretTool", + "description": "Adds two numbers", + "parameters": { + "properties": { + "a": { + "type": "integer" + }, + "b": { + "type": "integer" + } + }, + "required": [ + "a", + "b" + ] + } + } +} +{ + "type": "function", + "function": { + "name": "say", + "description": "Says something out loud (TTS)", + "parameters": { + "properties": { + "text": { + "description": "The text to say out loud", + "type": "string" + } + }, + "required": [ + "text" + ] + } + } +} + + +To call each function, give its name and arguments within XML tags as follows: + +{"name": , "arguments": } + +``` + + +Grammar: + +```js +content ::= [^<] | "<" [^t<] | "" +``` + + +### llama2 / TOOLS_LONG / without tools + + +Prompt: + +```js +[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. +``` + + +Prompt: + +```json +Please respond in JSON format with the following schema: { + "type": "integer" +} +``` + + +Grammar: + +```js +decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +root ::= ("-"? integral-part) space +space ::= " "? +``` + + +## llama2 / TOOLS_THOUGHTFUL_STEPS + + +### llama2 / TOOLS_THOUGHTFUL_STEPS / with tools + + Prompt: ```js @@ -1832,7 +1491,155 @@ Prompt: ``` -### without tools +Prompt: + +```json +You are a function calling AI model. +Here are the tools available: +{ + "type": "function", + "function": { + "name": "superSecretTool", + "description": "Adds two numbers", + "parameters": { + "properties": { + "a": { + "type": "integer" + }, + "b": { + "type": "integer" + } + }, + "required": [ + "a", + "b" + ] + } + } +} +{ + "type": "function", + "function": { + "name": "say", + "description": "Says something out loud (TTS)", + "parameters": { + "properties": { + "text": { + "description": "The text to say out loud", + "type": "string" + } + }, + "required": [ + "text" + ] + } + } +} +Please respond in JSON format with the following schema: { + "type": "object", + "properties": { + "thought_about_next_step_only": { + "title": "Thought about next step", + "type": "string" + }, + "next_step": { + "title": "Next Step: either a result or one or more tool calls to achieve the original goal", + "oneOf": [ + { + "properties": { + "tool_calls": { + "prefixItems": [ + { + "properties": { + "name": { + "title": "Name of the tool to call", + "type": "string" + }, + "arguments": { + "title": "Arguments to pass to the tool", + "type": "object" + } + }, + "required": [ + "name", + "arguments" + ] + } + ] + } + }, + "required": [ + "tool_calls" + ] + }, + { + "title": "Result (achieving original goal)", + "properties": { + "result": { + "type": "integer" + } + }, + "required": [ + "result" + ] + } + ] + } + }, + "required": [ + "original_goal", + "thought_about_next_step_only", + "next_step" + ] +} +``` + + +Grammar: + +```js +decimal-part ::= [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +integer ::= ("-"? integral-part) space +integral-part ::= [0-9] | [1-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? +next-step ::= next-step-0 | next-step-1 +next-step-0 ::= "{" space next-step-0-tool-calls-kv "}" space +next-step-0-tool-calls ::= "[" space next-step-0-tool-calls-tuple-0 "]" space +next-step-0-tool-calls-kv ::= "\"tool_calls\"" space ":" space next-step-0-tool-calls +next-step-0-tool-calls-tuple-0 ::= next-step-0-tool-calls-tuple-0-0 | next-step-0-tool-calls-tuple-0-1 +next-step-0-tool-calls-tuple-0-0 ::= "{" space next-step-0-tool-calls-tuple-0-0-name-kv "," space next-step-0-tool-calls-tuple-0-0-arguments-kv "}" space +next-step-0-tool-calls-tuple-0-0-arguments ::= "{" space next-step-0-tool-calls-tuple-0-0-arguments-a-kv "," space next-step-0-tool-calls-tuple-0-0-arguments-b-kv "}" space +next-step-0-tool-calls-tuple-0-0-arguments-a-kv ::= "\"a\"" space ":" space integer +next-step-0-tool-calls-tuple-0-0-arguments-b-kv ::= "\"b\"" space ":" space integer +next-step-0-tool-calls-tuple-0-0-arguments-kv ::= "\"arguments\"" space ":" space next-step-0-tool-calls-tuple-0-0-arguments +next-step-0-tool-calls-tuple-0-0-name ::= "\"superSecretTool\"" +next-step-0-tool-calls-tuple-0-0-name-kv ::= "\"name\"" space ":" space next-step-0-tool-calls-tuple-0-0-name +next-step-0-tool-calls-tuple-0-1 ::= "{" space next-step-0-tool-calls-tuple-0-1-name-kv "," space next-step-0-tool-calls-tuple-0-1-arguments-kv "}" space +next-step-0-tool-calls-tuple-0-1-arguments ::= "{" space next-step-0-tool-calls-tuple-0-1-arguments-text-kv "}" space +next-step-0-tool-calls-tuple-0-1-arguments-kv ::= "\"arguments\"" space ":" space next-step-0-tool-calls-tuple-0-1-arguments +next-step-0-tool-calls-tuple-0-1-arguments-text-kv ::= "\"text\"" space ":" space string +next-step-0-tool-calls-tuple-0-1-name ::= "\"say\"" +next-step-0-tool-calls-tuple-0-1-name-kv ::= "\"name\"" space ":" space next-step-0-tool-calls-tuple-0-1-name +next-step-1 ::= "{" space next-step-1-result-kv "}" space +next-step-1-result-kv ::= "\"result\"" space ":" space integer +next-step-kv ::= "\"next_step\"" space ":" space next-step +root ::= "{" space thought-about-next-step-only-kv "," space next-step-kv "}" space +space ::= " "? +string ::= "\"" ( + [^"\\] | + "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) + )* "\"" space +thought-about-next-step-only-kv ::= "\"thought_about_next_step_only\"" space ":" space string +``` + + +### llama2 / TOOLS_THOUGHTFUL_STEPS / without tools + + +Prompt: + +```js +[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. +``` Prompt: @@ -1854,14 +1661,10 @@ space ::= " "? ``` -# llama2 +## llama2 / TOOLS_HERMES_2_PRO -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` +### llama2 / TOOLS_HERMES_2_PRO / with tools Prompt: @@ -1871,12 +1674,6 @@ Prompt: ``` -## ToolsPromptStyle.TOOLS_HERMES_2_PRO - - -### with tools - - Prompt: ```json @@ -1923,14 +1720,7 @@ tool-call ::= "" space (superSecretTool-tool-call | say-tool-call) s ``` -# llama2 - - -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` +### llama2 / TOOLS_HERMES_2_PRO / without tools Prompt: @@ -1940,9 +1730,6 @@ Prompt: ``` -### without tools - - Prompt: ```json @@ -1961,20 +1748,3 @@ root ::= ("-"? integral-part) space space ::= " "? ``` - -# llama2 - - -Template: - -```js -{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\n' + system_message + '\n<>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %} -``` - - -Prompt: - -```js -[INST] Add two numbers for the purpose of this test. [/INST] {"id": "call_531873", "type": "function", "function": {"name": "superSecretTool", "arguments": {"a": 2535, "b": 32222000403}}} [INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] The sum of 2535 and 32222000403 is 42. -``` -