forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Frontend] Tool calling parser for Granite 3.0 models (vllm-project#9027
) Signed-off-by: Max de Bayser <[email protected]> Signed-off-by: Loc Huynh <[email protected]>
- Loading branch information
1 parent
7be2a3a
commit 5a2b152
Showing
6 changed files
with
314 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{%- if tools %} | ||
{{- '<|start_of_role|>available_tools<|end_of_role|> | ||
' }} | ||
{%- for tool in tools %} | ||
{{- tool | tojson(indent=4) }} | ||
{%- if not loop.last %} | ||
{{- ' | ||
|
||
' }} | ||
{%- endif %} | ||
{%- endfor %} | ||
{{- '<|end_of_text|> | ||
' }} | ||
{%- endif %} | ||
|
||
{%- for message in messages %} | ||
{%- if message['role'] == 'system' %} | ||
{{- '<|start_of_role|>system<|end_of_role|>' + message['content'] + '<|end_of_text|> | ||
' }} | ||
{%- elif message['role'] == 'user' %} | ||
{{- '<|start_of_role|>user<|end_of_role|>' + message['content'] + '<|end_of_text|> | ||
' }} | ||
{%- elif message['role'] == 'assistant_tool_call' or (message['role'] == 'assistant' and message.tool_calls is defined) %} | ||
{{- '<|start_of_role|>assistant<|end_of_role|>' }} | ||
{% for tc in message.tool_calls %} | ||
{{- '<|tool_call|> ' + {'name': tc.function.name, 'arguments': tc.function.arguments}|tojson }} | ||
{% endfor %} | ||
{{- '<|end_of_text|> | ||
' }} | ||
{%- elif message['role'] == 'assistant' %} | ||
{{- '<|start_of_role|>assistant<|end_of_role|>' + message['content'] + '<|end_of_text|> | ||
' }} | ||
{%- elif message['role'] == 'tool_response' or message['role'] == 'tool' %} | ||
{{- '<|start_of_role|>tool_response<|end_of_role|>' + message['content'] + '<|end_of_text|> | ||
' }} | ||
{%- endif %} | ||
{%- if loop.last and add_generation_prompt %} | ||
{{- '<|start_of_role|>assistant<|end_of_role|>' }} | ||
{%- endif %} | ||
{%- endfor %} |
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.