alexmarques commited on
Commit
4c7218f
·
verified ·
1 Parent(s): 9d76fe7

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. LICENSE +202 -0
  3. README.md +175 -0
  4. chat_template.jinja +117 -0
  5. config.json +238 -0
  6. generation_config.json +12 -0
  7. merges.txt +0 -0
  8. model-00003-of-00049.safetensors +3 -0
  9. model-00006-of-00049.safetensors +3 -0
  10. model-00007-of-00049.safetensors +3 -0
  11. model-00008-of-00049.safetensors +3 -0
  12. model-00009-of-00049.safetensors +3 -0
  13. model-00012-of-00049.safetensors +3 -0
  14. model-00013-of-00049.safetensors +3 -0
  15. model-00014-of-00049.safetensors +3 -0
  16. model-00017-of-00049.safetensors +3 -0
  17. model-00018-of-00049.safetensors +3 -0
  18. model-00019-of-00049.safetensors +3 -0
  19. model-00021-of-00049.safetensors +3 -0
  20. model-00022-of-00049.safetensors +3 -0
  21. model-00023-of-00049.safetensors +3 -0
  22. model-00024-of-00049.safetensors +3 -0
  23. model-00025-of-00049.safetensors +3 -0
  24. model-00026-of-00049.safetensors +3 -0
  25. model-00027-of-00049.safetensors +3 -0
  26. model-00028-of-00049.safetensors +3 -0
  27. model-00029-of-00049.safetensors +3 -0
  28. model-00030-of-00049.safetensors +3 -0
  29. model-00031-of-00049.safetensors +3 -0
  30. model-00032-of-00049.safetensors +3 -0
  31. model-00033-of-00049.safetensors +3 -0
  32. model-00034-of-00049.safetensors +3 -0
  33. model-00036-of-00049.safetensors +3 -0
  34. model-00037-of-00049.safetensors +3 -0
  35. model-00038-of-00049.safetensors +3 -0
  36. model-00039-of-00049.safetensors +3 -0
  37. model-00040-of-00049.safetensors +3 -0
  38. model-00041-of-00049.safetensors +3 -0
  39. model-00042-of-00049.safetensors +3 -0
  40. model-00043-of-00049.safetensors +3 -0
  41. model-00045-of-00049.safetensors +3 -0
  42. model-00046-of-00049.safetensors +3 -0
  43. model-00047-of-00049.safetensors +3 -0
  44. model-00048-of-00049.safetensors +3 -0
  45. model-00049-of-00049.safetensors +3 -0
  46. model.safetensors.index.json +0 -0
  47. qwen3coder_tool_parser.py +689 -0
  48. tokenizer.json +3 -0
  49. tokenizer_config.json +239 -0
  50. vocab.json +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ license_link: https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct/blob/main/LICENSE
5
+ pipeline_tag: text-generation
6
+ ---
7
+
8
+ # Qwen3-Coder-480B-A35B-Instruct-FP8
9
+ <a href="https://chat.qwen.ai/" target="_blank" style="margin: 2px;">
10
+ <img alt="Chat" src="https://img.shields.io/badge/%F0%9F%92%9C%EF%B8%8F%20Qwen%20Chat%20-536af5" style="display: inline-block; vertical-align: middle;"/>
11
+ </a>
12
+
13
+ ## Highlights
14
+
15
+ Today, we're announcing **Qwen3-Coder**, our most agentic code model to date. **Qwen3-Coder** is available in multiple sizes, but we're excited to introduce its most powerful variant first: **Qwen3-Coder-480B-A35B-Instruct**. featuring the following key enhancements:
16
+
17
+ - **Significant Performance** among open models on **Agentic Coding**, **Agentic Browser-Use**, and other foundational coding tasks, achieving results comparable to Claude Sonnet.
18
+ - **Long-context Capabilities** with native support for **256K** tokens, extendable up to **1M** tokens using Yarn, optimized for repository-scale understanding.
19
+ - **Agentic Coding** supporting for most platform such as **Qwen Code**, **CLINE**, featuring a specially designed function call format.
20
+
21
+ ![image/jpeg](https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen3-Coder/qwen3-coder-main.jpg)
22
+
23
+ ## Model Overview
24
+
25
+ **Qwen3-480B-A35B-Instruct** has the following features:
26
+ - Type: Causal Language Models
27
+ - Training Stage: Pretraining & Post-training
28
+ - Number of Parameters: 480B in total and 35B activated
29
+ - Number of Layers: 62
30
+ - Number of Attention Heads (GQA): 96 for Q and 8 for KV
31
+ - Number of Experts: 160
32
+ - Number of Activated Experts: 8
33
+ - Context Length: **262,144 natively**.
34
+
35
+ **NOTE: This model supports only non-thinking mode and does not generate ``<think></think>`` blocks in its output. Meanwhile, specifying `enable_thinking=False` is no longer required.**
36
+
37
+ For more details, including benchmark evaluation, hardware requirements, and inference performance, please refer to our [blog](https://qwenlm.github.io/blog/qwen3-coder/), [GitHub](https://github.com/QwenLM/Qwen3-Coder), and [Documentation](https://qwen.readthedocs.io/en/latest/).
38
+
39
+
40
+ ## Quickstart
41
+
42
+ We advise you to use the latest version of `transformers`.
43
+
44
+ With `transformers<4.51.0`, you will encounter the following error:
45
+ ```
46
+ KeyError: 'qwen3_moe'
47
+ ```
48
+
49
+ The following contains a code snippet illustrating how to use the model generate content based on given inputs.
50
+ ```python
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer
52
+
53
+ model_name = "Qwen/Qwen3-480B-A35B-Instruct"
54
+
55
+ # load the tokenizer and the model
56
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
57
+ model = AutoModelForCausalLM.from_pretrained(
58
+ model_name,
59
+ torch_dtype="auto",
60
+ device_map="auto"
61
+ )
62
+
63
+ # prepare the model input
64
+ prompt = "Write a quick sort algorithm."
65
+ messages = [
66
+ {"role": "user", "content": prompt}
67
+ ]
68
+ text = tokenizer.apply_chat_template(
69
+ messages,
70
+ tokenize=False,
71
+ add_generation_prompt=True,
72
+ )
73
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
74
+
75
+ # conduct text completion
76
+ generated_ids = model.generate(
77
+ **model_inputs,
78
+ max_new_tokens=65536
79
+ )
80
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
81
+
82
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
83
+
84
+ print("content:", content)
85
+ ```
86
+
87
+ **Note: If you encounter out-of-memory (OOM) issues, consider reducing the context length to a shorter value, such as `32,768`.**
88
+
89
+
90
+ ## Note on FP8
91
+
92
+ For convenience and performance, we have provided `fp8`-quantized model checkpoint for Qwen3, whose name ends with `-FP8`. The quantization method is fine-grained `fp8` quantization with block size of 128. You can find more details in the `quantization_config` field in `config.json`.
93
+
94
+ You can use the Qwen3-480B-A35B-Instruct-FP8 model with serveral inference frameworks, including `transformers`, `sglang`, and `vllm`, as the original bfloat16 model.
95
+ However, please pay attention to the following known issues:
96
+ - `transformers`:
97
+ - there are currently issues with the "fine-grained fp8" method in `transformers` for distributed inference. You may need to set the environment variable `CUDA_LAUNCH_BLOCKING=1` if multiple devices are used in inference.
98
+
99
+
100
+ ## Agentic Coding
101
+
102
+ Qwen3-Coder excels in tool calling capabilities.
103
+
104
+ You can simply define or use any tools as following example.
105
+ ```python
106
+ # Your tool implementation
107
+ def square_the_number(num: float) -> dict:
108
+ return num ** 2
109
+
110
+ # Define Tools
111
+ tools=[
112
+ {
113
+ "type":"function",
114
+ "function":{
115
+ "name": "square_the_number",
116
+ "description": "output the square of the number.",
117
+ "parameters": {
118
+ "type": "object",
119
+ "required": ["input_num"],
120
+ "properties": {
121
+ 'input_num': {
122
+ 'type': 'number',
123
+ 'description': 'input_num is a number that will be squared'
124
+ }
125
+ },
126
+ }
127
+ }
128
+ }
129
+ ]
130
+
131
+ import OpenAI
132
+ # Define LLM
133
+ client = OpenAI(
134
+ # Use a custom endpoint compatible with OpenAI API
135
+ base_url='http://localhost:8000/v1', # api_base
136
+ api_key="EMPTY"
137
+ )
138
+
139
+ messages = [{'role': 'user', 'content': 'square the number 1024'}]
140
+
141
+ completion = client.chat.completions.create(
142
+ messages=messages,
143
+ model="Qwen3-Coder-480B-A35B-Instruct",
144
+ max_tokens=65536,
145
+ tools=tools,
146
+ )
147
+
148
+ print(completion.choice[0])
149
+ ```
150
+
151
+ ## Best Practices
152
+
153
+ To achieve optimal performance, we recommend the following settings:
154
+
155
+ 1. **Sampling Parameters**:
156
+ - We suggest using `temperature=0.7`, `top_p=0.8`, `top_k=20`, `repetition_penalty=1.05`.
157
+
158
+ 2. **Adequate Output Length**: We recommend using an output length of 65,536 tokens for most queries, which is adequate for instruct models.
159
+
160
+
161
+ ### Citation
162
+
163
+ If you find our work helpful, feel free to give us a cite.
164
+
165
+ ```
166
+ @misc{qwen3technicalreport,
167
+ title={Qwen3 Technical Report},
168
+ author={Qwen Team},
169
+ year={2025},
170
+ eprint={2505.09388},
171
+ archivePrefix={arXiv},
172
+ primaryClass={cs.CL},
173
+ url={https://arxiv.org/abs/2505.09388},
174
+ }
175
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro render_extra_keys(json_dict, handled_keys) %}
2
+ {%- if json_dict is mapping %}
3
+ {%- for json_key in json_dict if json_key not in handled_keys %}
4
+ {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
5
+ {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
6
+ {%- else %}
7
+ {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
8
+ {%- endif %}
9
+ {%- endfor %}
10
+ {%- endif %}
11
+ {% endmacro %}
12
+
13
+ {%- if messages[0]["role"] == "system" %}
14
+ {%- set system_message = messages[0]["content"] %}
15
+ {%- set loop_messages = messages[1:] %}
16
+ {%- else %}
17
+ {%- set loop_messages = messages %}
18
+ {%- endif %}
19
+
20
+ {%- if not tools is defined %}
21
+ {%- set tools = [] %}
22
+ {%- endif %}
23
+
24
+ {%- if system_message is defined %}
25
+ {{- "<|im_start|>system\n" + system_message }}
26
+ {%- else %}
27
+ {%- if tools is iterable and tools | length > 0 %}
28
+ {{- "<|im_start|>system\nYou are Qwen, a helpful AI assistant that can interact with a computer to solve tasks." }}
29
+ {%- endif %}
30
+ {%- endif %}
31
+ {%- if tools is iterable and tools | length > 0 %}
32
+ {{- "\n\n# Tools\n\nYou have access to the following functions:\n\n" }}
33
+ {{- "<tools>" }}
34
+ {%- for tool in tools %}
35
+ {%- if tool.function is defined %}
36
+ {%- set tool = tool.function %}
37
+ {%- endif %}
38
+ {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }}
39
+ {%- if tool.description is defined %}
40
+ {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }}
41
+ {%- endif %}
42
+ {{- '\n<parameters>' }}
43
+ {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}
44
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
45
+ {{- '\n<parameter>' }}
46
+ {{- '\n<name>' ~ param_name ~ '</name>' }}
47
+ {%- if param_fields.type is defined %}
48
+ {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }}
49
+ {%- endif %}
50
+ {%- if param_fields.description is defined %}
51
+ {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}
52
+ {%- endif %}
53
+ {%- set handled_keys = ['name', 'type', 'description'] %}
54
+ {{- render_extra_keys(param_fields, handled_keys) }}
55
+ {{- '\n</parameter>' }}
56
+ {%- endfor %}
57
+ {%- endif %}
58
+ {% set handled_keys = ['type', 'properties'] %}
59
+ {{- render_extra_keys(tool.parameters, handled_keys) }}
60
+ {{- '\n</parameters>' }}
61
+ {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}
62
+ {{- render_extra_keys(tool, handled_keys) }}
63
+ {{- '\n</function>' }}
64
+ {%- endfor %}
65
+ {{- "\n</tools>" }}
66
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
67
+ {%- endif %}
68
+ {%- if system_message is defined %}
69
+ {{- '<|im_end|>\n' }}
70
+ {%- else %}
71
+ {%- if tools is iterable and tools | length > 0 %}
72
+ {{- '<|im_end|>\n' }}
73
+ {%- endif %}
74
+ {%- endif %}
75
+ {%- for message in loop_messages %}
76
+ {%- if message.role == "assistant" and message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
77
+ {{- '<|im_start|>' + message.role }}
78
+ {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}
79
+ {{- '\n' + message.content | trim + '\n' }}
80
+ {%- endif %}
81
+ {%- for tool_call in message.tool_calls %}
82
+ {%- if tool_call.function is defined %}
83
+ {%- set tool_call = tool_call.function %}
84
+ {%- endif %}
85
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
86
+ {%- if tool_call.arguments is defined %}
87
+ {%- for args_name, args_value in tool_call.arguments|items %}
88
+ {{- '<parameter=' + args_name + '>\n' }}
89
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
90
+ {{- args_value }}
91
+ {{- '\n</parameter>\n' }}
92
+ {%- endfor %}
93
+ {%- endif %}
94
+ {{- '</function>\n</tool_call>' }}
95
+ {%- endfor %}
96
+ {{- '<|im_end|>\n' }}
97
+ {%- elif message.role == "user" or message.role == "system" or message.role == "assistant" %}
98
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
99
+ {%- elif message.role == "tool" %}
100
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
101
+ {{- '<|im_start|>user\n' }}
102
+ {%- endif %}
103
+ {{- '<tool_response>\n' }}
104
+ {{- message.content }}
105
+ {{- '\n</tool_response>\n' }}
106
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
107
+ {{- '<|im_end|>\n' }}
108
+ {%- elif loop.last %}
109
+ {{- '<|im_end|>\n' }}
110
+ {%- endif %}
111
+ {%- else %}
112
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
113
+ {%- endif %}
114
+ {%- endfor %}
115
+ {%- if add_generation_prompt %}
116
+ {{- '<|im_start|>assistant\n' }}
117
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3MoeForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "decoder_sparse_step": 1,
9
+ "eos_token_id": 151645,
10
+ "head_dim": 128,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 6144,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 8192,
15
+ "max_position_embeddings": 262144,
16
+ "max_window_layers": 28,
17
+ "mlp_only_layers": [],
18
+ "model_type": "qwen3_moe",
19
+ "moe_intermediate_size": 2560,
20
+ "norm_topk_prob": true,
21
+ "num_attention_heads": 96,
22
+ "num_experts": 160,
23
+ "num_experts_per_tok": 8,
24
+ "num_hidden_layers": 62,
25
+ "num_key_value_heads": 8,
26
+ "output_router_logits": false,
27
+ "qkv_bias": false,
28
+ "quantization_config": {
29
+ "activation_scheme": "dynamic",
30
+ "modules_to_not_convert": [
31
+ "lm_head",
32
+ "model.layers.0.input_layernorm",
33
+ "model.layers.0.mlp.gate",
34
+ "model.layers.0.post_attention_layernorm",
35
+ "model.layers.1.input_layernorm",
36
+ "model.layers.1.mlp.gate",
37
+ "model.layers.1.post_attention_layernorm",
38
+ "model.layers.2.input_layernorm",
39
+ "model.layers.2.mlp.gate",
40
+ "model.layers.2.post_attention_layernorm",
41
+ "model.layers.3.input_layernorm",
42
+ "model.layers.3.mlp.gate",
43
+ "model.layers.3.post_attention_layernorm",
44
+ "model.layers.4.input_layernorm",
45
+ "model.layers.4.mlp.gate",
46
+ "model.layers.4.post_attention_layernorm",
47
+ "model.layers.5.input_layernorm",
48
+ "model.layers.5.mlp.gate",
49
+ "model.layers.5.post_attention_layernorm",
50
+ "model.layers.6.input_layernorm",
51
+ "model.layers.6.mlp.gate",
52
+ "model.layers.6.post_attention_layernorm",
53
+ "model.layers.7.input_layernorm",
54
+ "model.layers.7.mlp.gate",
55
+ "model.layers.7.post_attention_layernorm",
56
+ "model.layers.8.input_layernorm",
57
+ "model.layers.8.mlp.gate",
58
+ "model.layers.8.post_attention_layernorm",
59
+ "model.layers.9.input_layernorm",
60
+ "model.layers.9.mlp.gate",
61
+ "model.layers.9.post_attention_layernorm",
62
+ "model.layers.10.input_layernorm",
63
+ "model.layers.10.mlp.gate",
64
+ "model.layers.10.post_attention_layernorm",
65
+ "model.layers.11.input_layernorm",
66
+ "model.layers.11.mlp.gate",
67
+ "model.layers.11.post_attention_layernorm",
68
+ "model.layers.12.input_layernorm",
69
+ "model.layers.12.mlp.gate",
70
+ "model.layers.12.post_attention_layernorm",
71
+ "model.layers.13.input_layernorm",
72
+ "model.layers.13.mlp.gate",
73
+ "model.layers.13.post_attention_layernorm",
74
+ "model.layers.14.input_layernorm",
75
+ "model.layers.14.mlp.gate",
76
+ "model.layers.14.post_attention_layernorm",
77
+ "model.layers.15.input_layernorm",
78
+ "model.layers.15.mlp.gate",
79
+ "model.layers.15.post_attention_layernorm",
80
+ "model.layers.16.input_layernorm",
81
+ "model.layers.16.mlp.gate",
82
+ "model.layers.16.post_attention_layernorm",
83
+ "model.layers.17.input_layernorm",
84
+ "model.layers.17.mlp.gate",
85
+ "model.layers.17.post_attention_layernorm",
86
+ "model.layers.18.input_layernorm",
87
+ "model.layers.18.mlp.gate",
88
+ "model.layers.18.post_attention_layernorm",
89
+ "model.layers.19.input_layernorm",
90
+ "model.layers.19.mlp.gate",
91
+ "model.layers.19.post_attention_layernorm",
92
+ "model.layers.20.input_layernorm",
93
+ "model.layers.20.mlp.gate",
94
+ "model.layers.20.post_attention_layernorm",
95
+ "model.layers.21.input_layernorm",
96
+ "model.layers.21.mlp.gate",
97
+ "model.layers.21.post_attention_layernorm",
98
+ "model.layers.22.input_layernorm",
99
+ "model.layers.22.mlp.gate",
100
+ "model.layers.22.post_attention_layernorm",
101
+ "model.layers.23.input_layernorm",
102
+ "model.layers.23.mlp.gate",
103
+ "model.layers.23.post_attention_layernorm",
104
+ "model.layers.24.input_layernorm",
105
+ "model.layers.24.mlp.gate",
106
+ "model.layers.24.post_attention_layernorm",
107
+ "model.layers.25.input_layernorm",
108
+ "model.layers.25.mlp.gate",
109
+ "model.layers.25.post_attention_layernorm",
110
+ "model.layers.26.input_layernorm",
111
+ "model.layers.26.mlp.gate",
112
+ "model.layers.26.post_attention_layernorm",
113
+ "model.layers.27.input_layernorm",
114
+ "model.layers.27.mlp.gate",
115
+ "model.layers.27.post_attention_layernorm",
116
+ "model.layers.28.input_layernorm",
117
+ "model.layers.28.mlp.gate",
118
+ "model.layers.28.post_attention_layernorm",
119
+ "model.layers.29.input_layernorm",
120
+ "model.layers.29.mlp.gate",
121
+ "model.layers.29.post_attention_layernorm",
122
+ "model.layers.30.input_layernorm",
123
+ "model.layers.30.mlp.gate",
124
+ "model.layers.30.post_attention_layernorm",
125
+ "model.layers.31.input_layernorm",
126
+ "model.layers.31.mlp.gate",
127
+ "model.layers.31.post_attention_layernorm",
128
+ "model.layers.32.input_layernorm",
129
+ "model.layers.32.mlp.gate",
130
+ "model.layers.32.post_attention_layernorm",
131
+ "model.layers.33.input_layernorm",
132
+ "model.layers.33.mlp.gate",
133
+ "model.layers.33.post_attention_layernorm",
134
+ "model.layers.34.input_layernorm",
135
+ "model.layers.34.mlp.gate",
136
+ "model.layers.34.post_attention_layernorm",
137
+ "model.layers.35.input_layernorm",
138
+ "model.layers.35.mlp.gate",
139
+ "model.layers.35.post_attention_layernorm",
140
+ "model.layers.36.input_layernorm",
141
+ "model.layers.36.mlp.gate",
142
+ "model.layers.36.post_attention_layernorm",
143
+ "model.layers.37.input_layernorm",
144
+ "model.layers.37.mlp.gate",
145
+ "model.layers.37.post_attention_layernorm",
146
+ "model.layers.38.input_layernorm",
147
+ "model.layers.38.mlp.gate",
148
+ "model.layers.38.post_attention_layernorm",
149
+ "model.layers.39.input_layernorm",
150
+ "model.layers.39.mlp.gate",
151
+ "model.layers.39.post_attention_layernorm",
152
+ "model.layers.40.input_layernorm",
153
+ "model.layers.40.mlp.gate",
154
+ "model.layers.40.post_attention_layernorm",
155
+ "model.layers.41.input_layernorm",
156
+ "model.layers.41.mlp.gate",
157
+ "model.layers.41.post_attention_layernorm",
158
+ "model.layers.42.input_layernorm",
159
+ "model.layers.42.mlp.gate",
160
+ "model.layers.42.post_attention_layernorm",
161
+ "model.layers.43.input_layernorm",
162
+ "model.layers.43.mlp.gate",
163
+ "model.layers.43.post_attention_layernorm",
164
+ "model.layers.44.input_layernorm",
165
+ "model.layers.44.mlp.gate",
166
+ "model.layers.44.post_attention_layernorm",
167
+ "model.layers.45.input_layernorm",
168
+ "model.layers.45.mlp.gate",
169
+ "model.layers.45.post_attention_layernorm",
170
+ "model.layers.46.input_layernorm",
171
+ "model.layers.46.mlp.gate",
172
+ "model.layers.46.post_attention_layernorm",
173
+ "model.layers.47.input_layernorm",
174
+ "model.layers.47.mlp.gate",
175
+ "model.layers.47.post_attention_layernorm",
176
+ "model.layers.48.input_layernorm",
177
+ "model.layers.48.mlp.gate",
178
+ "model.layers.48.post_attention_layernorm",
179
+ "model.layers.49.input_layernorm",
180
+ "model.layers.49.mlp.gate",
181
+ "model.layers.49.post_attention_layernorm",
182
+ "model.layers.50.input_layernorm",
183
+ "model.layers.50.mlp.gate",
184
+ "model.layers.50.post_attention_layernorm",
185
+ "model.layers.51.input_layernorm",
186
+ "model.layers.51.mlp.gate",
187
+ "model.layers.51.post_attention_layernorm",
188
+ "model.layers.52.input_layernorm",
189
+ "model.layers.52.mlp.gate",
190
+ "model.layers.52.post_attention_layernorm",
191
+ "model.layers.53.input_layernorm",
192
+ "model.layers.53.mlp.gate",
193
+ "model.layers.53.post_attention_layernorm",
194
+ "model.layers.54.input_layernorm",
195
+ "model.layers.54.mlp.gate",
196
+ "model.layers.54.post_attention_layernorm",
197
+ "model.layers.55.input_layernorm",
198
+ "model.layers.55.mlp.gate",
199
+ "model.layers.55.post_attention_layernorm",
200
+ "model.layers.56.input_layernorm",
201
+ "model.layers.56.mlp.gate",
202
+ "model.layers.56.post_attention_layernorm",
203
+ "model.layers.57.input_layernorm",
204
+ "model.layers.57.mlp.gate",
205
+ "model.layers.57.post_attention_layernorm",
206
+ "model.layers.58.input_layernorm",
207
+ "model.layers.58.mlp.gate",
208
+ "model.layers.58.post_attention_layernorm",
209
+ "model.layers.59.input_layernorm",
210
+ "model.layers.59.mlp.gate",
211
+ "model.layers.59.post_attention_layernorm",
212
+ "model.layers.60.input_layernorm",
213
+ "model.layers.60.mlp.gate",
214
+ "model.layers.60.post_attention_layernorm",
215
+ "model.layers.61.input_layernorm",
216
+ "model.layers.61.mlp.gate",
217
+ "model.layers.61.post_attention_layernorm"
218
+ ],
219
+ "quant_method": "fp8",
220
+ "weight_block_size": [
221
+ 128,
222
+ 128
223
+ ]
224
+ },
225
+ "rms_norm_eps": 1e-06,
226
+ "rope_scaling": null,
227
+ "rope_theta": 10000000,
228
+ "router_aux_loss_coef": 0.0,
229
+ "shared_expert_intermediate_size": 0,
230
+ "sliding_window": null,
231
+ "tie_word_embeddings": false,
232
+ "torch_dtype": "bfloat16",
233
+ "transformers_version": "4.52.4",
234
+ "use_cache": true,
235
+ "use_qk_norm": true,
236
+ "use_sliding_window": false,
237
+ "vocab_size": 151936
238
+ }
generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pad_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "repetition_penalty": 1.05,
9
+ "temperature": 0.7,
10
+ "top_p": 0.8,
11
+ "top_k": 20
12
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00003-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08c86cf377a571560bf36f73c2bab548557d2c5336b014a30d4ace255289b44f
3
+ size 9997346856
model-00006-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8688e8d26a7ca9e3dbef62a7dae247d85014978d558e91e7bba8d7a611548bc7
3
+ size 9997346848
model-00007-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bf602baa71a1e711362e06057dc5b01ce08e11c03bd70596f2fa57b783cf9ba
3
+ size 9997347040
model-00008-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e3583fc9ac98459f995ce00de1e0f20f69e5825c879604fef262dae76f2de8d
3
+ size 9989899528
model-00009-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a0054be18235f5a680668868a8b7839da83575148b69ab8de6c671eba1e9671
3
+ size 9997348112
model-00012-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41897c33c3ffea539e39796f5b606d119ad6e9ec72d80b3dac0c49e4970e69dd
3
+ size 9989874840
model-00013-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e05692ebfe61aa8a7d7479f1ee5df8e416a4ae21576074afddaa2d8a545c779c
3
+ size 9997348112
model-00014-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81f310ebd39dbc0280c6f920cfb4ed1896aec85b39781b0d8df84f82cf53a166
3
+ size 9997348360
model-00017-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d69954e8e319b404e230c9d76cc9c68ed304d91ee994406e2259993e3e343b22
3
+ size 9997348240
model-00018-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f87ae0f24a92020b0d2ad5c962d1ce4ae9a859bfdac383f2cbd59ef7185059c
3
+ size 9989899840
model-00019-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:669d3cfd31b76fcd4556e0afdff75ed512a3c592d88905fadcf0a46ac19a703b
3
+ size 9997348088
model-00021-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f9b50185c94eb55fb0aaae147febfebe0fc8e97aeafa437372b3363e8331d56
3
+ size 9997348400
model-00022-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8f58ac8051a00a8b4f07a0c6a6f28e714c37715f072bcb2bc2c1f9a8231c20f
3
+ size 9989899664
model-00023-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee024a2cb8ce6a45274960c2a61279de1aad85834a6a3ff207c832d229cabc6f
3
+ size 9997348112
model-00024-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b657832f896619c326270bccd232cfc5d95a7ea328a6bf750559c19dcc62aee
3
+ size 9997348312
model-00025-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b003320079404a5ef55cb253611f8cfc097802e601447848473dc13996571af7
3
+ size 9989899760
model-00026-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c86ed89803f3ef7e89b0f81c299026a33d66ce7de1ad15e536fc6edcafe6ef2b
3
+ size 9997348104
model-00027-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ce3adf6ead7f0273c6cd74fa77095a5d6074ff828868fc4ceeb20810db1da2b
3
+ size 9997348200
model-00028-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:668628f53a82dceaced90396a7919debbf19befbc94efacee5fc65a79047c1f1
3
+ size 9928156904
model-00029-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3566cebf32e22c5e48be0b94605314a49caeb0f6356fe4a2a318387b52b287f
3
+ size 9996167872
model-00030-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf1d968c1b5736a96bc80c0e434fd0f3669434f15dc3e183cdbdc208a6e2ad5a
3
+ size 9997348112
model-00031-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1f4796d7f92d7cf78b7ea54c009a99fe5b64e2a6368a676ab3cb7d09d34c2ac
3
+ size 9997348368
model-00032-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b728be17d6855173188b5c94866afb39a2ff5cf95c09d10cdec7270d58a5bd8
3
+ size 9989899696
model-00033-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f1b10f22d419dfcc4fde4ad34b699015c3b6f4fdc125cf93e340585b5b2d194
3
+ size 9997348112
model-00034-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96649317f0644ac78f561ed0d9dee30a8e7b9f3bea2e37785dadebd679ff1f25
3
+ size 9997348256
model-00036-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37e5b2c17e702d17a11aed1a2123ef3a0fc04536fbe2700df00490b980f27f83
3
+ size 9997348104
model-00037-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:640b809ee36dc6c14390623b6e06e694fc803e3aaa0275eb2d5419f5427a2789
3
+ size 9997348144
model-00038-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b82a4474c3aef95967ac69178c4179baa7b5f562974c5e6c5a677c4ffecdad88
3
+ size 9997348400
model-00039-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67862f44ff6b1456482a5eaab52b52b848db5fe20eba2298c2994e8b63de421a
3
+ size 9989899656
model-00040-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dca78652b591dbdbec2e5a36d2667e33de181507dc6a5c07cf037b3cbdea9b93
3
+ size 9997348112
model-00041-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5ceb5403e7debb467bad47d887a070e2776d1cde7ffa8f604c2927f040f3626
3
+ size 9997348320
model-00042-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57df19df663cceeb6ee3e300979c2c58a0f735ed78e838248ea54909e33940f8
3
+ size 9989899744
model-00043-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24e2251ad9431ae9d8e234f99dab905a1dd7b2cef10eceba1f07aa4a53aa067f
3
+ size 9997348104
model-00045-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6d1bd3e471f9bf33316fa7eded3634b5301f73845a0ba91e4ed1dcebc40d952
3
+ size 9989899904
model-00046-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9bdd358551b4650ccd96674629b160af8efa34bb1336c4de5d7faacf2042ba7
3
+ size 9997348064
model-00047-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf52a7cd13e914f6fbaa0ff719b8078b9bf7c0ad658b0ceafec44c2ee7eeb74b
3
+ size 9997348112
model-00048-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb032e0432770a4a452df9d765ca005c806a0c91809a226ba5eb0bb75d543957
3
+ size 9997348384
model-00049-of-00049.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:df68b21e7f8b38b8972b4813de0bfbf53c73074bf71f8b1e6064287df22aa26d
3
+ size 2496259752
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
qwen3coder_tool_parser.py ADDED
@@ -0,0 +1,689 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ import ast
4
+ import json
5
+ import uuid
6
+ from collections.abc import Sequence
7
+ from typing import Any, List, Optional, Union
8
+
9
+ import regex as re
10
+
11
+ from vllm.entrypoints.openai.protocol import (ChatCompletionRequest,
12
+ ChatCompletionToolsParam,
13
+ DeltaFunctionCall, DeltaMessage,
14
+ DeltaToolCall,
15
+ ExtractedToolCallInformation,
16
+ FunctionCall, ToolCall)
17
+ from vllm.entrypoints.openai.tool_parsers.abstract_tool_parser import (
18
+ ToolParser, ToolParserManager)
19
+ from vllm.logger import init_logger
20
+ from vllm.transformers_utils.tokenizer import AnyTokenizer
21
+
22
+ logger = init_logger(__name__)
23
+
24
+
25
+ @ToolParserManager.register_module("qwen3_coder")
26
+ class Qwen3CoderToolParser(ToolParser):
27
+
28
+ def __init__(self, tokenizer: AnyTokenizer):
29
+ super().__init__(tokenizer)
30
+
31
+ self.current_tool_name_sent: bool = False
32
+ self.prev_tool_call_arr: list[dict] = []
33
+ self.current_tool_id: int = -1
34
+ self.streamed_args_for_tool: list[str] = []
35
+
36
+ # Sentinel tokens for streaming mode
37
+ self.tool_call_start_token: str = "<tool_call>"
38
+ self.tool_call_end_token: str = "</tool_call>"
39
+ self.tool_call_prefix: str = "<function="
40
+ self.function_end_token: str = "</function>"
41
+ self.parameter_prefix: str = "<parameter="
42
+ self.parameter_end_token: str = "</parameter>"
43
+ self.is_tool_call_started: bool = False
44
+ self.failed_count: int = 0
45
+
46
+ # Enhanced streaming state - reset for each new message
47
+ self._reset_streaming_state()
48
+
49
+ # Regex patterns
50
+ self.tool_call_complete_regex = re.compile(
51
+ r"<tool_call>(.*?)</tool_call>", re.DOTALL)
52
+ self.tool_call_regex = re.compile(
53
+ r"<tool_call>(.*?)</tool_call>|<tool_call>(.*?)$", re.DOTALL)
54
+ self.tool_call_function_regex = re.compile(
55
+ r"<function=(.*?)</function>|<function=(.*)$", re.DOTALL)
56
+ self.tool_call_parameter_regex = re.compile(
57
+ r"<parameter=(.*?)(?:</parameter>|(?=<parameter=)|(?=</function>)|$)",
58
+ re.DOTALL)
59
+
60
+ if not self.model_tokenizer:
61
+ raise ValueError(
62
+ "The model tokenizer must be passed to the ToolParser "
63
+ "constructor during construction.")
64
+
65
+ self.tool_call_start_token_id = self.vocab.get(
66
+ self.tool_call_start_token)
67
+ self.tool_call_end_token_id = self.vocab.get(self.tool_call_end_token)
68
+
69
+ if self.tool_call_start_token_id is None or self.tool_call_end_token_id is None:
70
+ raise RuntimeError(
71
+ "Qwen3 XML Tool parser could not locate tool call start/end "
72
+ "tokens in the tokenizer!")
73
+
74
+ logger.info(
75
+ f"vLLM Successfully import tool parser {self.__class__.__name__} !"
76
+ )
77
+
78
+ def _generate_tool_call_id(self) -> str:
79
+ """Generate a unique tool call ID."""
80
+ return f"call_{uuid.uuid4().hex[:24]}"
81
+
82
+ def _reset_streaming_state(self):
83
+ """Reset all streaming state."""
84
+ self.current_tool_index = 0
85
+ self.is_tool_call_started = False
86
+ self.header_sent = False
87
+ self.current_tool_id = None
88
+ self.current_function_name = None
89
+ self.current_param_name = None
90
+ self.current_param_value = ""
91
+ self.param_count = 0
92
+ self.in_param = False
93
+ self.in_function = False
94
+ self.accumulated_text = ""
95
+ self.json_started = False
96
+ self.json_closed = False
97
+ # Store accumulated parameters for type conversion
98
+ self.accumulated_params = {}
99
+ self.streaming_request = None
100
+
101
+ def _get_arguments_config(
102
+ self, func_name: str,
103
+ tools: Optional[list[ChatCompletionToolsParam]]) -> dict:
104
+ """Extract argument configuration for a function."""
105
+ if tools is None:
106
+ return {}
107
+ for config in tools:
108
+ if not hasattr(config, "type") or not (hasattr(
109
+ config, "function") and hasattr(config.function, "name")):
110
+ continue
111
+ if config.type == "function" and config.function.name == func_name:
112
+ if not hasattr(config.function, "parameters"):
113
+ return {}
114
+ params = config.function.parameters
115
+ if isinstance(params, dict) and "properties" in params:
116
+ return params["properties"]
117
+ elif isinstance(params, dict):
118
+ return params
119
+ else:
120
+ return {}
121
+ logger.warning(f"Tool '{func_name}' is not defined in the tools list.")
122
+ return {}
123
+
124
+ def _convert_param_value(self, param_value: str, param_name: str,
125
+ param_config: dict, func_name: str) -> Any:
126
+ """Convert parameter value based on its type in the schema."""
127
+ # Handle null value for any type
128
+ if param_value.lower() == "null":
129
+ return None
130
+
131
+ if param_name not in param_config:
132
+ if param_config != {}:
133
+ logger.warning(
134
+ f"Parsed parameter '{param_name}' is not defined in the tool "
135
+ f"parameters for tool '{func_name}', directly returning the string value."
136
+ )
137
+ return param_value
138
+
139
+ if isinstance(param_config[param_name],
140
+ dict) and "type" in param_config[param_name]:
141
+ param_type = str(param_config[param_name]["type"]).strip().lower()
142
+ else:
143
+ param_type = "string"
144
+ if param_type in ["string", "str", "text", "varchar", "char", "enum"]:
145
+ return param_value
146
+ elif param_type.startswith("int") or param_type.startswith(
147
+ "uint") or param_type.startswith(
148
+ "long") or param_type.startswith(
149
+ "short") or param_type.startswith("unsigned"):
150
+ try:
151
+ param_value = int(param_value)
152
+ except:
153
+ logger.warning(
154
+ f"Parsed value '{param_value}' of parameter '{param_name}' is not an integer in tool "
155
+ f"'{func_name}', degenerating to string.")
156
+ return param_value
157
+ elif param_type.startswith("num") or param_type.startswith("float"):
158
+ try:
159
+ float_param_value = float(param_value)
160
+ param_value = float_param_value if float_param_value - int(
161
+ float_param_value) != 0 else int(float_param_value)
162
+ except:
163
+ logger.warning(
164
+ f"Parsed value '{param_value}' of parameter '{param_name}' is not a float in tool "
165
+ f"'{func_name}', degenerating to string.")
166
+ return param_value
167
+ elif param_type in ["boolean", "bool", "binary"]:
168
+ param_value = param_value.lower()
169
+ if param_value not in ["true", "false"]:
170
+ logger.warning(
171
+ f"Parsed value '{param_value}' of parameter '{param_name}' is not a boolean (`true` of `false`) in tool '{func_name}', degenerating to false."
172
+ )
173
+ return param_value == "true"
174
+ else:
175
+ if param_type in ["object", "array", "arr"
176
+ ] or param_type.startswith(
177
+ "dict") or param_type.startswith("list"):
178
+ try:
179
+ param_value = json.loads(param_value)
180
+ return param_value
181
+ except:
182
+ logger.warning(
183
+ f"Parsed value '{param_value}' of parameter '{param_name}' cannot be parsed with json.loads in tool "
184
+ f"'{func_name}', will try other methods to parse it.")
185
+ try:
186
+ param_value = ast.literal_eval(param_value) # safer
187
+ except:
188
+ logger.warning(
189
+ f"Parsed value '{param_value}' of parameter '{param_name}' cannot be converted via Python `ast.literal_eval()` in tool '{func_name}', degenerating to string."
190
+ )
191
+ return param_value
192
+
193
+ def _parse_xml_function_call(
194
+ self, function_call_str: str,
195
+ tools: Optional[list[ChatCompletionToolsParam]]
196
+ ) -> Optional[ToolCall]:
197
+
198
+ # Extract function name
199
+ end_index = function_call_str.index(">")
200
+ function_name = function_call_str[:end_index]
201
+ param_config = self._get_arguments_config(function_name, tools)
202
+ parameters = function_call_str[end_index + 1:]
203
+ param_dict = {}
204
+ for match_text in self.tool_call_parameter_regex.findall(parameters):
205
+ idx = match_text.index(">")
206
+ param_name = match_text[:idx]
207
+ param_value = str(match_text[idx + 1:])
208
+ # Remove prefix and trailing \n
209
+ if param_value.startswith("\n"):
210
+ param_value = param_value[1:]
211
+ if param_value.endswith("\n"):
212
+ param_value = param_value[:-1]
213
+
214
+ param_dict[param_name] = self._convert_param_value(
215
+ param_value, param_name, param_config, function_name)
216
+ return ToolCall(
217
+ type="function",
218
+ function=FunctionCall(name=function_name,
219
+ arguments=json.dumps(param_dict,
220
+ ensure_ascii=False)),
221
+ )
222
+
223
+ def _get_function_calls(self, model_output: str) -> List[str]:
224
+ # Find all tool calls
225
+ matched_ranges = self.tool_call_regex.findall(model_output)
226
+ raw_tool_calls = [
227
+ match[0] if match[0] else match[1] for match in matched_ranges
228
+ ]
229
+
230
+ # Back-off strategy if no tool_call tags found
231
+ if len(raw_tool_calls) == 0:
232
+ raw_tool_calls = [model_output]
233
+
234
+ raw_function_calls = []
235
+ for tool_call in raw_tool_calls:
236
+ raw_function_calls.extend(
237
+ self.tool_call_function_regex.findall(tool_call))
238
+
239
+ function_calls = [
240
+ match[0] if match[0] else match[1] for match in raw_function_calls
241
+ ]
242
+ return function_calls
243
+
244
+ def extract_tool_calls(
245
+ self,
246
+ model_output: str,
247
+ request: ChatCompletionRequest,
248
+ ) -> ExtractedToolCallInformation:
249
+ # Quick check to avoid unnecessary processing
250
+ if self.tool_call_prefix not in model_output:
251
+ return ExtractedToolCallInformation(tools_called=False,
252
+ tool_calls=[],
253
+ content=model_output)
254
+
255
+ try:
256
+ function_calls = self._get_function_calls(model_output)
257
+ if len(function_calls) == 0:
258
+ return ExtractedToolCallInformation(tools_called=False,
259
+ tool_calls=[],
260
+ content=model_output)
261
+
262
+ tool_calls = [
263
+ self._parse_xml_function_call(function_call_str, request.tools)
264
+ for function_call_str in function_calls
265
+ ]
266
+
267
+ # Populate prev_tool_call_arr for serving layer to set finish_reason
268
+ self.prev_tool_call_arr.clear() # Clear previous calls
269
+ for tool_call in tool_calls:
270
+ if tool_call:
271
+ self.prev_tool_call_arr.append({
272
+ "name":
273
+ tool_call.function.name,
274
+ "arguments":
275
+ tool_call.function.arguments,
276
+ })
277
+
278
+ # Extract content before tool calls
279
+ content_index = model_output.find(self.tool_call_start_token)
280
+ content_index = content_index if content_index >= 0 else model_output.find(
281
+ self.tool_call_prefix)
282
+ content = model_output[:content_index] # .rstrip()
283
+
284
+ return ExtractedToolCallInformation(
285
+ tools_called=(len(tool_calls) > 0),
286
+ tool_calls=tool_calls,
287
+ content=content if content else None,
288
+ )
289
+
290
+ except Exception:
291
+ logger.exception("Error in extracting tool call from response.")
292
+ return ExtractedToolCallInformation(tools_called=False,
293
+ tool_calls=[],
294
+ content=model_output)
295
+
296
+ def extract_tool_calls_streaming(
297
+ self,
298
+ previous_text: str,
299
+ current_text: str,
300
+ delta_text: str,
301
+ previous_token_ids: Sequence[int],
302
+ current_token_ids: Sequence[int],
303
+ delta_token_ids: Sequence[int],
304
+ request: ChatCompletionRequest,
305
+ ) -> Union[DeltaMessage, None]:
306
+ # Store request for type conversion
307
+ if not previous_text:
308
+ self._reset_streaming_state()
309
+ self.streaming_request = request
310
+
311
+ # If no delta text, return None unless it's an EOS token after tool calls
312
+ if not delta_text:
313
+ # Check if this is an EOS token after all tool calls are complete
314
+ # We check for tool calls in the text even if is_tool_call_started is False
315
+ # because it might have been reset after processing all tools
316
+ if delta_token_ids and self.tool_call_end_token_id not in delta_token_ids:
317
+ # Count complete tool calls
318
+ complete_calls = len(
319
+ self.tool_call_complete_regex.findall(current_text))
320
+
321
+ # If we have completed tool calls and populated prev_tool_call_arr
322
+ if complete_calls > 0 and len(self.prev_tool_call_arr) > 0:
323
+ # Check if all tool calls are closed
324
+ open_calls = current_text.count(
325
+ self.tool_call_start_token) - current_text.count(
326
+ self.tool_call_end_token)
327
+ if open_calls == 0:
328
+ # Return empty delta message to allow finish_reason processing
329
+ return DeltaMessage(content="")
330
+ elif not self.is_tool_call_started and current_text:
331
+ # This is a regular content response that's now complete
332
+ return DeltaMessage(content="")
333
+ return None
334
+
335
+ # Update accumulated text
336
+ self.accumulated_text = current_text
337
+
338
+ # Check if we need to advance to next tool
339
+ if self.json_closed and not self.in_function:
340
+ # Check if this tool call has ended
341
+ tool_ends = current_text.count(self.tool_call_end_token)
342
+ if tool_ends > self.current_tool_index:
343
+ # This tool has ended, advance to next
344
+ self.current_tool_index += 1
345
+ self.header_sent = False
346
+ self.param_count = 0
347
+ self.json_started = False
348
+ self.json_closed = False
349
+ self.accumulated_params = {}
350
+
351
+ # Check if there are more tool calls
352
+ tool_starts = current_text.count(self.tool_call_start_token)
353
+ if self.current_tool_index >= tool_starts:
354
+ # No more tool calls
355
+ self.is_tool_call_started = False
356
+ # Continue processing next tool
357
+ return None
358
+
359
+ # Handle normal content before tool calls
360
+ if not self.is_tool_call_started:
361
+ # Check if tool call is starting
362
+ if self.tool_call_start_token_id in delta_token_ids or self.tool_call_start_token in delta_text:
363
+ self.is_tool_call_started = True
364
+ # Return any content before the tool call
365
+ if self.tool_call_start_token in delta_text:
366
+ content_before = delta_text[:delta_text.index(
367
+ self.tool_call_start_token)]
368
+ if content_before:
369
+ return DeltaMessage(content=content_before)
370
+ return None
371
+ else:
372
+ # Check if we're between tool calls - skip whitespace
373
+ if current_text.rstrip().endswith(self.tool_call_end_token):
374
+ # We just ended a tool call, skip whitespace
375
+ if delta_text.strip() == "":
376
+ return None
377
+ # Normal content, no tool call
378
+ return DeltaMessage(content=delta_text)
379
+
380
+ # Check if we're between tool calls (waiting for next one)
381
+ # Count tool calls we've seen vs processed
382
+ tool_starts_count = current_text.count(self.tool_call_start_token)
383
+ if self.current_tool_index >= tool_starts_count:
384
+ # We're past all tool calls, shouldn't be here
385
+ return None
386
+
387
+ # We're in a tool call, find the current tool call portion
388
+ # Need to find the correct tool call based on current_tool_index
389
+ tool_starts = []
390
+ idx = 0
391
+ while True:
392
+ idx = current_text.find(self.tool_call_start_token, idx)
393
+ if idx == -1:
394
+ break
395
+ tool_starts.append(idx)
396
+ idx += len(self.tool_call_start_token)
397
+
398
+ if self.current_tool_index >= len(tool_starts):
399
+ # No more tool calls to process yet
400
+ return None
401
+
402
+ tool_start_idx = tool_starts[self.current_tool_index]
403
+ # Find where this tool call ends (or current position if not ended yet)
404
+ tool_end_idx = current_text.find(self.tool_call_end_token,
405
+ tool_start_idx)
406
+ if tool_end_idx == -1:
407
+ tool_text = current_text[tool_start_idx:]
408
+ else:
409
+ tool_text = current_text[tool_start_idx:tool_end_idx +
410
+ len(self.tool_call_end_token)]
411
+
412
+ # Looking for function header
413
+ if not self.header_sent:
414
+ if self.tool_call_prefix in tool_text:
415
+ func_start = tool_text.find(self.tool_call_prefix) + len(
416
+ self.tool_call_prefix)
417
+ func_end = tool_text.find(">", func_start)
418
+
419
+ if func_end != -1:
420
+ # Found complete function name
421
+ self.current_function_name = tool_text[func_start:func_end]
422
+ self.current_tool_id = self._generate_tool_call_id()
423
+ self.header_sent = True
424
+ self.in_function = True
425
+
426
+ # IMPORTANT: Add to prev_tool_call_arr immediately when we detect a tool call
427
+ # This ensures finish_reason="tool_calls" even if parsing isn't complete
428
+ already_added = any(
429
+ tool.get("name") == self.current_function_name
430
+ for tool in self.prev_tool_call_arr)
431
+ if not already_added:
432
+ self.prev_tool_call_arr.append({
433
+ "name": self.current_function_name,
434
+ "arguments":
435
+ "{}", # Placeholder, will be updated later
436
+ })
437
+
438
+ # Send header with function info
439
+ return DeltaMessage(tool_calls=[
440
+ DeltaToolCall(
441
+ index=self.current_tool_index,
442
+ id=self.current_tool_id,
443
+ function=DeltaFunctionCall(
444
+ name=self.current_function_name, arguments=""),
445
+ type="function",
446
+ )
447
+ ])
448
+ return None
449
+
450
+ # We've sent header, now handle function body
451
+ if self.in_function:
452
+ # Send opening brace if not sent yet
453
+ if not self.json_started and self.parameter_prefix not in delta_text:
454
+ self.json_started = True
455
+ return DeltaMessage(tool_calls=[
456
+ DeltaToolCall(
457
+ index=self.current_tool_index,
458
+ function=DeltaFunctionCall(arguments="{"),
459
+ )
460
+ ])
461
+
462
+ # Make sure json_started is set if we're processing parameters
463
+ if not self.json_started:
464
+ self.json_started = True
465
+
466
+ # Check for function end in accumulated text
467
+ if not self.json_closed and self.function_end_token in tool_text:
468
+ # Close JSON
469
+ self.json_closed = True
470
+
471
+ # Extract the complete tool call to update prev_tool_call_arr with final arguments
472
+ # Find the function content
473
+ func_start = tool_text.find(self.tool_call_prefix) + len(
474
+ self.tool_call_prefix)
475
+ func_content_end = tool_text.find(self.function_end_token,
476
+ func_start)
477
+ if func_content_end != -1:
478
+ func_content = tool_text[func_start:func_content_end]
479
+ # Parse to get the complete arguments
480
+ try:
481
+ parsed_tool = self._parse_xml_function_call(
482
+ func_content, self.streaming_request.tools
483
+ if self.streaming_request else None)
484
+ if parsed_tool:
485
+ # Update existing entry in prev_tool_call_arr with complete arguments
486
+ for i, tool in enumerate(self.prev_tool_call_arr):
487
+ if tool.get(
488
+ "name") == parsed_tool.function.name:
489
+ self.prev_tool_call_arr[i][
490
+ "arguments"] = parsed_tool.function.arguments
491
+ break
492
+ except Exception:
493
+ pass # Ignore parsing errors during streaming
494
+
495
+ result = DeltaMessage(tool_calls=[
496
+ DeltaToolCall(
497
+ index=self.current_tool_index,
498
+ function=DeltaFunctionCall(arguments="}"),
499
+ )
500
+ ])
501
+
502
+ # Reset state for next tool
503
+ self.in_function = False
504
+ self.json_closed = True
505
+ self.accumulated_params = {}
506
+
507
+ return result
508
+
509
+ # Look for parameters
510
+ # Find all parameter starts
511
+ param_starts = []
512
+ idx = 0
513
+ while True:
514
+ idx = tool_text.find(self.parameter_prefix, idx)
515
+ if idx == -1:
516
+ break
517
+ param_starts.append(idx)
518
+ idx += len(self.parameter_prefix)
519
+
520
+ # Check if we should start a new parameter
521
+ if not self.in_param and self.param_count < len(param_starts):
522
+
523
+ if len(param_starts) > self.param_count:
524
+ # Process the next parameter
525
+ param_idx = param_starts[self.param_count]
526
+ param_start = param_idx + len(self.parameter_prefix)
527
+ remaining = tool_text[param_start:]
528
+
529
+ if ">" in remaining:
530
+ # We have the complete parameter name
531
+ name_end = remaining.find(">")
532
+ self.current_param_name = remaining[:name_end]
533
+
534
+ # Find the parameter value
535
+ value_start = param_start + name_end + 1
536
+ value_text = tool_text[value_start:]
537
+ if value_text.startswith("\n"):
538
+ value_text = value_text[1:]
539
+
540
+ # Find where this parameter ends
541
+ param_end_idx = value_text.find(
542
+ self.parameter_end_token)
543
+ if param_end_idx == -1:
544
+ # No closing tag, look for next parameter or function end
545
+ next_param_idx = value_text.find(
546
+ self.parameter_prefix)
547
+ func_end_idx = value_text.find(
548
+ self.function_end_token)
549
+
550
+ if next_param_idx != -1 and (func_end_idx == -1
551
+ or next_param_idx
552
+ < func_end_idx):
553
+ param_end_idx = next_param_idx
554
+ elif func_end_idx != -1:
555
+ param_end_idx = func_end_idx
556
+ else:
557
+ # Neither found, check if tool call is complete
558
+ if self.tool_call_end_token in tool_text:
559
+ # Tool call is complete, so parameter must be complete too
560
+ # Use all remaining text before function end as value
561
+ param_end_idx = len(value_text)
562
+ else:
563
+ # Still streaming, wait for more content
564
+ return None
565
+
566
+ if param_end_idx != -1:
567
+ # Complete parameter found
568
+ param_value = value_text[:param_end_idx]
569
+ if param_value.endswith("\n"):
570
+ param_value = param_value[:-1]
571
+
572
+ # Store raw value for later processing
573
+ self.accumulated_params[
574
+ self.current_param_name] = param_value
575
+
576
+ # Get parameter configuration for type conversion
577
+ param_config = self._get_arguments_config(
578
+ self.current_function_name,
579
+ self.streaming_request.tools
580
+ if self.streaming_request else None)
581
+
582
+ # Convert the parameter value to the appropriate type
583
+ converted_value = self._convert_param_value(
584
+ param_value, self.current_param_name,
585
+ param_config, self.current_function_name)
586
+
587
+ # Build JSON fragment based on the converted type
588
+ # Use json.dumps to properly serialize the value
589
+ serialized_value = json.dumps(converted_value,
590
+ ensure_ascii=False)
591
+
592
+ if self.param_count == 0:
593
+ json_fragment = f'"{self.current_param_name}": {serialized_value}'
594
+ else:
595
+ json_fragment = f', "{self.current_param_name}": {serialized_value}'
596
+
597
+ self.param_count += 1
598
+
599
+ return DeltaMessage(tool_calls=[
600
+ DeltaToolCall(
601
+ index=self.current_tool_index,
602
+ function=DeltaFunctionCall(
603
+ arguments=json_fragment),
604
+ )
605
+ ])
606
+
607
+ # Continue parameter value - Not used in the current implementation
608
+ # since we process complete parameters above
609
+ if self.in_param:
610
+ if self.parameter_end_token in delta_text:
611
+ # End of parameter
612
+ end_idx = delta_text.find(self.parameter_end_token)
613
+ value_chunk = delta_text[:end_idx]
614
+
615
+ # Skip past > if at start
616
+ if not self.current_param_value and ">" in value_chunk:
617
+ gt_idx = value_chunk.find(">")
618
+ value_chunk = value_chunk[gt_idx + 1:]
619
+
620
+ if not self.current_param_value and value_chunk.startswith(
621
+ "\n"):
622
+ value_chunk = value_chunk[1:]
623
+
624
+ # Store complete value
625
+ full_value = self.current_param_value + value_chunk
626
+ self.accumulated_params[
627
+ self.current_param_name] = full_value
628
+
629
+ # Get parameter configuration for type conversion
630
+ param_config = self._get_arguments_config(
631
+ self.current_function_name,
632
+ self.streaming_request.tools
633
+ if self.streaming_request else None)
634
+
635
+ # Convert the parameter value to the appropriate type
636
+ converted_value = self._convert_param_value(
637
+ full_value, self.current_param_name, param_config,
638
+ self.current_function_name)
639
+
640
+ # Serialize the converted value
641
+ serialized_value = json.dumps(converted_value,
642
+ ensure_ascii=False)
643
+
644
+ # Since we've been streaming the quoted version, we need to close it properly
645
+ # This is complex - for now just complete the value
646
+ self.in_param = False
647
+ self.current_param_value = ""
648
+
649
+ # Just close the current parameter string
650
+ return DeltaMessage(tool_calls=[
651
+ DeltaToolCall(
652
+ index=self.current_tool_index,
653
+ function=DeltaFunctionCall(
654
+ arguments='"'), # Close the string quote
655
+ )
656
+ ])
657
+ else:
658
+ # Continue accumulating value
659
+ value_chunk = delta_text
660
+
661
+ # Handle first chunk after param name
662
+ if not self.current_param_value and ">" in value_chunk:
663
+ gt_idx = value_chunk.find(">")
664
+ value_chunk = value_chunk[gt_idx + 1:]
665
+
666
+ if not self.current_param_value and value_chunk.startswith(
667
+ "\n"):
668
+ value_chunk = value_chunk[1:]
669
+
670
+ if value_chunk:
671
+ # Stream the escaped delta
672
+ prev_escaped = json.dumps(
673
+ self.current_param_value, ensure_ascii=False
674
+ )[1:-1] if self.current_param_value else ""
675
+ self.current_param_value += value_chunk
676
+ full_escaped = json.dumps(self.current_param_value,
677
+ ensure_ascii=False)[1:-1]
678
+ delta_escaped = full_escaped[len(prev_escaped):]
679
+
680
+ if delta_escaped:
681
+ return DeltaMessage(tool_calls=[
682
+ DeltaToolCall(
683
+ index=self.current_tool_index,
684
+ function=DeltaFunctionCall(
685
+ arguments=delta_escaped),
686
+ )
687
+ ])
688
+
689
+ return None
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4
3
+ size 11422654
tokenizer_config.json ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "151643": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "151644": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "151645": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "151646": {
29
+ "content": "<|object_ref_start|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "151647": {
37
+ "content": "<|object_ref_end|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "151648": {
45
+ "content": "<|box_start|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "151649": {
53
+ "content": "<|box_end|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "151650": {
61
+ "content": "<|quad_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "151651": {
69
+ "content": "<|quad_end|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "151652": {
77
+ "content": "<|vision_start|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "151653": {
85
+ "content": "<|vision_end|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "151654": {
93
+ "content": "<|vision_pad|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "151655": {
101
+ "content": "<|image_pad|>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "151656": {
109
+ "content": "<|video_pad|>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "151657": {
117
+ "content": "<tool_call>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "151658": {
125
+ "content": "</tool_call>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "151659": {
133
+ "content": "<|fim_prefix|>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "151660": {
141
+ "content": "<|fim_middle|>",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "151661": {
149
+ "content": "<|fim_suffix|>",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "151662": {
157
+ "content": "<|fim_pad|>",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "151663": {
165
+ "content": "<|repo_name|>",
166
+ "lstrip": false,
167
+ "normalized": false,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "151664": {
173
+ "content": "<|file_sep|>",
174
+ "lstrip": false,
175
+ "normalized": false,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "151665": {
181
+ "content": "<tool_response>",
182
+ "lstrip": false,
183
+ "normalized": false,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "151666": {
189
+ "content": "</tool_response>",
190
+ "lstrip": false,
191
+ "normalized": false,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "151667": {
197
+ "content": "<think>",
198
+ "lstrip": false,
199
+ "normalized": false,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "151668": {
205
+ "content": "</think>",
206
+ "lstrip": false,
207
+ "normalized": false,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ }
212
+ },
213
+ "additional_special_tokens": [
214
+ "<|im_start|>",
215
+ "<|im_end|>",
216
+ "<|object_ref_start|>",
217
+ "<|object_ref_end|>",
218
+ "<|box_start|>",
219
+ "<|box_end|>",
220
+ "<|quad_start|>",
221
+ "<|quad_end|>",
222
+ "<|vision_start|>",
223
+ "<|vision_end|>",
224
+ "<|vision_pad|>",
225
+ "<|image_pad|>",
226
+ "<|video_pad|>"
227
+ ],
228
+ "bos_token": null,
229
+ "chat_template": "{% macro render_extra_keys(json_dict, handled_keys) %}\n {%- if json_dict is mapping %}\n {%- for json_key in json_dict if json_key not in handled_keys %}\n {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}\n {{- '\\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}\n {%- else %}\n {{-'\\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n{% endmacro %}\n\n{%- if messages[0][\"role\"] == \"system\" %}\n {%- set system_message = messages[0][\"content\"] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n{%- endif %}\n\n{%- if not tools is defined %}\n {%- set tools = [] %}\n{%- endif %}\n\n{%- if system_message is defined %}\n {{- \"<|im_start|>system\\n\" + system_message }}\n{%- else %}\n {%- if tools is iterable and tools | length > 0 %}\n {{- \"<|im_start|>system\\nYou are Qwen, a helpful AI assistant that can interact with a computer to solve tasks.\" }}\n {%- endif %}\n{%- endif %}\n{%- if tools is iterable and tools | length > 0 %}\n {{- \"\\n\\n# Tools\\n\\nYou have access to the following functions:\\n\\n\" }}\n {{- \"<tools>\" }}\n {%- for tool in tools %}\n {%- if tool.function is defined %}\n {%- set tool = tool.function %}\n {%- endif %}\n {{- \"\\n<function>\\n<name>\" ~ tool.name ~ \"</name>\" }}\n {%- if tool.description is defined %}\n {{- '\\n<description>' ~ (tool.description | trim) ~ '</description>' }}\n {%- endif %}\n {{- '\\n<parameters>' }}\n {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}\n {%- for param_name, param_fields in tool.parameters.properties|items %}\n {{- '\\n<parameter>' }}\n {{- '\\n<name>' ~ param_name ~ '</name>' }}\n {%- if param_fields.type is defined %}\n {{- '\\n<type>' ~ (param_fields.type | string) ~ '</type>' }}\n {%- endif %}\n {%- if param_fields.description is defined %}\n {{- '\\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}\n {%- endif %}\n {%- set handled_keys = ['name', 'type', 'description'] %}\n {{- render_extra_keys(param_fields, handled_keys) }}\n {{- '\\n</parameter>' }}\n {%- endfor %}\n {%- endif %}\n {% set handled_keys = ['type', 'properties'] %}\n {{- render_extra_keys(tool.parameters, handled_keys) }}\n {{- '\\n</parameters>' }}\n {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}\n {{- render_extra_keys(tool, handled_keys) }}\n {{- '\\n</function>' }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n{%- endif %}\n{%- if system_message is defined %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if tools is iterable and tools | length > 0 %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in loop_messages %}\n {%- if message.role == \"assistant\" and message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}\n {{- '\\n' + message.content | trim + '\\n' }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- if tool_call.arguments is defined %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"user\" or message.role == \"system\" or message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user\\n' }}\n {%- endif %}\n {{- '<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>\\n' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
230
+ "clean_up_tokenization_spaces": false,
231
+ "eos_token": "<|im_end|>",
232
+ "errors": "replace",
233
+ "model_max_length": 1048576,
234
+ "pad_token": "<|endoftext|>",
235
+ "split_special_tokens": false,
236
+ "tokenizer_class": "Qwen2Tokenizer",
237
+ "unk_token": null,
238
+ "add_bos_token": false
239
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff