|
| 1 | +diff --git a/src/cpp/server/model_manager.cpp b/src/cpp/server/model_manager.cpp |
| 2 | +index 19371d57..a5d9e077 100644 |
| 3 | +--- a/src/cpp/server/model_manager.cpp |
| 4 | ++++ b/src/cpp/server/model_manager.cpp |
| 5 | +@@ -1456,8 +1456,10 @@ std::vector<std::string> ModelManager::get_flm_installed_models() { |
| 6 | + #endif |
| 7 | + |
| 8 | + // Parse output: { "models": [ { "name": "modelname:tag", ... }, ... ] } |
| 9 | ++ // FLM may emit log lines to stdout before the JSON, so find the first '{'. |
| 10 | + try { |
| 11 | +- json j = JsonUtils::parse(output); |
| 12 | ++ size_t json_start = output.find('{'); |
| 13 | ++ json j = JsonUtils::parse(json_start != std::string::npos ? output.substr(json_start) : output); |
| 14 | + if (j.contains("models") && j["models"].is_array()) { |
| 15 | + for (const auto& model : j["models"]) { |
| 16 | + if (model.contains("name") && model["name"].is_string()) { |
| 17 | +@@ -1537,8 +1539,10 @@ std::vector<ModelInfo> ModelManager::get_flm_available_models() { |
| 18 | + #endif |
| 19 | + |
| 20 | + // Parse output: { "models": [ { "name": "modelname:tag", "footprint": 1.23, ... }, ... ] } |
| 21 | ++ // FLM may emit log lines to stdout before the JSON, so find the first '{'. |
| 22 | + try { |
| 23 | +- json j = JsonUtils::parse(output); |
| 24 | ++ size_t json_start = output.find('{'); |
| 25 | ++ json j = JsonUtils::parse(json_start != std::string::npos ? output.substr(json_start) : output); |
| 26 | + if (j.contains("models") && j["models"].is_array()) { |
| 27 | + for (const auto& m : j["models"]) { |
| 28 | + if (m.contains("name") && m["name"].is_string()) { |
| 29 | +diff --git a/src/cpp/server/system_info.cpp b/src/cpp/server/system_info.cpp |
| 30 | +index 9b60150e..df8c37cd 100644 |
| 31 | +--- a/src/cpp/server/system_info.cpp |
| 32 | ++++ b/src/cpp/server/system_info.cpp |
| 33 | +@@ -1489,8 +1489,11 @@ std::string SystemInfo::get_flm_version() { |
| 34 | + #endif |
| 35 | + |
| 36 | + // Parse JSON output: { "version": "0.9.34" } |
| 37 | ++ // FLM may emit log lines to stdout before the JSON (e.g. "[FLM] Using custom model list path: ...") |
| 38 | ++ // so find the first '{' and parse from there. |
| 39 | + try { |
| 40 | +- json j = JsonUtils::parse(output); |
| 41 | ++ size_t json_start = output.find('{'); |
| 42 | ++ json j = JsonUtils::parse(json_start != std::string::npos ? output.substr(json_start) : output); |
| 43 | + if (j.contains("version") && j["version"].is_string()) { |
| 44 | + std::string version = j["version"].get<std::string>(); |
| 45 | + // If the version doesn't start with 'v', prepend it |
0 commit comments