xinference 1.8.1__py3-none-any.whl → 1.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xinference might be problematic. Click here for more details.
- xinference/_version.py +3 -3
- xinference/api/restful_api.py +2 -1
- xinference/core/model.py +5 -0
- xinference/core/supervisor.py +2 -3
- xinference/core/worker.py +3 -4
- xinference/deploy/local.py +5 -0
- xinference/deploy/worker.py +6 -0
- xinference/model/core.py +3 -0
- xinference/model/embedding/sentence_transformers/core.py +3 -4
- xinference/model/embedding/vllm/core.py +4 -3
- xinference/model/image/model_spec.json +69 -0
- xinference/model/image/stable_diffusion/core.py +22 -0
- xinference/model/llm/cache_manager.py +17 -3
- xinference/model/llm/harmony.py +245 -0
- xinference/model/llm/llm_family.json +293 -8
- xinference/model/llm/llm_family.py +1 -1
- xinference/model/llm/sglang/core.py +108 -5
- xinference/model/llm/transformers/core.py +15 -7
- xinference/model/llm/transformers/gemma3.py +1 -1
- xinference/model/llm/transformers/gpt_oss.py +91 -0
- xinference/model/llm/transformers/multimodal/core.py +1 -1
- xinference/model/llm/transformers/multimodal/gemma3.py +1 -1
- xinference/model/llm/transformers/multimodal/glm4_1v.py +2 -2
- xinference/model/llm/transformers/multimodal/ovis2.py +1 -1
- xinference/model/llm/transformers/multimodal/qwen-omni.py +7 -8
- xinference/model/llm/transformers/multimodal/qwen2_vl.py +9 -6
- xinference/model/llm/transformers/utils.py +1 -33
- xinference/model/llm/utils.py +61 -7
- xinference/model/llm/vllm/core.py +38 -8
- xinference/model/rerank/__init__.py +66 -23
- xinference/model/rerank/cache_manager.py +35 -0
- xinference/model/rerank/core.py +84 -339
- xinference/model/rerank/custom.py +33 -8
- xinference/model/rerank/model_spec.json +251 -212
- xinference/model/rerank/rerank_family.py +137 -0
- xinference/model/rerank/sentence_transformers/__init__.py +13 -0
- xinference/model/rerank/sentence_transformers/core.py +337 -0
- xinference/model/rerank/vllm/__init__.py +13 -0
- xinference/model/rerank/vllm/core.py +106 -0
- xinference/model/utils.py +109 -0
- xinference/types.py +2 -0
- xinference/ui/web/ui/build/asset-manifest.json +3 -3
- xinference/ui/web/ui/build/index.html +1 -1
- xinference/ui/web/ui/build/static/js/{main.b969199a.js → main.4918643a.js} +3 -3
- xinference/ui/web/ui/build/static/js/{main.b969199a.js.map → main.4918643a.js.map} +1 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/28012da921a51f1082549956d3ae82acd769a754b22afda9acddd98a4daf9ea4.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/475936ebe725eca62a6f52ce182c06a19b2cef4df9545a05ed0591ee0c539d43.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/89179f8f51887b9167721860a12412549ff04f78162e921a7b6aa6532646deb2.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/8b8cd408ccfbe115acef27ccfa5b233da8597131a2a5712add13e1e4d5d4504b.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/9dc5cfc67dd0617b0272aeef8651f1589b2155a4ff1fd72ad3166b217089b619.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/aee5aaba26f2b1e816a3ea9efa68bad8b95695a3d80adcfd8dd57a7bb17ac71a.json +1 -0
- {xinference-1.8.1.dist-info → xinference-1.9.0.dist-info}/METADATA +6 -1
- {xinference-1.8.1.dist-info → xinference-1.9.0.dist-info}/RECORD +58 -50
- xinference/ui/web/ui/node_modules/.cache/babel-loader/1409a96b9f9f9f5de99a89ab0f738f6da62b449521b0a8d3e4efcf7f5c23534d.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/43b889c3a8e2634092ade463d52481c7c5581c72ded8f23bc5f012ea0ef8cea5.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/5d47532fb42128280d87f57c8a0b02bc1930f7ef764aa7e90579247df18bba83.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/830882bb275468a969614824a9ab8983f874b4581f2eb625e9c66426cdc65e5b.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/9df08abcb5a7c1e48a4eb25c5d5f5d7253ea6854a4397e6d74d1fd75a14acda1.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/b99034986a06445701accc7a4914bb9320947435e8d4e15793392ca4f679316c.json +0 -1
- /xinference/ui/web/ui/build/static/js/{main.b969199a.js.LICENSE.txt → main.4918643a.js.LICENSE.txt} +0 -0
- {xinference-1.8.1.dist-info → xinference-1.9.0.dist-info}/WHEEL +0 -0
- {xinference-1.8.1.dist-info → xinference-1.9.0.dist-info}/entry_points.txt +0 -0
- {xinference-1.8.1.dist-info → xinference-1.9.0.dist-info}/licenses/LICENSE +0 -0
- {xinference-1.8.1.dist-info → xinference-1.9.0.dist-info}/top_level.txt +0 -0
|
@@ -5255,7 +5255,8 @@
|
|
|
5255
5255
|
],
|
|
5256
5256
|
"model_ability": [
|
|
5257
5257
|
"chat",
|
|
5258
|
-
"reasoning"
|
|
5258
|
+
"reasoning",
|
|
5259
|
+
"tools"
|
|
5259
5260
|
],
|
|
5260
5261
|
"model_description": "DeepSeek-R1, which incorporates cold-start data before RL. DeepSeek-R1 achieves performance comparable to OpenAI-o1 across math, code, and reasoning tasks.",
|
|
5261
5262
|
"model_specs": [
|
|
@@ -5300,7 +5301,7 @@
|
|
|
5300
5301
|
}
|
|
5301
5302
|
}
|
|
5302
5303
|
],
|
|
5303
|
-
"chat_template": "{
|
|
5304
|
+
"chat_template": "{%- if not add_generation_prompt is defined %}{%- set add_generation_prompt = false %}{%- endif %}{%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_last_user=false) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{%- set ns.system_prompt = ns.system_prompt + message['content'] %}{%- set ns.is_first_sp = false %}{%- else %}{%- set ns.system_prompt = ns.system_prompt + '\n\n' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{%- if tools is defined and tools is not none %}{%- set tool_ns = namespace(text='You are a helpful assistant with tool calling capabilities. ' + 'When a tool call is needed, you MUST use the following format to issue the call:\n' + '<|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>FUNCTION_NAME\n' + '```json\n{\"param1\": \"value1\", \"param2\": \"value2\"}\n```<|tool▁call▁end|><|tool▁calls▁end|>\n\n' + 'Make sure the JSON is valid.' + '## Tools\n\n### Function\n\nYou have the following functions available:\n\n') %}{%- for tool in tools %}{%- set tool_ns.text = tool_ns.text + '\n```json\n' + (tool | tojson) + '\n```\n' %}{%- endfor %}{%- if ns.system_prompt|length != 0 %}{%- set ns.system_prompt = ns.system_prompt + '\n\n' + tool_ns.text %}{%- else %}{%- set ns.system_prompt = tool_ns.text %}{%- endif %}{%- endif %}{{- bos_token }}{{- ns.system_prompt }}{%- set last_index = (messages|length - 1) %}{%- for message in messages %}{%- set content = message['content'] %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{%- set ns.is_first = false -%}{%- set ns.is_last_user = true -%}{%- if loop.index0 == last_index %}{{- '<|User|>' + content }}{%- else %}{{- '<|User|>' + content + '<|Assistant|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'assistant' %}{%- if '</think>' in content %}{%- set content = (content.split('</think>')|last) %}{%- endif %}{%- endif %}{%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}{%- set ns.is_last_user = false -%}{%- if ns.is_tool %}{{- '<|tool▁outputs▁end|>'}}{%- endif %}{%- set ns.is_first = false %}{%- set ns.is_tool = false -%}{%- set ns.is_output_first = true %}{%- for tool in message['tool_calls'] %}{%- set arguments = tool['function']['arguments'] %}{%- if arguments is not string %}{%- set arguments = arguments|tojson %}{%- endif %}{%- if not ns.is_first %}{%- if content is none %}{{- '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + arguments + '\n' + '```' + '<|tool▁call▁end|>'}}{%- else %}{{- content + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + arguments + '\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{- '\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + arguments + '\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- endfor %}{{- '<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none) %}{%- set ns.is_last_user = false -%}{%- if ns.is_tool %}{{- '<|tool▁outputs▁end|>' + content + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{{- content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_last_user = false -%}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{- '<|tool▁outputs▁begin|><|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{- '\n<|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{%- if ns.is_tool %}{{- '<|tool▁outputs▁end|>'}}{%- endif %}{%- if add_generation_prompt and not ns.is_tool %}{{- '<|Assistant|>'}}{%- endif %}",
|
|
5304
5305
|
"stop_token_ids": [
|
|
5305
5306
|
1
|
|
5306
5307
|
],
|
|
@@ -17314,7 +17315,8 @@
|
|
|
17314
17315
|
"zh"
|
|
17315
17316
|
],
|
|
17316
17317
|
"model_ability": [
|
|
17317
|
-
"chat"
|
|
17318
|
+
"chat",
|
|
17319
|
+
"tools"
|
|
17318
17320
|
],
|
|
17319
17321
|
"model_description": "We introduce the updated version of the Qwen3-235B-A22B non-thinking mode, named Qwen3-235B-A22B-Instruct-2507",
|
|
17320
17322
|
"model_specs": [
|
|
@@ -18540,7 +18542,8 @@
|
|
|
18540
18542
|
"zh"
|
|
18541
18543
|
],
|
|
18542
18544
|
"model_ability": [
|
|
18543
|
-
"chat"
|
|
18545
|
+
"chat",
|
|
18546
|
+
"tools"
|
|
18544
18547
|
],
|
|
18545
18548
|
"model_description": "we're announcing Qwen3-Coder, our most agentic code model to date",
|
|
18546
18549
|
"model_specs": [
|
|
@@ -19303,15 +19306,13 @@
|
|
|
19303
19306
|
}
|
|
19304
19307
|
}
|
|
19305
19308
|
],
|
|
19306
|
-
"chat_template": "{% macro
|
|
19309
|
+
"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 %}\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\\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 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",
|
|
19307
19310
|
"stop_token_ids": [
|
|
19308
19311
|
151643,
|
|
19309
|
-
151644,
|
|
19310
19312
|
151645
|
|
19311
19313
|
],
|
|
19312
19314
|
"stop": [
|
|
19313
19315
|
"<|endoftext|>",
|
|
19314
|
-
"<|im_start|>",
|
|
19315
19316
|
"<|im_end|>"
|
|
19316
19317
|
]
|
|
19317
19318
|
},
|
|
@@ -20697,7 +20698,7 @@
|
|
|
20697
20698
|
},
|
|
20698
20699
|
{
|
|
20699
20700
|
"version": 2,
|
|
20700
|
-
"context_length":
|
|
20701
|
+
"context_length": 131072,
|
|
20701
20702
|
"model_name": "glm-4.5",
|
|
20702
20703
|
"model_lang": [
|
|
20703
20704
|
"en",
|
|
@@ -20748,6 +20749,44 @@
|
|
|
20748
20749
|
}
|
|
20749
20750
|
}
|
|
20750
20751
|
},
|
|
20752
|
+
{
|
|
20753
|
+
"model_format": "gptq",
|
|
20754
|
+
"model_size_in_billions": 355,
|
|
20755
|
+
"activated_size_in_billions": 32,
|
|
20756
|
+
"model_src": {
|
|
20757
|
+
"huggingface": {
|
|
20758
|
+
"quantizations": [
|
|
20759
|
+
"Int4-Int8Mix"
|
|
20760
|
+
],
|
|
20761
|
+
"model_id": "QuantTrio/GLM-4.5-GPTQ-Int4-Int8Mix"
|
|
20762
|
+
},
|
|
20763
|
+
"modelscope": {
|
|
20764
|
+
"quantizations": [
|
|
20765
|
+
"Int4-Int8Mix"
|
|
20766
|
+
],
|
|
20767
|
+
"model_id": "tclf90/GLM-4.5-GPTQ-Int4-Int8Mix"
|
|
20768
|
+
}
|
|
20769
|
+
}
|
|
20770
|
+
},
|
|
20771
|
+
{
|
|
20772
|
+
"model_format": "awq",
|
|
20773
|
+
"model_size_in_billions": 355,
|
|
20774
|
+
"activated_size_in_billions": 32,
|
|
20775
|
+
"model_src": {
|
|
20776
|
+
"huggingface": {
|
|
20777
|
+
"quantizations": [
|
|
20778
|
+
"Int4"
|
|
20779
|
+
],
|
|
20780
|
+
"model_id": "QuantTrio/GLM-4.5-AWQ"
|
|
20781
|
+
},
|
|
20782
|
+
"modelscope": {
|
|
20783
|
+
"quantizations": [
|
|
20784
|
+
"Int4"
|
|
20785
|
+
],
|
|
20786
|
+
"model_id": "tclf90/GLM-4.5-AWQ"
|
|
20787
|
+
}
|
|
20788
|
+
}
|
|
20789
|
+
},
|
|
20751
20790
|
{
|
|
20752
20791
|
"model_format": "mlx",
|
|
20753
20792
|
"model_size_in_billions": 355,
|
|
@@ -20805,6 +20844,44 @@
|
|
|
20805
20844
|
}
|
|
20806
20845
|
}
|
|
20807
20846
|
},
|
|
20847
|
+
{
|
|
20848
|
+
"model_format": "gptq",
|
|
20849
|
+
"model_size_in_billions": 106,
|
|
20850
|
+
"activated_size_in_billions": 12,
|
|
20851
|
+
"model_src": {
|
|
20852
|
+
"huggingface": {
|
|
20853
|
+
"quantizations": [
|
|
20854
|
+
"Int4-Int8Mix"
|
|
20855
|
+
],
|
|
20856
|
+
"model_id": "QuantTrio/GLM-4.5-Air-GPTQ-Int4-Int8Mix"
|
|
20857
|
+
},
|
|
20858
|
+
"modelscope": {
|
|
20859
|
+
"quantizations": [
|
|
20860
|
+
"Int4-Int8Mix"
|
|
20861
|
+
],
|
|
20862
|
+
"model_id": "tclf90/GLM-4.5-Air-GPTQ-Int4-Int8Mix"
|
|
20863
|
+
}
|
|
20864
|
+
}
|
|
20865
|
+
},
|
|
20866
|
+
{
|
|
20867
|
+
"model_format": "awq",
|
|
20868
|
+
"model_size_in_billions": 106,
|
|
20869
|
+
"activated_size_in_billions": 12,
|
|
20870
|
+
"model_src": {
|
|
20871
|
+
"huggingface": {
|
|
20872
|
+
"quantizations": [
|
|
20873
|
+
"AWQ-FP16Mix"
|
|
20874
|
+
],
|
|
20875
|
+
"model_id": "QuantTrio/GLM-4.5-Air-AWQ-FP16Mix"
|
|
20876
|
+
},
|
|
20877
|
+
"modelscope": {
|
|
20878
|
+
"quantizations": [
|
|
20879
|
+
"AWQ-FP16Mix"
|
|
20880
|
+
],
|
|
20881
|
+
"model_id": "tclf90/GLM-4.5-Air-AWQ-FP16Mix"
|
|
20882
|
+
}
|
|
20883
|
+
}
|
|
20884
|
+
},
|
|
20808
20885
|
{
|
|
20809
20886
|
"model_format": "mlx",
|
|
20810
20887
|
"model_size_in_billions": 106,
|
|
@@ -20852,5 +20929,213 @@
|
|
|
20852
20929
|
"#system_numpy#"
|
|
20853
20930
|
]
|
|
20854
20931
|
}
|
|
20932
|
+
},
|
|
20933
|
+
{
|
|
20934
|
+
"version": 2,
|
|
20935
|
+
"context_length": 131072,
|
|
20936
|
+
"model_name": "glm-4.5v",
|
|
20937
|
+
"model_lang": [
|
|
20938
|
+
"en",
|
|
20939
|
+
"zh"
|
|
20940
|
+
],
|
|
20941
|
+
"model_ability": [
|
|
20942
|
+
"chat",
|
|
20943
|
+
"vision",
|
|
20944
|
+
"reasoning"
|
|
20945
|
+
],
|
|
20946
|
+
"model_description": "GLM-4.5V is based on ZhipuAI’s next-generation flagship text foundation model GLM-4.5-Air (106B parameters, 12B active). It continues the technical approach of GLM-4.1V-Thinking, achieving SOTA performance among models of the same scale on 42 public vision-language benchmarks.",
|
|
20947
|
+
"model_specs": [
|
|
20948
|
+
{
|
|
20949
|
+
"model_format": "pytorch",
|
|
20950
|
+
"model_size_in_billions": 106,
|
|
20951
|
+
"activated_size_in_billions": 12,
|
|
20952
|
+
"model_src": {
|
|
20953
|
+
"huggingface": {
|
|
20954
|
+
"quantizations": [
|
|
20955
|
+
"none"
|
|
20956
|
+
],
|
|
20957
|
+
"model_id": "zai-org/GLM-4.5V"
|
|
20958
|
+
},
|
|
20959
|
+
"modelscope": {
|
|
20960
|
+
"quantizations": [
|
|
20961
|
+
"none"
|
|
20962
|
+
],
|
|
20963
|
+
"model_id": "ZhipuAI/GLM-4.5V"
|
|
20964
|
+
}
|
|
20965
|
+
}
|
|
20966
|
+
},
|
|
20967
|
+
{
|
|
20968
|
+
"model_format": "fp8",
|
|
20969
|
+
"model_size_in_billions": 106,
|
|
20970
|
+
"activated_size_in_billions": 12,
|
|
20971
|
+
"model_src": {
|
|
20972
|
+
"huggingface": {
|
|
20973
|
+
"quantizations": [
|
|
20974
|
+
"FP8"
|
|
20975
|
+
],
|
|
20976
|
+
"model_id": "zai-org/GLM-4.5V-FP8"
|
|
20977
|
+
},
|
|
20978
|
+
"modelscope": {
|
|
20979
|
+
"quantizations": [
|
|
20980
|
+
"FP8"
|
|
20981
|
+
],
|
|
20982
|
+
"model_id": "ZhipuAI/GLM-4.5V-FP8"
|
|
20983
|
+
}
|
|
20984
|
+
}
|
|
20985
|
+
},
|
|
20986
|
+
{
|
|
20987
|
+
"model_format": "awq",
|
|
20988
|
+
"model_size_in_billions": 106,
|
|
20989
|
+
"activated_size_in_billions": 12,
|
|
20990
|
+
"model_src": {
|
|
20991
|
+
"huggingface": {
|
|
20992
|
+
"quantizations": [
|
|
20993
|
+
"Int4"
|
|
20994
|
+
],
|
|
20995
|
+
"model_id": "QuantTrio/GLM-4.5V-AWQ"
|
|
20996
|
+
},
|
|
20997
|
+
"modelscope": {
|
|
20998
|
+
"quantizations": [
|
|
20999
|
+
"Int4"
|
|
21000
|
+
],
|
|
21001
|
+
"model_id": "tclf90/GLM-4.5V-AWQ"
|
|
21002
|
+
}
|
|
21003
|
+
}
|
|
21004
|
+
},
|
|
21005
|
+
{
|
|
21006
|
+
"model_format": "mlx",
|
|
21007
|
+
"model_size_in_billions": 106,
|
|
21008
|
+
"activated_size_in_billions": 12,
|
|
21009
|
+
"model_src": {
|
|
21010
|
+
"huggingface": {
|
|
21011
|
+
"quantizations": [
|
|
21012
|
+
"3bit",
|
|
21013
|
+
"4bit",
|
|
21014
|
+
"5bit",
|
|
21015
|
+
"6bit",
|
|
21016
|
+
"8bit"
|
|
21017
|
+
],
|
|
21018
|
+
"model_id": "mlx-community/GLM-4.5V-{quantization}"
|
|
21019
|
+
},
|
|
21020
|
+
"modelscope": {
|
|
21021
|
+
"quantizations": [
|
|
21022
|
+
"3bit",
|
|
21023
|
+
"4bit",
|
|
21024
|
+
"5bit",
|
|
21025
|
+
"6bit",
|
|
21026
|
+
"8bit"
|
|
21027
|
+
],
|
|
21028
|
+
"model_id": "mlx-community/GLM-4.5V-{quantization}"
|
|
21029
|
+
}
|
|
21030
|
+
}
|
|
21031
|
+
}
|
|
21032
|
+
],
|
|
21033
|
+
"chat_template": "[gMASK]<sop>\n{%- if tools -%}\n<|system|>\n# Tools\nYou may call one or more functions to assist with the user query.\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>\n{% for tool in tools %}\n{{ tool | tojson(ensure_ascii=False) }}\n{% endfor %}\n</tools>\nFor each function call, output the function name and arguments within the following XML format:\n<tool_call>{function-name}\n<arg_key>{arg-key-1}</arg_key>\n<arg_value>{arg-value-1}</arg_value>\n<arg_key>{arg-key-2}</arg_key>\n<arg_value>{arg-value-2}</arg_value>\n...\n</tool_call>{%- endif -%}\n{%- macro visible_text(content) -%}\n {%- if content is string -%}\n {{- content }}\n {%- elif content is iterable and content is not mapping -%}\n {%- for item in content -%}\n {%- if item is mapping and item.type == 'text' -%}\n {{- item.text }}\n {%- elif item is mapping and (item.type == 'image' or 'image' in item) -%}\n <|begin_of_image|><|image|><|end_of_image|>\n {%- elif item is mapping and (item.type == 'video' or 'video' in item) -%}\n <|begin_of_video|><|video|><|end_of_video|>\n {%- elif item is string -%}\n {{- item }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{- content }}\n {%- endif -%}\n{%- endmacro -%}\n{%- set ns = namespace(last_user_index=-1) %}\n{%- for m in messages %}\n {%- if m.role == 'user' %}\n {% set ns.last_user_index = loop.index0 -%}\n {%- endif %}\n{%- endfor %}\n{% for m in messages %}\n{%- if m.role == 'user' -%}<|user|>\n{% if m.content is string %}\n{{ m.content }}\n{%- else %}\n{%- for item in m.content %}\n{% if item.type == 'video' or 'video' in item %}\n<|begin_of_video|><|video|><|end_of_video|>{% elif item.type == 'image' or 'image' in item %}\n<|begin_of_image|><|image|><|end_of_image|>{% elif item.type == 'text' %}\n{{ item.text }}\n{%- endif %}\n{%- endfor %}\n{%- endif %}\n{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith(\"/nothink\")) else '' -}}\n{%- elif m.role == 'assistant' -%}\n<|assistant|>\n{%- set reasoning_content = '' %}\n{%- set content = visible_text(m.content) %}\n{%- if m.reasoning_content is string %}\n {%- set reasoning_content = m.reasoning_content %}\n{%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n{%- endif %}\n{%- if loop.index0 > ns.last_user_index and reasoning_content -%}\n{{ '\\n<think>' + reasoning_content.strip() + '</think>'}}\n{%- else -%}\n{{ '\\n<think></think>' }}\n{%- endif -%}\n{%- if content.strip() -%}\n{{ '\\n' + content.strip() }}\n{%- endif -%}\n{% if m.tool_calls %}\n{% for tc in m.tool_calls %}\n{%- if tc.function %}\n {%- set tc = tc.function %}\n{%- endif %}\n{{ '\\n<tool_call>' + tc.name }}\n{% set _args = tc.arguments %}\n{% for k, v in _args.items() %}\n<arg_key>{{ k }}</arg_key>\n<arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>\n{% endfor %}\n</tool_call>{% endfor %}\n{% endif %}\n{%- elif m.role == 'tool' -%}\n{%- if m.content is string -%}\n{%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|observation|>' }}\n{%- endif %}\n{{- '\\n<tool_response>\\n' }}\n{{- m.content }}\n{{- '\\n</tool_response>' }}\n{%- else -%}\n<|observation|>{% for tr in m.content %}\n<tool_response>\n{{ tr.output if tr.output is defined else tr }}\n</tool_response>{% endfor -%}\n{% endif -%}\n{%- elif m.role == 'system' -%}\n<|system|>\n{{ visible_text(m.content) }}\n{%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n<|assistant|>\n{{'<think></think>\\n' if (enable_thinking is defined and not enable_thinking) else ''}}\n{%- endif -%}",
|
|
21034
|
+
"stop_token_ids": [
|
|
21035
|
+
151329,
|
|
21036
|
+
151336,
|
|
21037
|
+
151338
|
|
21038
|
+
],
|
|
21039
|
+
"stop": [
|
|
21040
|
+
"<|endoftext|>",
|
|
21041
|
+
"<|user|>",
|
|
21042
|
+
"<|observation|>"
|
|
21043
|
+
],
|
|
21044
|
+
"reasoning_start_tag": "<think>",
|
|
21045
|
+
"reasoning_end_tag": "</think>",
|
|
21046
|
+
"virtualenv": {
|
|
21047
|
+
"packages": [
|
|
21048
|
+
"transformers>=4.55.0",
|
|
21049
|
+
"#system_numpy#"
|
|
21050
|
+
]
|
|
21051
|
+
}
|
|
21052
|
+
},
|
|
21053
|
+
{
|
|
21054
|
+
"version": 2,
|
|
21055
|
+
"context_length": 131072,
|
|
21056
|
+
"model_name": "gpt-oss",
|
|
21057
|
+
"model_lang": [
|
|
21058
|
+
"en"
|
|
21059
|
+
],
|
|
21060
|
+
"model_ability": [
|
|
21061
|
+
"chat",
|
|
21062
|
+
"reasoning"
|
|
21063
|
+
],
|
|
21064
|
+
"model_description": "gpt-oss series, OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases.",
|
|
21065
|
+
"model_specs": [
|
|
21066
|
+
{
|
|
21067
|
+
"model_format": "pytorch",
|
|
21068
|
+
"model_size_in_billions": 20,
|
|
21069
|
+
"activated_size_in_billions": "3_6",
|
|
21070
|
+
"model_src": {
|
|
21071
|
+
"huggingface": {
|
|
21072
|
+
"quantizations": [
|
|
21073
|
+
"none"
|
|
21074
|
+
],
|
|
21075
|
+
"model_id": "openai/gpt-oss-20b"
|
|
21076
|
+
},
|
|
21077
|
+
"modelscope": {
|
|
21078
|
+
"quantizations": [
|
|
21079
|
+
"none"
|
|
21080
|
+
],
|
|
21081
|
+
"model_id": "openai-mirror/gpt-oss-20b"
|
|
21082
|
+
}
|
|
21083
|
+
}
|
|
21084
|
+
},
|
|
21085
|
+
{
|
|
21086
|
+
"model_format": "bnb",
|
|
21087
|
+
"model_size_in_billions": 20,
|
|
21088
|
+
"activated_size_in_billions": "3_6",
|
|
21089
|
+
"model_src": {
|
|
21090
|
+
"huggingface": {
|
|
21091
|
+
"quantizations": [
|
|
21092
|
+
"4-bit"
|
|
21093
|
+
],
|
|
21094
|
+
"model_id": "unsloth/gpt-oss-20b-bnb-4bit"
|
|
21095
|
+
},
|
|
21096
|
+
"modelscope": {
|
|
21097
|
+
"quantizations": [
|
|
21098
|
+
"4-bit"
|
|
21099
|
+
],
|
|
21100
|
+
"model_id": "unsloth/gpt-oss-20b-bnb-4bit"
|
|
21101
|
+
}
|
|
21102
|
+
}
|
|
21103
|
+
},
|
|
21104
|
+
{
|
|
21105
|
+
"model_format": "pytorch",
|
|
21106
|
+
"model_size_in_billions": 120,
|
|
21107
|
+
"activated_size_in_billions": "5_1",
|
|
21108
|
+
"model_src": {
|
|
21109
|
+
"huggingface": {
|
|
21110
|
+
"quantizations": [
|
|
21111
|
+
"none"
|
|
21112
|
+
],
|
|
21113
|
+
"model_id": "openai/gpt-oss-120b"
|
|
21114
|
+
},
|
|
21115
|
+
"modelscope": {
|
|
21116
|
+
"quantizations": [
|
|
21117
|
+
"none"
|
|
21118
|
+
],
|
|
21119
|
+
"model_id": "openai-mirror/gpt-oss-120b"
|
|
21120
|
+
}
|
|
21121
|
+
}
|
|
21122
|
+
}
|
|
21123
|
+
],
|
|
21124
|
+
"chat_template": "{#-\n In addition to the normal inputs of `messages` and `tools`, this template also accepts the\n following kwargs:\n - \"builtin_tools\": A list, can contain \"browser\" and/or \"python\".\n - \"model_identity\": A string that optionally describes the model identity.\n - \"reasoning_effort\": A string that describes the reasoning effort, defaults to \"medium\".\n #}\n\n{#- Tool Definition Rendering ============================================== #}\n{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}\n {%- if param_spec.type == \"array\" -%}\n {%- if param_spec['items'] -%}\n {%- if param_spec['items']['type'] == \"string\" -%}\n {{- \"string[]\" }}\n {%- elif param_spec['items']['type'] == \"number\" -%}\n {{- \"number[]\" }}\n {%- elif param_spec['items']['type'] == \"integer\" -%}\n {{- \"number[]\" }}\n {%- elif param_spec['items']['type'] == \"boolean\" -%}\n {{- \"boolean[]\" }}\n {%- else -%}\n {%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%}\n {%- if inner_type == \"object | object\" or inner_type|length > 50 -%}\n {{- \"any[]\" }}\n {%- else -%}\n {{- inner_type + \"[]\" }}\n {%- endif -%}\n {%- endif -%}\n {%- if param_spec.nullable -%}\n {{- \" | null\" }}\n {%- endif -%}\n {%- else -%}\n {{- \"any[]\" }}\n {%- if param_spec.nullable -%}\n {{- \" | null\" }}\n {%- endif -%}\n {%- endif -%}\n {%- elif param_spec.type is defined and param_spec.type is iterable and param_spec.type is not string and param_spec.type is not mapping and param_spec.type[0] is defined -%}\n {#- Handle array of types like [\"object\", \"object\"] from Union[dict, list] #}\n {%- if param_spec.type | length > 1 -%}\n {{- param_spec.type | join(\" | \") }}\n {%- else -%}\n {{- param_spec.type[0] }}\n {%- endif -%}\n {%- elif param_spec.oneOf -%}\n {#- Handle oneOf schemas - check for complex unions and fallback to any #}\n {%- set has_object_variants = false -%}\n {%- for variant in param_spec.oneOf -%}\n {%- if variant.type == \"object\" -%}\n {%- set has_object_variants = true -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if has_object_variants and param_spec.oneOf|length > 1 -%}\n {{- \"any\" }}\n {%- else -%}\n {%- for variant in param_spec.oneOf -%}\n {{- render_typescript_type(variant, required_params) -}}\n {%- if variant.description %}\n {{- \"// \" + variant.description }}\n {%- endif -%}\n {%- if variant.default is defined %}\n {{ \"// default: \" + variant.default|tojson }}\n {%- endif -%}\n {%- if not loop.last %}\n {{- \" | \" }}\n {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- elif param_spec.type == \"string\" -%}\n {%- if param_spec.enum -%}\n {{- '\"' + param_spec.enum|join('\" | \"') + '\"' -}}\n {%- else -%}\n {{- \"string\" }}\n {%- if param_spec.nullable %}\n {{- \" | null\" }}\n {%- endif -%}\n {%- endif -%}\n {%- elif param_spec.type == \"number\" -%}\n {{- \"number\" }}\n {%- elif param_spec.type == \"integer\" -%}\n {{- \"number\" }}\n {%- elif param_spec.type == \"boolean\" -%}\n {{- \"boolean\" }}\n\n {%- elif param_spec.type == \"object\" -%}\n {%- if param_spec.properties -%}\n {{- \"{\n\" }}\n {%- for prop_name, prop_spec in param_spec.properties.items() -%}\n {{- prop_name -}}\n {%- if prop_name not in (param_spec.required or []) -%}\n {{- \"?\" }}\n {%- endif -%}\n {{- \": \" }}\n {{ render_typescript_type(prop_spec, param_spec.required or []) }}\n {%- if not loop.last -%}\n {{-\", \" }}\n {%- endif -%}\n {%- endfor -%}\n {{- \"}\" }}\n {%- else -%}\n {{- \"object\" }}\n {%- endif -%}\n {%- else -%}\n {{- \"any\" }}\n {%- endif -%}\n{%- endmacro -%}\n\n{%- macro render_tool_namespace(namespace_name, tools) -%}\n {{- \"## \" + namespace_name + \"\n\n\" }}\n {{- \"namespace \" + namespace_name + \" {\n\n\" }}\n {%- for tool in tools %}\n {%- set tool = tool.function %}\n {{- \"// \" + tool.description + \"\n\" }}\n {{- \"type \"+ tool.name + \" = \" }}\n {%- if tool.parameters and tool.parameters.properties %}\n {{- \"(_: {\n\" }}\n {%- for param_name, param_spec in tool.parameters.properties.items() %}\n {%- if param_spec.description %}\n {{- \"// \" + param_spec.description + \"\n\" }}\n {%- endif %}\n {{- param_name }}\n {%- if param_name not in (tool.parameters.required or []) -%}\n {{- \"?\" }}\n {%- endif -%}\n {{- \": \" }}\n {{- render_typescript_type(param_spec, tool.parameters.required or []) }}\n {%- if param_spec.default is defined -%}\n {%- if param_spec.enum %}\n {{- \", // default: \" + param_spec.default }}\n {%- elif param_spec.oneOf %}\n {{- \"// default: \" + param_spec.default }}\n {%- else %}\n {{- \", // default: \" + param_spec.default|tojson }}\n {%- endif -%}\n {%- endif -%}\n {%- if not loop.last %}\n {{- \",\n\" }}\n {%- else %}\n {{- \"\n\" }}\n {%- endif -%}\n {%- endfor %}\n {{- \"}) => any;\n\n\" }}\n {%- else -%}\n {{- \"() => any;\n\n\" }}\n {%- endif -%}\n {%- endfor %}\n {{- \"} // namespace \" + namespace_name }}\n{%- endmacro -%}\n\n{%- macro render_builtin_tools(browser_tool, python_tool) -%}\n {%- if browser_tool %}\n {{- \"## browser\n\n\" }}\n {{- \"// Tool for browsing.\n\" }}\n {{- \"// The `cursor` appears in brackets before each browsing display: `[{cursor}]`.\n\" }}\n {{- \"// Cite information from the tool using the following format:\n\" }}\n {{- \"// `\u3010{cursor}\u2020L{line_start}(-L{line_end})?\u3011`, for example: `\u30106\u2020L9-L11\u3011` or `\u30108\u2020L3\u3011`.\n\" }}\n {{- \"// Do not quote more than 10 words directly from the tool output.\n\" }}\n {{- \"// sources=web (default: web)\n\" }}\n {{- \"namespace browser {\n\n\" }}\n {{- \"// Searches for information related to `query` and displays `topn` results.\n\" }}\n {{- \"type search = (_: {\n\" }}\n {{- \"query: string,\n\" }}\n {{- \"topn?: number, // default: 10\n\" }}\n {{- \"source?: string,\n\" }}\n {{- \"}) => any;\n\n\" }}\n {{- \"// Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines.\n\" }}\n {{- \"// Valid link ids are displayed with the formatting: `\u3010{id}\u2020.*\u3011`.\n\" }}\n {{- \"// If `cursor` is not provided, the most recent page is implied.\n\" }}\n {{- \"// If `id` is a string, it is treated as a fully qualified URL associated with `source`.\n\" }}\n {{- \"// If `loc` is not provided, the viewport will be positioned at the beginning of the document or centered on the most relevant passage, if available.\n\" }}\n {{- \"// Use this function without `id` to scroll to a new location of an opened page.\n\" }}\n {{- \"type open = (_: {\n\" }}\n {{- \"id?: number | string, // default: -1\n\" }}\n {{- \"cursor?: number, // default: -1\n\" }}\n {{- \"loc?: number, // default: -1\n\" }}\n {{- \"num_lines?: number, // default: -1\n\" }}\n {{- \"view_source?: boolean, // default: false\n\" }}\n {{- \"source?: string,\n\" }}\n {{- \"}) => any;\n\n\" }}\n {{- \"// Finds exact matches of `pattern` in the current page, or the page given by `cursor`.\n\" }}\n {{- \"type find = (_: {\n\" }}\n {{- \"pattern: string,\n\" }}\n {{- \"cursor?: number, // default: -1\n\" }}\n {{- \"}) => any;\n\n\" }}\n {{- \"} // namespace browser\n\n\" }}\n {%- endif -%}\n\n {%- if python_tool %}\n {{- \"## python\n\n\" }}\n {{- \"Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).\n\n\" }}\n {{- \"When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.\n\n\" }}\n {%- endif -%}\n{%- endmacro -%}\n\n{#- System Message Construction ============================================ #}\n{%- macro build_system_message() -%}\n {%- if model_identity is not defined %}\n {%- set model_identity = \"You are ChatGPT, a large language model trained by OpenAI.\" %}\n {%- endif %}\n {{- model_identity + \"\n\" }}\n {{- \"Knowledge cutoff: 2024-06\n\" }}\n {{- \"Current date: \" + strftime_now(\"%Y-%m-%d\") + \"\n\n\" }}\n {%- if reasoning_effort is not defined %}\n {%- set reasoning_effort = \"medium\" %}\n {%- endif %}\n {{- \"Reasoning: \" + reasoning_effort + \"\n\n\" }}\n {%- if builtin_tools %}\n {{- \"# Tools\n\n\" }}\n {%- set available_builtin_tools = namespace(browser=false, python=false) %}\n {%- for tool in builtin_tools %}\n {%- if tool == \"browser\" %}\n {%- set available_builtin_tools.browser = true %}\n {%- elif tool == \"python\" %}\n {%- set available_builtin_tools.python = true %}\n {%- endif %}\n {%- endfor %}\n {{- render_builtin_tools(available_builtin_tools.browser, available_builtin_tools.python) }}\n {%- endif -%}\n {{- \"# Valid channels: analysis, commentary, final. Channel must be included for every message.\" }}\n {%- if tools -%}\n {{- \"\nCalls to these tools must go to the commentary channel: 'functions'.\" }}\n {%- endif -%}\n{%- endmacro -%}\n\n{#- Main Template Logic ================================================= #}\n{#- Set defaults #}\n\n{#- Render system message #}\n{{- \"<|start|>system<|message|>\" }}\n{{- build_system_message() }}\n{{- \"<|end|>\" }}\n\n{#- Extract developer message #}\n{%- if messages[0].role == \"developer\" or messages[0].role == \"system\" %}\n {%- set developer_message = messages[0].content %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set developer_message = \"\" %}\n {%- set loop_messages = messages %}\n{%- endif %}\n\n{#- Render developer message #}\n{%- if developer_message or tools %}\n {{- \"<|start|>developer<|message|>\" }}\n {%- if developer_message %}\n {{- \"# Instructions\n\n\" }}\n {{- developer_message }}\n {%- endif %}\n {%- if tools -%}\n {{- \"\n\n\" }}\n {{- \"# Tools\n\n\" }}\n {{- render_tool_namespace(\"functions\", tools) }}\n {%- endif -%}\n {{- \"<|end|>\" }}\n{%- endif %}\n\n{#- Render messages #}\n{%- set last_tool_call = namespace(name=none) %}\n{%- for message in loop_messages -%}\n {#- At this point only assistant/user/tool messages should remain #}\n {%- if message.role == 'assistant' -%}\n {#- Checks to ensure the messages are being passed in the format we expect #}\n {%- if \"content\" in message %}\n {%- if \"<|channel|>analysis<|message|>\" in message.content or \"<|channel|>final<|message|>\" in message.content %}\n {{- raise_exception(\"You have passed a message containing <|channel|> tags in the content field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.\") }}\n {%- endif %}\n {%- endif %}\n {%- if \"thinking\" in message %}\n {%- if \"<|channel|>analysis<|message|>\" in message.thinking or \"<|channel|>final<|message|>\" in message.thinking %}\n {{- raise_exception(\"You have passed a message containing <|channel|> tags in the thinking field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.\") }}\n {%- endif %}\n {%- endif %}\n {%- if \"tool_calls\" in message %}\n {#- We assume max 1 tool call per message, and so we infer the tool call name #}\n {#- in \"tool\" messages from the most recent assistant tool call name #}\n {%- set tool_call = message.tool_calls[0] %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if message.content and message.thinking %}\n {{- raise_exception(\"Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.\") }}\n {%- elif message.content %}\n {{- \"<|start|>assistant<|channel|>analysis<|message|>\" + message.content + \"<|end|>\" }}\n {%- elif message.thinking %}\n {{- \"<|start|>assistant<|channel|>analysis<|message|>\" + message.thinking + \"<|end|>\" }}\n {%- endif %}\n {{- \"<|start|>assistant to=\" }}\n {{- \"functions.\" + tool_call.name + \"<|channel|>commentary \" }}\n {{- (tool_call.content_type if tool_call.content_type is defined else \"json\") + \"<|message|>\" }}\n {{- tool_call.arguments|tojson }}\n {{- \"<|call|>\" }}\n {%- set last_tool_call.name = tool_call.name %}\n {%- elif loop.last and not add_generation_prompt %}\n {#- Only render the CoT if the final turn is an assistant turn and add_generation_prompt is false #}\n {#- This is a situation that should only occur in training, never in inference. #}\n {%- if \"thinking\" in message %}\n {{- \"<|start|>assistant<|channel|>analysis<|message|>\" + message.thinking + \"<|end|>\" }}\n {%- endif %}\n {#- <|return|> indicates the end of generation, but <|end|> does not #}\n {#- <|return|> should never be an input to the model, but we include it as the final token #}\n {#- when training, so the model learns to emit it. #}\n {{- \"<|start|>assistant<|channel|>final<|message|>\" + message.content + \"<|return|>\" }}\n {%- else %}\n {#- CoT is dropped during all previous turns, so we never render it for inference #}\n {{- \"<|start|>assistant<|channel|>final<|message|>\" + message.content + \"<|end|>\" }}\n {%- set last_tool_call.name = none %}\n {%- endif %}\n {%- elif message.role == 'tool' -%}\n {%- if last_tool_call.name is none %}\n {{- raise_exception(\"Message has tool role, but there was no previous assistant message with a tool call!\") }}\n {%- endif %}\n {{- \"<|start|>functions.\" + last_tool_call.name }}\n {{- \" to=assistant<|channel|>commentary<|message|>\" + message.content|tojson + \"<|end|>\" }}\n {%- elif message.role == 'user' -%}\n {{- \"<|start|>user<|message|>\" + message.content + \"<|end|>\" }}\n {%- endif -%}\n{%- endfor -%}\n\n{#- Generation prompt #}\n{%- if add_generation_prompt -%}\n<|start|>assistant\n{%- endif -%}",
|
|
21125
|
+
"stop_token_ids": [
|
|
21126
|
+
200002,
|
|
21127
|
+
199999
|
|
21128
|
+
],
|
|
21129
|
+
"stop": [
|
|
21130
|
+
"<|endoftext|>",
|
|
21131
|
+
"<|return|>"
|
|
21132
|
+
],
|
|
21133
|
+
"virtualenv": {
|
|
21134
|
+
"packages": [
|
|
21135
|
+
"transformers>=4.55.0,<4.56.0",
|
|
21136
|
+
"kernels==0.9.0",
|
|
21137
|
+
"#system_numpy#"
|
|
21138
|
+
]
|
|
21139
|
+
}
|
|
20855
21140
|
}
|
|
20856
21141
|
]
|
|
@@ -78,7 +78,7 @@ class LlamaCppLLMSpecV2(BaseModel):
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
class PytorchLLMSpecV2(BaseModel):
|
|
81
|
-
model_format: Literal["pytorch", "gptq", "awq", "fp8"]
|
|
81
|
+
model_format: Literal["pytorch", "gptq", "awq", "fp8", "bnb"]
|
|
82
82
|
# Must in order that `str` first, then `int`
|
|
83
83
|
model_size_in_billions: Union[str, int]
|
|
84
84
|
quantization: str
|
|
@@ -39,6 +39,7 @@ from ..llm_family import CustomLLMFamilyV2
|
|
|
39
39
|
from ..utils import (
|
|
40
40
|
DEEPSEEK_TOOL_CALL_FAMILY,
|
|
41
41
|
QWEN_TOOL_CALL_FAMILY,
|
|
42
|
+
QWEN_TOOL_CALL_SYMBOLS,
|
|
42
43
|
ChatModelMixin,
|
|
43
44
|
generate_completion_chunk,
|
|
44
45
|
)
|
|
@@ -337,7 +338,7 @@ class SGLANGModel(LLM):
|
|
|
337
338
|
return False
|
|
338
339
|
if not cls._is_linux():
|
|
339
340
|
return False
|
|
340
|
-
if llm_spec.model_format not in ["pytorch", "gptq", "awq", "fp8"]:
|
|
341
|
+
if llm_spec.model_format not in ["pytorch", "gptq", "awq", "fp8", "bnb"]:
|
|
341
342
|
return False
|
|
342
343
|
if llm_spec.model_format == "pytorch":
|
|
343
344
|
if quantization != "none" and not (quantization is None):
|
|
@@ -471,6 +472,7 @@ class SGLANGModel(LLM):
|
|
|
471
472
|
*,
|
|
472
473
|
image_data: Optional[Union[List[str], str]] = None,
|
|
473
474
|
generate_config: Optional[SGLANGGenerateConfig] = None,
|
|
475
|
+
tools: Optional[List[Dict]] = None,
|
|
474
476
|
request_id: Optional[str] = None,
|
|
475
477
|
) -> Union[Completion, AsyncGenerator[CompletionChunk, None]]:
|
|
476
478
|
sanitized_generate_config = self._sanitize_generate_config(generate_config)
|
|
@@ -501,6 +503,10 @@ class SGLANGModel(LLM):
|
|
|
501
503
|
|
|
502
504
|
async def stream_results() -> AsyncGenerator[CompletionChunk, None]:
|
|
503
505
|
prompt_tokens, completion_tokens, total_tokens = 0, 0, 0
|
|
506
|
+
complete_response = ""
|
|
507
|
+
match_tool_call_tmp_results: List[CompletionChunk] = []
|
|
508
|
+
is_match_tool_call = False
|
|
509
|
+
chunk = None
|
|
504
510
|
finish_reason = None
|
|
505
511
|
async for meta_info, out in self._stream_generate(
|
|
506
512
|
prompt, image_data, **sanitized_generate_config
|
|
@@ -508,6 +514,7 @@ class SGLANGModel(LLM):
|
|
|
508
514
|
chunk = self._convert_state_to_completion_chunk(
|
|
509
515
|
request_id, self.model_uid, output_text=out
|
|
510
516
|
)
|
|
517
|
+
complete_response += out
|
|
511
518
|
finish_reason = meta_info["finish_reason"]
|
|
512
519
|
prompt_tokens = meta_info["prompt_tokens"]
|
|
513
520
|
completion_tokens = meta_info["completion_tokens"]
|
|
@@ -517,6 +524,49 @@ class SGLANGModel(LLM):
|
|
|
517
524
|
completion_tokens=completion_tokens,
|
|
518
525
|
total_tokens=total_tokens,
|
|
519
526
|
)
|
|
527
|
+
if tools:
|
|
528
|
+
"""
|
|
529
|
+
The qwen2 tool call returns format like this:
|
|
530
|
+
<tool_call>
|
|
531
|
+
{...}
|
|
532
|
+
</tool_call>
|
|
533
|
+
Here is to match this.
|
|
534
|
+
"""
|
|
535
|
+
if (
|
|
536
|
+
len(QWEN_TOOL_CALL_SYMBOLS[0]) > len(complete_response)
|
|
537
|
+
) and (
|
|
538
|
+
not QWEN_TOOL_CALL_SYMBOLS[0].startswith(complete_response)
|
|
539
|
+
):
|
|
540
|
+
for c in match_tool_call_tmp_results:
|
|
541
|
+
yield c
|
|
542
|
+
match_tool_call_tmp_results.clear()
|
|
543
|
+
yield chunk
|
|
544
|
+
elif (
|
|
545
|
+
len(QWEN_TOOL_CALL_SYMBOLS[0]) > len(complete_response)
|
|
546
|
+
) and (QWEN_TOOL_CALL_SYMBOLS[0].startswith(complete_response)):
|
|
547
|
+
match_tool_call_tmp_results.append(chunk)
|
|
548
|
+
else:
|
|
549
|
+
assert len(QWEN_TOOL_CALL_SYMBOLS[0]) <= len(
|
|
550
|
+
complete_response
|
|
551
|
+
)
|
|
552
|
+
if not is_match_tool_call and complete_response.startswith(
|
|
553
|
+
QWEN_TOOL_CALL_SYMBOLS[0]
|
|
554
|
+
):
|
|
555
|
+
is_match_tool_call = True
|
|
556
|
+
match_tool_call_tmp_results.clear()
|
|
557
|
+
|
|
558
|
+
if not is_match_tool_call:
|
|
559
|
+
for c in match_tool_call_tmp_results:
|
|
560
|
+
yield c
|
|
561
|
+
match_tool_call_tmp_results.clear()
|
|
562
|
+
yield chunk
|
|
563
|
+
else:
|
|
564
|
+
chunk["choices"][0]["text"] = complete_response
|
|
565
|
+
else:
|
|
566
|
+
yield chunk
|
|
567
|
+
|
|
568
|
+
if is_match_tool_call:
|
|
569
|
+
assert chunk is not None
|
|
520
570
|
yield chunk
|
|
521
571
|
|
|
522
572
|
finish_reason = (
|
|
@@ -561,7 +611,7 @@ class SGLANGChatModel(SGLANGModel, ChatModelMixin):
|
|
|
561
611
|
def match_json(
|
|
562
612
|
cls, llm_family: "LLMFamilyV2", llm_spec: "LLMSpecV1", quantization: str
|
|
563
613
|
) -> bool:
|
|
564
|
-
if llm_spec.model_format not in ["pytorch", "gptq", "awq", "fp8"]:
|
|
614
|
+
if llm_spec.model_format not in ["pytorch", "gptq", "awq", "fp8", "bnb"]:
|
|
565
615
|
return False
|
|
566
616
|
if llm_spec.model_format == "pytorch":
|
|
567
617
|
if quantization != "none" and not (quantization is None):
|
|
@@ -588,6 +638,57 @@ class SGLANGChatModel(SGLANGModel, ChatModelMixin):
|
|
|
588
638
|
generate_config.pop("chat_template_kwargs", None)
|
|
589
639
|
return generate_config
|
|
590
640
|
|
|
641
|
+
@staticmethod
|
|
642
|
+
def is_tool_call_chunk_start(chunk):
|
|
643
|
+
return chunk["choices"][0]["text"].startswith(QWEN_TOOL_CALL_SYMBOLS[0])
|
|
644
|
+
|
|
645
|
+
@staticmethod
|
|
646
|
+
def is_tool_call_chunk_end(chunk):
|
|
647
|
+
return chunk["choices"][0]["text"].endswith(QWEN_TOOL_CALL_SYMBOLS[1])
|
|
648
|
+
|
|
649
|
+
async def _async_to_tool_completion_chunks(
|
|
650
|
+
self,
|
|
651
|
+
chunks: AsyncGenerator[CompletionChunk, None],
|
|
652
|
+
) -> AsyncGenerator[ChatCompletionChunk, None]:
|
|
653
|
+
i = 0
|
|
654
|
+
previous_texts = [""]
|
|
655
|
+
tool_call = False
|
|
656
|
+
tool_call_texts = [""]
|
|
657
|
+
if self.reasoning_parser:
|
|
658
|
+
chunks = self.reasoning_parser.prepare_reasoning_content_streaming(chunks)
|
|
659
|
+
async for chunk in chunks:
|
|
660
|
+
if i == 0:
|
|
661
|
+
for first_chunk in self._get_first_chat_completion_chunk(
|
|
662
|
+
chunk, self.reasoning_parser
|
|
663
|
+
):
|
|
664
|
+
yield first_chunk
|
|
665
|
+
# usage
|
|
666
|
+
choices = chunk.get("choices")
|
|
667
|
+
if not choices:
|
|
668
|
+
yield self._get_final_chat_completion_chunk(chunk)
|
|
669
|
+
else:
|
|
670
|
+
if self.is_tool_call_chunk_start(chunk):
|
|
671
|
+
tool_call = True
|
|
672
|
+
if tool_call:
|
|
673
|
+
tool_call_text = tool_call_texts[-1]
|
|
674
|
+
tool_call_text += chunk["choices"][0]["text"]
|
|
675
|
+
tool_call_texts.append(tool_call_text)
|
|
676
|
+
if self.is_tool_call_chunk_end(chunk):
|
|
677
|
+
yield self._post_process_completion_chunk(
|
|
678
|
+
self.model_family,
|
|
679
|
+
self.model_uid,
|
|
680
|
+
chunk,
|
|
681
|
+
reasoning_parser=self.reasoning_parser,
|
|
682
|
+
tool_call_text=tool_call_text,
|
|
683
|
+
)
|
|
684
|
+
tool_call = False
|
|
685
|
+
tool_call_texts = [""]
|
|
686
|
+
else:
|
|
687
|
+
yield self._to_chat_completion_chunk(
|
|
688
|
+
chunk, self.reasoning_parser, previous_texts
|
|
689
|
+
)
|
|
690
|
+
i += 1
|
|
691
|
+
|
|
591
692
|
async def async_chat(
|
|
592
693
|
self,
|
|
593
694
|
messages: List[Dict],
|
|
@@ -618,13 +719,15 @@ class SGLANGChatModel(SGLANGModel, ChatModelMixin):
|
|
|
618
719
|
generate_config = self._sanitize_chat_config(generate_config)
|
|
619
720
|
stream = generate_config.get("stream", None)
|
|
620
721
|
if stream:
|
|
621
|
-
agen = await self.async_generate(full_prompt, generate_config=generate_config) # type: ignore
|
|
722
|
+
agen = await self.async_generate(full_prompt, generate_config=generate_config, tools=tools) # type: ignore
|
|
622
723
|
assert isinstance(agen, AsyncGenerator)
|
|
724
|
+
if tools:
|
|
725
|
+
return self._async_to_tool_completion_chunks(agen)
|
|
623
726
|
return self._async_to_chat_completion_chunks(
|
|
624
727
|
agen, self.reasoning_parser, chat_template_kwargs
|
|
625
728
|
)
|
|
626
729
|
else:
|
|
627
|
-
c = await self.async_generate(full_prompt, generate_config=generate_config) # type: ignore
|
|
730
|
+
c = await self.async_generate(full_prompt, generate_config=generate_config, tools=tools) # type: ignore
|
|
628
731
|
assert not isinstance(c, AsyncGenerator)
|
|
629
732
|
if tools:
|
|
630
733
|
return self._post_process_completion(
|
|
@@ -642,7 +745,7 @@ class SGLANGVisionModel(SGLANGModel, ChatModelMixin):
|
|
|
642
745
|
return False
|
|
643
746
|
if not cls._is_linux():
|
|
644
747
|
return False
|
|
645
|
-
if llm_spec.model_format not in ["pytorch", "gptq", "awq", "fp8"]:
|
|
748
|
+
if llm_spec.model_format not in ["pytorch", "gptq", "awq", "fp8", "bnb"]:
|
|
646
749
|
return False
|
|
647
750
|
if llm_spec.model_format == "pytorch":
|
|
648
751
|
if quantization != "none" and not (quantization is None):
|