Views
No views yet
1[gMASK]<sop>
2{%- if tools -%}
3<|system|>
4你是一个名为 ChatGLM 的人工智能助手。你是基于智谱 AI 公司训练的语言模型 GLM-4 模型开发的,你的任务是针对用户的问题和要求提供适当的答复和支持。
5# 可用工具
6{%- for tool in tools %}
7 {%- set function = tool.function if tool.get("function") else tool %}
8## {{ function.name }}
9{{ function | tojson(indent=4, ensure_ascii=False) }}
10在调用上述函数时,请使用 Json 格式表示调用的参数。
11{%- endfor %}
12{%- endif -%}
13{%- for msg in messages %}
14 {%- if msg.role == 'system' %}
15<|system|>
16{{ msg.content }}
17 {%- endif %}
18{%- endfor %}
19{%- for message in messages if message.role != 'system' %}
20 {%- set role = message['role'] %}
21 {%- set content = message['content'] %}
22 {%- set thinkcontent = content.split('</think>') %}
23 {%- set visible = thinkcontent[-1].strip() %}
24 {%- set meta = message.get("metadata", "") %}
25 {%- if role == 'user' %}
26<|user|>
27{{ visible }}
28 {%- elif role == 'assistant' and not meta %}
29<|assistant|>
30{{ visible }}
31 {%- elif role == 'assistant' and meta %}
32<|assistant|>{{ meta }}
33{{ visible }}
34 {%- elif role == 'observation' %}
35<|observation|>
36{{ visible }}
37 {%- endif %}
38{%- endfor %}
39{% if add_generation_prompt %}<|assistant|>\n<think>{% endif %}