-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[Frontend][Feature] support tool calling for internlm/internlm2_5-7b-chat model #8405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DarkLight1337
merged 25 commits into
vllm-project:main
from
sydnash:add-internlm2-for-tool-use
Oct 4, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
87b6352
[add] add tools call for internlm2
sydnash 5355659
Merge branch 'main' into add-internlm2-for-tool-use
sydnash 68cd89d
[add] add some comments
sydnash d17f006
[add] add some comments
sydnash 2d7d9d4
[fix] fix internlm2 tool chat template, fix the internlm2 tool call o…
sydnash 12352e7
[add] add tool parser plugin doc
sydnash 11bed0d
[add] add tool parser plugin doc
sydnash 8a8b840
[fix] fix the stream tool call for internlm2
sydnash 00c5da2
[fix] comment
sydnash 882c764
[merge] resolve conflict
sydnash 12b1035
[fix] use metavar to display the help info for --tool-call-parser, ad…
sydnash ed5b3fd
[add] got valid tool parsers from ToolParserManager
sydnash ea2c089
[fix] fix build for docs
sydnash 36ad5d0
[fix] internlm's tool call out may arguments or parameters
sydnash cf981c0
[merge] resolve conflict
sydnash 647db0d
refactor the tool parser to internlm, fix the test case of streamed_args
sydnash 064ca1f
merge main
sydnash 106909c
[fix] fix internlm parallel test, remove vllm/version.py
sydnash e242501
[format]
sydnash 0a5ddf4
[format]
sydnash 1db530d
[fix] fix the mistral tool call error. recover vllm/version.py and de…
sydnash dc94a22
[fix] change vocab property to get_vocab method in mistral_tool_parse…
sydnash 3048233
Merge remote-tracking branch 'origin/main' into add-internlm2-for-too…
sydnash a2f938f
[fix] remove --tokenizer-mode mistral for mistral test. fix the syste…
sydnash 4b619a2
[merge] merge from main
sydnash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,60 @@ | ||
| {%- if messages[0]["role"] == "system" %} | ||
| {%- set system_message = messages[0]["content"] %} | ||
| {%- set loop_messages = messages[1:] %} | ||
| {%- else %} | ||
| {%- set loop_messages = messages %} | ||
| {%- endif %} | ||
|
|
||
| {%- if not tools is defined %} | ||
| {%- set tools = none %} | ||
| {%- endif %} | ||
|
|
||
| {{- bos_token }} | ||
| {%- if system_message is defined %} | ||
| {{- "<|im_start|>system\n" + system_message + "<|im_end|>\n" }} | ||
| {%- endif %} | ||
|
|
||
| {%- if tools is not none %} | ||
| {{- "<|im_start|>system name=<|plugin|>\n[" }} | ||
| {%- for tool in tools %} | ||
| {{- tool.function|tojson }} | ||
| {%- if not loop.last %} | ||
| {{- ", " }} | ||
| {%- else %} | ||
| {{- "]" }} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| {{- "<|im_end|>\n" }} | ||
| {%- endif %} | ||
|
|
||
| {%- for message in loop_messages %} | ||
| {%- if message["role"] == "user" %} | ||
| {{- "<|im_start|>user\n" + message["content"] + "<|im_end|>\n"}} | ||
| {%- elif message.tool_calls is defined and message.tool_calls is not none %} | ||
| {%- set content = message["content"] if message["content"] else "" %} | ||
| {{- "<|im_start|>assistant\n" + content }} | ||
| {%- for tool_call in message.tool_calls %} | ||
| {%- set function=tool_call.function %} | ||
| {{- "<|action_start|><|plugin|>\n" }} | ||
| {{- '{"name": "' + function.name + '", '}} | ||
| {{- '"arguments": ' + function.arguments|tojson + '}' }} | ||
| {{- "<|action_end|>" }} | ||
| {%- endfor %} | ||
| {{- "<|im_end|>\n" }} | ||
| {%- elif message["role"] == "assistant" %} | ||
| {{- "<|im_start|>assistant\n" + message["content"] + "<|im_end|>\n"}} | ||
| {%- elif message["role"] == "tool_results" or message["role"] == "tool" or message["role"] == "function" %} | ||
| {%- if message.content is defined and message.content.content is defined %} | ||
| {%- set content = message.content.content %} | ||
| {%- else %} | ||
| {%- set content = message.content %} | ||
| {%- endif %} | ||
| {{- "<|im_start|>environment name=<|plugin|>\n" + content|string + "<|im_end|>\n" }} | ||
| {%- else %} | ||
| {{- raise_exception("Only user and assistant and tool_results and tool and function roles are supported, with the exception of an initial optional system message!") }} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
|
|
||
| {%- if add_generation_prompt %} | ||
| {{- '<|im_start|>assistant\n' }} | ||
| {%- endif %} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,9 +1,10 @@ | ||
| from .abstract_tool_parser import ToolParser | ||
| from .abstract_tool_parser import ToolParser, ToolParserManager | ||
| from .hermes_tool_parser import Hermes2ProToolParser | ||
| from .internlm2_tool_parser import Internlm2ToolParser | ||
| from .llama_tool_parser import Llama3JsonToolParser | ||
| from .mistral_tool_parser import MistralToolParser | ||
|
|
||
| __all__ = [ | ||
| "ToolParser", "Hermes2ProToolParser", "MistralToolParser", | ||
| "Llama3JsonToolParser" | ||
| "ToolParser", "ToolParserManager", "Hermes2ProToolParser", | ||
| "MistralToolParser", "Internlm2ToolParser", "Llama3JsonToolParser" | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.