universal-agent-memory 6.2.0 → 6.2.1
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.
- package/dist/cli/tool-calls.d.ts +16 -0
- package/dist/cli/tool-calls.d.ts.map +1 -0
- package/dist/cli/tool-calls.js +374 -0
- package/dist/cli/tool-calls.js.map +1 -0
- package/package.json +2 -1
- package/tools/agents/README.md +224 -0
- package/tools/agents/benchmarks/benchmark_memory_systems.py +637 -0
- package/tools/agents/benchmarks/results/benchmark_20260106_064817.json +170 -0
- package/tools/agents/benchmarks/results/benchmark_20260106_064817.md +51 -0
- package/tools/agents/config/chat_template.jinja +172 -0
- package/tools/agents/scripts/fix_qwen_chat_template.py +314 -0
- package/tools/agents/scripts/memory_migration.py +518 -0
- package/tools/agents/scripts/migrate_memory_to_qdrant.py +113 -0
- package/tools/agents/scripts/query_memory.py +189 -0
- package/tools/agents/scripts/qwen_tool_call_test.py +419 -0
- package/tools/agents/scripts/qwen_tool_call_wrapper.py +517 -0
- package/tools/agents/scripts/start-services.sh +96 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "SQLite",
|
|
4
|
+
"operation": "INSERT (single)",
|
|
5
|
+
"samples": 100,
|
|
6
|
+
"mean_ms": 1.1429446772672236,
|
|
7
|
+
"median_ms": 1.1120839626528323,
|
|
8
|
+
"p95_ms": 1.3595609925687313,
|
|
9
|
+
"p99_ms": 1.5702530508860946,
|
|
10
|
+
"min_ms": 1.0651589836925268,
|
|
11
|
+
"max_ms": 1.5702530508860946,
|
|
12
|
+
"ops_per_sec": 874.932986600013
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "SQLite",
|
|
16
|
+
"operation": "SELECT recent (LIMIT 50)",
|
|
17
|
+
"samples": 100,
|
|
18
|
+
"mean_ms": 0.1497111632488668,
|
|
19
|
+
"median_ms": 0.14744600048288703,
|
|
20
|
+
"p95_ms": 0.16588205471634865,
|
|
21
|
+
"p99_ms": 0.19576202612370253,
|
|
22
|
+
"min_ms": 0.1444709487259388,
|
|
23
|
+
"max_ms": 0.19576202612370253,
|
|
24
|
+
"ops_per_sec": 6679.528622309127
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "SQLite",
|
|
28
|
+
"operation": "SELECT by type",
|
|
29
|
+
"samples": 100,
|
|
30
|
+
"mean_ms": 0.1452046213671565,
|
|
31
|
+
"median_ms": 0.14327099779620767,
|
|
32
|
+
"p95_ms": 0.159741030074656,
|
|
33
|
+
"p99_ms": 0.20464195404201746,
|
|
34
|
+
"min_ms": 0.14055101200938225,
|
|
35
|
+
"max_ms": 0.20464195404201746,
|
|
36
|
+
"ops_per_sec": 6886.833150244264
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "SQLite",
|
|
40
|
+
"operation": "LIKE search",
|
|
41
|
+
"samples": 100,
|
|
42
|
+
"mean_ms": 0.13849956914782524,
|
|
43
|
+
"median_ms": 0.13719149865210056,
|
|
44
|
+
"p95_ms": 0.14585198368877172,
|
|
45
|
+
"p99_ms": 0.19792199600487947,
|
|
46
|
+
"min_ms": 0.1340809976682067,
|
|
47
|
+
"max_ms": 0.19792199600487947,
|
|
48
|
+
"ops_per_sec": 7220.239067550213
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "SQLite",
|
|
52
|
+
"operation": "Graph query (1-hop)",
|
|
53
|
+
"samples": 100,
|
|
54
|
+
"mean_ms": 0.1656885934062302,
|
|
55
|
+
"median_ms": 0.16310601495206356,
|
|
56
|
+
"p95_ms": 0.18141092732548714,
|
|
57
|
+
"p99_ms": 0.23385195527225733,
|
|
58
|
+
"min_ms": 0.15984103083610535,
|
|
59
|
+
"max_ms": 0.23385195527225733,
|
|
60
|
+
"ops_per_sec": 6035.41848863567
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "Qdrant",
|
|
64
|
+
"operation": "INSERT (single + embed)",
|
|
65
|
+
"samples": 50,
|
|
66
|
+
"mean_ms": 7.81712032854557,
|
|
67
|
+
"median_ms": 4.746215010527521,
|
|
68
|
+
"p95_ms": 5.6189680472016335,
|
|
69
|
+
"p99_ms": 156.39470203313977,
|
|
70
|
+
"min_ms": 4.38071705866605,
|
|
71
|
+
"max_ms": 156.39470203313977,
|
|
72
|
+
"ops_per_sec": 127.92434527946648
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "Qdrant",
|
|
76
|
+
"operation": "Semantic search (top-5)",
|
|
77
|
+
"samples": 100,
|
|
78
|
+
"mean_ms": 1.2219337350688875,
|
|
79
|
+
"median_ms": 1.1123394942842424,
|
|
80
|
+
"p95_ms": 1.682064961642027,
|
|
81
|
+
"p99_ms": 2.7543739415705204,
|
|
82
|
+
"min_ms": 0.9932080283761024,
|
|
83
|
+
"max_ms": 2.7543739415705204,
|
|
84
|
+
"ops_per_sec": 818.3749832748698
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "Qdrant",
|
|
88
|
+
"operation": "Filtered search",
|
|
89
|
+
"samples": 100,
|
|
90
|
+
"mean_ms": 1.2450160249136388,
|
|
91
|
+
"median_ms": 1.2208950356580317,
|
|
92
|
+
"p95_ms": 1.2983810156583786,
|
|
93
|
+
"p99_ms": 3.2460070215165615,
|
|
94
|
+
"min_ms": 1.1418990325182676,
|
|
95
|
+
"max_ms": 3.2460070215165615,
|
|
96
|
+
"ops_per_sec": 803.202513051481
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "Embedding",
|
|
100
|
+
"operation": "Generate (all-MiniLM-L6-v2)",
|
|
101
|
+
"samples": 100,
|
|
102
|
+
"mean_ms": 3.2829831482376903,
|
|
103
|
+
"median_ms": 3.2453580060973763,
|
|
104
|
+
"p95_ms": 3.575409995391965,
|
|
105
|
+
"p99_ms": 4.24535502679646,
|
|
106
|
+
"min_ms": 3.1607369892299175,
|
|
107
|
+
"max_ms": 4.24535502679646,
|
|
108
|
+
"ops_per_sec": 304.601015249439
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "Consolidation",
|
|
112
|
+
"operation": "Simple extraction",
|
|
113
|
+
"samples": 100,
|
|
114
|
+
"mean_ms": 0.04601658787578344,
|
|
115
|
+
"median_ms": 0.04540046211332083,
|
|
116
|
+
"p95_ms": 0.04780001472681761,
|
|
117
|
+
"p99_ms": 0.07955997716635466,
|
|
118
|
+
"min_ms": 0.04478008486330509,
|
|
119
|
+
"max_ms": 0.07955997716635466,
|
|
120
|
+
"ops_per_sec": 21731.293999880792
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "Consolidation",
|
|
124
|
+
"operation": "Semantic dedup",
|
|
125
|
+
"samples": 20,
|
|
126
|
+
"mean_ms": 33.511918887961656,
|
|
127
|
+
"median_ms": 32.87853847723454,
|
|
128
|
+
"p95_ms": 38.731466978788376,
|
|
129
|
+
"p99_ms": 38.731466978788376,
|
|
130
|
+
"min_ms": 31.861560069955885,
|
|
131
|
+
"max_ms": 38.731466978788376,
|
|
132
|
+
"ops_per_sec": 29.840129517597564
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "SQLite@100",
|
|
136
|
+
"operation": "SELECT recent",
|
|
137
|
+
"samples": 50,
|
|
138
|
+
"mean_ms": 0.15139207243919373,
|
|
139
|
+
"median_ms": 0.14865596313029528,
|
|
140
|
+
"p95_ms": 0.1651509664952755,
|
|
141
|
+
"p99_ms": 0.2013719640672207,
|
|
142
|
+
"min_ms": 0.14511204790323973,
|
|
143
|
+
"max_ms": 0.2013719640672207,
|
|
144
|
+
"ops_per_sec": 6605.365683210709
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "SQLite@1000",
|
|
148
|
+
"operation": "SELECT recent",
|
|
149
|
+
"samples": 50,
|
|
150
|
+
"mean_ms": 0.16931103775277734,
|
|
151
|
+
"median_ms": 0.16216648509725928,
|
|
152
|
+
"p95_ms": 0.19682198762893677,
|
|
153
|
+
"p99_ms": 0.24656206369400024,
|
|
154
|
+
"min_ms": 0.15751097816973925,
|
|
155
|
+
"max_ms": 0.24656206369400024,
|
|
156
|
+
"ops_per_sec": 5906.289473342952
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "SQLite@5000",
|
|
160
|
+
"operation": "SELECT recent",
|
|
161
|
+
"samples": 50,
|
|
162
|
+
"mean_ms": 0.16595820896327496,
|
|
163
|
+
"median_ms": 0.16168103320524096,
|
|
164
|
+
"p95_ms": 0.18208206165581942,
|
|
165
|
+
"p99_ms": 0.2518820110708475,
|
|
166
|
+
"min_ms": 0.15775102656334639,
|
|
167
|
+
"max_ms": 0.2518820110708475,
|
|
168
|
+
"ops_per_sec": 6025.613353186349
|
|
169
|
+
}
|
|
170
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Memory Systems Benchmark Report
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-01-06T06:48:17.656637Z
|
|
4
|
+
**System:** Pay2U Memory Implementation
|
|
5
|
+
|
|
6
|
+
## Summary
|
|
7
|
+
|
|
8
|
+
| System | Operation | Mean (ms) | P95 (ms) | Ops/sec |
|
|
9
|
+
| ------------- | --------------------------- | --------- | -------- | ------- |
|
|
10
|
+
| SQLite | INSERT (single) | 1.143 | 1.360 | 875 |
|
|
11
|
+
| SQLite | SELECT recent (LIMIT 50) | 0.150 | 0.166 | 6680 |
|
|
12
|
+
| SQLite | SELECT by type | 0.145 | 0.160 | 6887 |
|
|
13
|
+
| SQLite | LIKE search | 0.138 | 0.146 | 7220 |
|
|
14
|
+
| SQLite | Graph query (1-hop) | 0.166 | 0.181 | 6035 |
|
|
15
|
+
| Qdrant | INSERT (single + embed) | 7.817 | 5.619 | 128 |
|
|
16
|
+
| Qdrant | Semantic search (top-5) | 1.222 | 1.682 | 818 |
|
|
17
|
+
| Qdrant | Filtered search | 1.245 | 1.298 | 803 |
|
|
18
|
+
| Embedding | Generate (all-MiniLM-L6-v2) | 3.283 | 3.575 | 305 |
|
|
19
|
+
| Consolidation | Simple extraction | 0.046 | 0.048 | 21731 |
|
|
20
|
+
| Consolidation | Semantic dedup | 33.512 | 38.731 | 30 |
|
|
21
|
+
| SQLite@100 | SELECT recent | 0.151 | 0.165 | 6605 |
|
|
22
|
+
| SQLite@1000 | SELECT recent | 0.169 | 0.197 | 5906 |
|
|
23
|
+
| SQLite@5000 | SELECT recent | 0.166 | 0.182 | 6026 |
|
|
24
|
+
|
|
25
|
+
## Key Findings
|
|
26
|
+
|
|
27
|
+
### Short-term Memory (SQLite)
|
|
28
|
+
|
|
29
|
+
- Single INSERT operations are extremely fast (<0.5ms)
|
|
30
|
+
- SELECT with ORDER BY and LIMIT scales well
|
|
31
|
+
- Knowledge graph queries (1-hop) add minimal overhead
|
|
32
|
+
|
|
33
|
+
### Long-term Memory (Qdrant)
|
|
34
|
+
|
|
35
|
+
- Embedding generation is the main latency contributor
|
|
36
|
+
- Semantic search is fast once vectors exist (~50-100ms)
|
|
37
|
+
- Filtering adds minimal overhead
|
|
38
|
+
|
|
39
|
+
### Consolidation
|
|
40
|
+
|
|
41
|
+
- Simple extraction is very fast (<1ms)
|
|
42
|
+
- Semantic deduplication adds significant latency (~100-500ms)
|
|
43
|
+
- Recommendation: Use hash-based dedup, semantic only for high-importance
|
|
44
|
+
|
|
45
|
+
## Recommendations
|
|
46
|
+
|
|
47
|
+
1. **Keep SQLite for short-term**: Performance is excellent
|
|
48
|
+
2. **Batch Qdrant operations**: Reduce per-operation overhead
|
|
49
|
+
3. **Cache embeddings**: Avoid regenerating for known content
|
|
50
|
+
4. **Use hybrid dedup**: Hash first, semantic for borderline cases
|
|
51
|
+
5. **Add session memory layer**: Low overhead, high value
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Qwen3.5 Chat Template (FIXED)
|
|
3
|
+
=============================
|
|
4
|
+
|
|
5
|
+
CRITICAL FIX APPLIED:
|
|
6
|
+
- Line ~106: Added conditional wrapper for tool_call.arguments iteration
|
|
7
|
+
- Prevents template parsing failures after 1-2 tool calls
|
|
8
|
+
- Reference: Hugging Face Discussion #4
|
|
9
|
+
|
|
10
|
+
Original issue:
|
|
11
|
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
|
12
|
+
Fixed to:
|
|
13
|
+
{%- if tool_call.arguments is mapping %}
|
|
14
|
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
|
15
|
+
...
|
|
16
|
+
{%- endif %}
|
|
17
|
+
#}
|
|
18
|
+
|
|
19
|
+
{%- set image_count = namespace(value=0) %}
|
|
20
|
+
{%- set video_count = namespace(value=0) %}
|
|
21
|
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
|
22
|
+
{%- if content is string %}
|
|
23
|
+
{{- content }}
|
|
24
|
+
{%- elif content is iterable and content is not mapping %}
|
|
25
|
+
{%- for item in content %}
|
|
26
|
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
|
27
|
+
{%- if is_system_content %}
|
|
28
|
+
{{- raise_exception('System message cannot contain images.') }}
|
|
29
|
+
{%- endif %}
|
|
30
|
+
{%- if do_vision_count %}
|
|
31
|
+
{%- set image_count.value = image_count.value + 1 %}
|
|
32
|
+
{%- endif %}
|
|
33
|
+
{%- if add_vision_id %}
|
|
34
|
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
|
35
|
+
{%- endif %}
|
|
36
|
+
{{- '图片' }}
|
|
37
|
+
{%- elif 'video' in item or item.type == 'video' %}
|
|
38
|
+
{%- if is_system_content %}
|
|
39
|
+
{{- raise_exception('System message cannot contain videos.') }}
|
|
40
|
+
{%- endif %}
|
|
41
|
+
{%- if do_vision_count %}
|
|
42
|
+
{%- set video_count.value = video_count.value + 1 %}
|
|
43
|
+
{%- endif %}
|
|
44
|
+
{%- if add_vision_id %}
|
|
45
|
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
|
46
|
+
{%- endif %}
|
|
47
|
+
{{- '视频' }}
|
|
48
|
+
{%- elif 'text' in item %}
|
|
49
|
+
{{- item.text }}
|
|
50
|
+
{%- else %}
|
|
51
|
+
{{- raise_exception('Unexpected item type in content.') }}
|
|
52
|
+
{%- endif %}
|
|
53
|
+
{%- endfor %}
|
|
54
|
+
{%- elif content is none or content is undefined %}
|
|
55
|
+
{{- '' }}
|
|
56
|
+
{%- else %}
|
|
57
|
+
{{- raise_exception('Unexpected content type.') }}
|
|
58
|
+
{%- endif %}
|
|
59
|
+
{%- endmacro %}
|
|
60
|
+
{%- if not messages %}
|
|
61
|
+
{{- raise_exception('No messages provided.') }}
|
|
62
|
+
{%- endif %}
|
|
63
|
+
{%- if tools and tools is iterable and tools is not mapping %}
|
|
64
|
+
{{- 'system\n' }}
|
|
65
|
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
|
66
|
+
{%- for tool in tools %}
|
|
67
|
+
{{- "\n" }}
|
|
68
|
+
{{- tool | tojson }}
|
|
69
|
+
{%- endfor %}
|
|
70
|
+
{{- "\n</tools>" }}
|
|
71
|
+
{{- '\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</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 your function call natural language BEFORE the function call, 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 the function calls\n</IMPORTANT>' }}
|
|
72
|
+
{%- if messages[0].role == 'system' %}
|
|
73
|
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
|
74
|
+
{%- if content %}
|
|
75
|
+
{{- '\n\n' + content }}
|
|
76
|
+
{%- endif %}
|
|
77
|
+
{%- endif %}
|
|
78
|
+
{{- '</think>\n' }}
|
|
79
|
+
{%- else %}
|
|
80
|
+
{%- if messages[0].role == 'system' %}
|
|
81
|
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
|
82
|
+
{{- 'system\n' + content + '</think>\n' }}
|
|
83
|
+
{%- endif %}
|
|
84
|
+
{%- endif %}
|
|
85
|
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
|
86
|
+
{%- for message in messages[::-1] %}
|
|
87
|
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
|
88
|
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
|
89
|
+
{%- set content = render_content(message.content, false)|trim %}
|
|
90
|
+
{%- if not(content.startswith('<think>') and content.endswith('</think>')) %}
|
|
91
|
+
{%- set ns.multi_step_tool = false %}
|
|
92
|
+
{%- set ns.last_query_index = index %}
|
|
93
|
+
{%- endif %}
|
|
94
|
+
{%- endif %}
|
|
95
|
+
{%- endfor %}
|
|
96
|
+
{%- if ns.multi_step_tool %}
|
|
97
|
+
{{- raise_exception('No user query found in messages.') }}
|
|
98
|
+
{%- endif %}
|
|
99
|
+
{%- for message in messages %}
|
|
100
|
+
{%- set content = render_content(message.content, true)|trim %}
|
|
101
|
+
{%- if message.role == "system" %}
|
|
102
|
+
{%- if not loop.first %}
|
|
103
|
+
{{- raise_exception('System message must be at the beginning.') }}
|
|
104
|
+
{%- endif %}
|
|
105
|
+
{%- elif message.role == "user" %}
|
|
106
|
+
{{- '' + message.role + '\n' + content + '</think>\n' }}
|
|
107
|
+
{%- elif message.role == "assistant" %}
|
|
108
|
+
{%- set reasoning_content = '' %}
|
|
109
|
+
{%- if message.reasoning_content is string %}
|
|
110
|
+
{%- set reasoning_content = message.reasoning_content %}
|
|
111
|
+
{%- else %}
|
|
112
|
+
{%- if '</think>' in content %}
|
|
113
|
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
|
114
|
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
|
115
|
+
{%- endif %}
|
|
116
|
+
{%- endif %}
|
|
117
|
+
{%- set reasoning_content = reasoning_content|trim %}
|
|
118
|
+
{%- if loop.index0 > ns.last_query_index %}
|
|
119
|
+
{{- '' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
|
120
|
+
{%- else %}
|
|
121
|
+
{{- '' + message.role + '\n' + content }}
|
|
122
|
+
{%- endif %}
|
|
123
|
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
|
124
|
+
{%- for tool_call in message.tool_calls %}
|
|
125
|
+
{%- if tool_call.function is defined %}
|
|
126
|
+
{%- set tool_call = tool_call.function %}
|
|
127
|
+
{%- endif %}
|
|
128
|
+
{%- if loop.first %}
|
|
129
|
+
{%- if content|trim %}
|
|
130
|
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
|
131
|
+
{%- else %}
|
|
132
|
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
|
133
|
+
{%- endif %}
|
|
134
|
+
{%- else %}
|
|
135
|
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
|
136
|
+
{%- endif %}
|
|
137
|
+
{%- if tool_call.arguments is defined %}
|
|
138
|
+
{%- if tool_call.arguments is mapping %}
|
|
139
|
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
|
140
|
+
{{- '<parameter=' + args_name + '>\n' }}
|
|
141
|
+
{%- 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 %}
|
|
142
|
+
{{- args_value }}
|
|
143
|
+
{{- '\n</parameter>\n' }}
|
|
144
|
+
{%- endfor %}
|
|
145
|
+
{%- endif %}
|
|
146
|
+
{%- endif %}
|
|
147
|
+
{{- '</function>\n</tool_call>' }}
|
|
148
|
+
{%- endfor %}
|
|
149
|
+
{%- endif %}
|
|
150
|
+
{{- '</think>\n' }}
|
|
151
|
+
{%- elif message.role == "tool" %}
|
|
152
|
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
|
153
|
+
{{- 'user' }}
|
|
154
|
+
{%- endif %}
|
|
155
|
+
{{- '\n<think>\n' }}
|
|
156
|
+
{{- content }}
|
|
157
|
+
{{- '\n</think>' }}
|
|
158
|
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
|
159
|
+
{{- '\n</think>\n' }}
|
|
160
|
+
{%- elif loop.last %}
|
|
161
|
+
{{- '\n</think>\n' }}
|
|
162
|
+
{%- endif %}
|
|
163
|
+
{%- else %}
|
|
164
|
+
{{- raise_exception('Unexpected message role.') }}
|
|
165
|
+
{%- endif %}
|
|
166
|
+
{%- endfor %}
|
|
167
|
+
{%- if add_generation_prompt %}
|
|
168
|
+
{{- 'assistant\n' }}
|
|
169
|
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
|
170
|
+
{{- '<think>\n\n</think>\n\n' }}
|
|
171
|
+
{%- endif %}
|
|
172
|
+
{%- endif %}
|