Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/backends/llamacpp/rac_backend_llamacpp_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <cstring>
#include <mutex>

#include <nlohmann/json.hpp>

#include "rac/core/rac_core.h"
#include "rac/core/rac_error.h"
#include "rac/core/rac_logger.h"
Expand Down Expand Up @@ -66,10 +68,28 @@ static rac_result_t llamacpp_vtable_generate_stream(void* impl, const char* prom
static rac_result_t llamacpp_vtable_get_info(void* impl, rac_llm_info_t* out_info) {
if (!out_info)
return RAC_ERROR_NULL_POINTER;

out_info->is_ready = rac_llm_llamacpp_is_model_loaded(impl);
out_info->supports_streaming = RAC_TRUE;
out_info->current_model = nullptr;
out_info->context_length = 0;
out_info->context_length = 0; // Default if model not loaded or info unavailable

// Get actual context_length from model info JSON when model is loaded
if (out_info->is_ready) {
char* json_str = nullptr;
if (rac_llm_llamacpp_get_model_info(impl, &json_str) == RAC_SUCCESS && json_str) {
try {
auto json = nlohmann::json::parse(json_str);
if (json.contains("context_size") && json["context_size"].is_number()) {
out_info->context_length = json["context_size"].get<int32_t>();
}
} catch (...) {
// JSON parse error - context_length remains 0
}
free(json_str);
}
}

return RAC_SUCCESS;
}

Expand Down
Loading