Commit 609debc
runtime: inject system prompt via rkllm_set_chat_template (not inlined in user msg)
Lab smoke test after the role-based refactor showed the model's first
thought event regurgitating the entire SYSTEM_PROMPT_TEMPLATE — because
the prior fix inlined the system rules into the user message as
'System: [rules]\\n\\nUser request: [prompt]'. The model treated the
rules as additional context to acknowledge / restate.
Proper fix: configure session-level chat template via
rkllm_set_chat_template(handle, system, prefix, postfix) so the
runtime injects the system in the canonical <|im_start|>system\\n...
<|im_end|> slot. The model recognises it as instructions, not as
something to repeat back.
Trade-off documented earlier — calling set_chat_template disables
the runtime's automatic enable_thinking handling. We work around by
including '<think>\\n' in the postfix, so every assistant turn starts
inside a think block:
postfix = '<|im_end|>\\n<|im_start|>assistant\\n<think>\\n'
This still keeps <|im_end|> as the stop-token signal (the first
token of the postfix), so the runtime correctly terminates each
turn at <|im_end|> — no more fictitious continuations.
55/55 unit tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 6bf700a commit 609debc
1 file changed
Lines changed: 28 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
1103 | 1102 | | |
1104 | 1103 | | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1109 | 1125 | | |
1110 | | - | |
| 1126 | + | |
1111 | 1127 | | |
1112 | 1128 | | |
1113 | 1129 | | |
| |||
0 commit comments