chore: ⬆️ Update ggml-org/llama.cpp to f2cc7282ce0042641df55e0e563b75e824e2b647 (#12601)

* ⬆️ Update ggml-org/llama.cpp

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(llama-cpp): preserve chat session state

Newer llama.cpp parsers return template state outside the request JSON.
Pass that state to both inference tasks and response readers so grammar,
tool calls, and reasoning remain available in both chat paths.

Detect the parser API during preparation to preserve older fork builds.

Assisted-by: Codex:gpt-6

---------

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: mudler <2420543+mudler@users.noreply.github.com>
Co-authored-by: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-12 09:35:15 +02:00
1 parent ca35f6e710
commit 615446ae75
4 files changed
+44 -2

No files matched your search

+32
View File
@@ -1783,6 +1783,9 @@ public:
std::string prompt_str;
std::vector<raw_buffer> files; // Declare files early so it's accessible in both branches
#if LOCALAI_HAS_CHAT_SESSION
common_chat_session chat_session;
#endif
// Handle chat templates when UseTokenizerTemplate is enabled and Messages are provided
if (request->usetokenizertemplate() && request->messages_size() > 0 && ctx_server.impl->chat_params.tmpls != nullptr) {
// Convert proto Messages to JSON format compatible with oaicompat_chat_params_parse
@@ -2038,7 +2041,12 @@ public:
}
}
#if LOCALAI_HAS_CHAT_SESSION
json parsed_data = oaicompat_chat_params_parse(
ctx_server.impl->vocab, body_json, ctx_server.impl->chat_params, files, chat_session);
#else
json parsed_data = oaicompat_chat_params_parse(body_json, ctx_server.impl->chat_params, files);
#endif
// Debug: Log tools after template processing
if (parsed_data.contains("tools")) {
@@ -2157,6 +2165,10 @@ public:
ctx_server.get_meta().slot_n_ctx,
ctx_server.get_meta().logit_bias_eog,
data);
#endif
#if LOCALAI_HAS_CHAT_SESSION
// The parser now keeps grammar, stops and message spans in the session.
task.apply_chat_session(chat_session);
#endif
task.id_slot = json_value(data, "id_slot", -1);
@@ -2171,7 +2183,11 @@ public:
tasks.push_back(std::move(task));
}
#if LOCALAI_HAS_CHAT_SESSION
rd.post_tasks(std::move(tasks), chat_session);
#else
rd.post_tasks(std::move(tasks));
#endif
} catch (const std::exception & e) {
return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, e.what());
}
@@ -2368,6 +2384,9 @@ public:
std::string prompt_str;
std::vector<raw_buffer> files; // Declare files early so it's accessible in both branches
#if LOCALAI_HAS_CHAT_SESSION
common_chat_session chat_session;
#endif
// Handle chat templates when UseTokenizerTemplate is enabled and Messages are provided
if (request->usetokenizertemplate() && request->messages_size() > 0 && ctx_server.impl->chat_params.tmpls != nullptr) {
// Convert proto Messages to JSON format compatible with oaicompat_chat_params_parse
@@ -2624,7 +2643,12 @@ public:
}
}
#if LOCALAI_HAS_CHAT_SESSION
json parsed_data = oaicompat_chat_params_parse(
ctx_server.impl->vocab, body_json, ctx_server.impl->chat_params, files, chat_session);
#else
json parsed_data = oaicompat_chat_params_parse(body_json, ctx_server.impl->chat_params, files);
#endif
// Debug: Log tools after template processing
if (parsed_data.contains("tools")) {
@@ -2746,6 +2770,10 @@ public:
ctx_server.get_meta().slot_n_ctx,
ctx_server.get_meta().logit_bias_eog,
data);
#endif
#if LOCALAI_HAS_CHAT_SESSION
// The parser now keeps grammar, stops and message spans in the session.
task.apply_chat_session(chat_session);
#endif
task.id_slot = json_value(data, "id_slot", -1);
@@ -2758,7 +2786,11 @@ public:
tasks.push_back(std::move(task));
}
#if LOCALAI_HAS_CHAT_SESSION
rd.post_tasks(std::move(tasks), chat_session);
#else
rd.post_tasks(std::move(tasks));
#endif
} catch (const std::exception & e) {
return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, e.what());
}