Skip to content

Commit 31f1cbd

Browse files
committed
Prepend system message from settings to API payload
Add the system message (if configured and non‑empty) to the beginning of the JSON array that is sent to the LlamaCPP server. The new entry uses the role "system" and contains the configured text. This ensures the server receives the system context before any user messages, improving generation behaviour without changing the existing message flow.
1 parent fb8ae0e commit 31f1cbd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llamachatmanager.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,15 @@ LlamaCppServerProps ChatManager::serverProps() const
543543
QJsonArray ChatManager::normalizeMsgsForAPI(const QVector<Message> &msgs)
544544
{
545545
QJsonArray res;
546+
547+
const QString sysMsgText = LlamaCpp::settings().systemMessage.value();
548+
if (!sysMsgText.trimmed().isEmpty()) {
549+
QJsonObject sys;
550+
sys["role"] = "system";
551+
sys["content"] = sysMsgText;
552+
res.append(sys);
553+
}
554+
546555
for (const Message &msg : msgs) {
547556
if (msg.role != "user" || msg.extra.isEmpty()) {
548557
QJsonObject out;

0 commit comments

Comments
 (0)