Skip to content

Commit a0f1290

Browse files
committed
Use --json output for flm
1 parent 3466e7d commit a0f1290

File tree

5 files changed

+191
-182
lines changed

5 files changed

+191
-182
lines changed

src/cpp/include/lemon/model_manager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class ModelManager {
122122
// Get list of installed FLM models (for caching)
123123
std::vector<std::string> get_flm_installed_models();
124124

125+
// Get list of all available FLM models from 'flm list --json'
126+
std::vector<ModelInfo> get_flm_available_models();
127+
125128
// Refresh FLM model download status from 'flm list' (call after FLM install/upgrade)
126129
void refresh_flm_download_status();
127130

src/cpp/resources/server_models.json

Lines changed: 0 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -998,103 +998,6 @@
998998
"suggested": true,
999999
"size": 14.4
10001000
},
1001-
"gpt-oss-20b-FLM": {
1002-
"checkpoint": "gpt-oss:20b",
1003-
"recipe": "flm",
1004-
"suggested": true,
1005-
"labels": [
1006-
"reasoning"
1007-
],
1008-
"size": 13.4
1009-
},
1010-
"Gemma3-1b-it-FLM": {
1011-
"checkpoint": "gemma3:1b",
1012-
"recipe": "flm",
1013-
"suggested": true,
1014-
"size": 1.17
1015-
},
1016-
"Gemma3-4b-it-FLM": {
1017-
"checkpoint": "gemma3:4b",
1018-
"recipe": "flm",
1019-
"suggested": true,
1020-
"labels": [
1021-
"vision"
1022-
],
1023-
"size": 5.26
1024-
},
1025-
"Qwen3-VL-4B-Instruct-FLM": {
1026-
"checkpoint": "qwen3vl-it:4b",
1027-
"recipe": "flm",
1028-
"suggested": true,
1029-
"labels": [
1030-
"hot",
1031-
"vision"
1032-
],
1033-
"size": 3.85
1034-
},
1035-
"Qwen3-0.6B-FLM": {
1036-
"checkpoint": "qwen3:0.6b",
1037-
"recipe": "flm",
1038-
"suggested": true,
1039-
"labels": [
1040-
"reasoning"
1041-
],
1042-
"size": 0.66
1043-
},
1044-
"Qwen3-4B-Instruct-2507-FLM": {
1045-
"checkpoint": "qwen3-it:4b",
1046-
"recipe": "flm",
1047-
"suggested": true,
1048-
"labels": [
1049-
"tool-calling"
1050-
],
1051-
"size": 3.07
1052-
},
1053-
"Qwen3-8b-FLM": {
1054-
"checkpoint": "qwen3:8b",
1055-
"recipe": "flm",
1056-
"suggested": true,
1057-
"labels": [
1058-
"reasoning"
1059-
],
1060-
"size": 5.57
1061-
},
1062-
"Llama-3.1-8B-FLM": {
1063-
"checkpoint": "llama3.1:8b",
1064-
"recipe": "flm",
1065-
"suggested": true,
1066-
"size": 5.36
1067-
},
1068-
"Llama-3.2-1B-FLM": {
1069-
"checkpoint": "llama3.2:1b",
1070-
"recipe": "flm",
1071-
"suggested": true,
1072-
"size": 1.21
1073-
},
1074-
"Llama-3.2-3B-FLM": {
1075-
"checkpoint": "llama3.2:3b",
1076-
"recipe": "flm",
1077-
"suggested": true,
1078-
"size": 2.62
1079-
},
1080-
"LFM2-1.2B-FLM": {
1081-
"checkpoint": "lfm2:1.2b",
1082-
"recipe": "flm",
1083-
"suggested": true,
1084-
"size": 0.96
1085-
},
1086-
"LFM2.5-1.2B-Instruct-FLM": {
1087-
"checkpoint": "lfm2.5-it:1.2b",
1088-
"recipe": "flm",
1089-
"suggested": true,
1090-
"size": 0.96
1091-
},
1092-
"Phi-4-Mini-Instruct-FLM": {
1093-
"checkpoint": "phi4-mini-it:4b",
1094-
"recipe": "flm",
1095-
"suggested": true,
1096-
"size": 3.39
1097-
},
10981001
"Whisper-Tiny": {
10991002
"checkpoints": {
11001003
"main": "ggerganov/whisper.cpp:ggml-tiny.bin",
@@ -1174,48 +1077,6 @@
11741077
],
11751078
"size": 1.55
11761079
},
1177-
"DeepSeek-R1-Distill-Llama-8B-FLM": {
1178-
"checkpoint": "deepseek-r1:8b",
1179-
"recipe": "flm",
1180-
"suggested": true,
1181-
"labels": [
1182-
"reasoning"
1183-
],
1184-
"size": 5.36
1185-
},
1186-
"DeepSeek-R1-0528-Qwen3-8B-FLM": {
1187-
"checkpoint": "deepseek-r1-0528:8b",
1188-
"recipe": "flm",
1189-
"suggested": true,
1190-
"labels": [
1191-
"reasoning"
1192-
],
1193-
"size": 5.57
1194-
},
1195-
"LFM2-2.6B-FLM": {
1196-
"checkpoint": "lfm2:2.6b",
1197-
"recipe": "flm",
1198-
"suggested": true,
1199-
"size": 1.75
1200-
},
1201-
"Qwen3-1.7B-FLM": {
1202-
"checkpoint": "qwen3:1.7b",
1203-
"recipe": "flm",
1204-
"suggested": true,
1205-
"labels": [
1206-
"reasoning"
1207-
],
1208-
"size": 1.59
1209-
},
1210-
"LFM2.5-1.2B-Thinking-FLM": {
1211-
"checkpoint": "lfm2.5-tk:1.2b",
1212-
"recipe": "flm",
1213-
"suggested": true,
1214-
"labels": [
1215-
"reasoning"
1216-
],
1217-
"size": 0.96
1218-
},
12191080
"SD-Turbo": {
12201081
"checkpoint": "stabilityai/sd-turbo:sd_turbo.safetensors",
12211082
"recipe": "sd-cpp",
@@ -1342,38 +1203,5 @@
13421203
"speech"
13431204
],
13441205
"size": 0.34
1345-
},
1346-
"Qwen2.5-3B-Instruct-FLM": {
1347-
"checkpoint": "qwen2.5-it:3b",
1348-
"recipe": "flm",
1349-
"suggested": true,
1350-
"size": 2.41
1351-
},
1352-
"Qwen2.5-VL-3B-Instruct-FLM": {
1353-
"checkpoint": "qwen2.5vl-it:3b",
1354-
"recipe": "flm",
1355-
"suggested": true,
1356-
"labels": [
1357-
"vision"
1358-
],
1359-
"size": 3.74
1360-
},
1361-
"Translategemma-4B-Instruct-FLM": {
1362-
"checkpoint": "translategemma:4b",
1363-
"recipe": "flm",
1364-
"suggested": true,
1365-
"labels": [
1366-
"vision"
1367-
],
1368-
"size": 4.44
1369-
},
1370-
"Medgemma1.5-4B-Instruct-FLM": {
1371-
"checkpoint": "medgemma1.5:4b",
1372-
"recipe": "flm",
1373-
"suggested": true,
1374-
"labels": [
1375-
"vision"
1376-
],
1377-
"size": 4.44
13781206
}
13791207
}

src/cpp/server/backends/fastflowlm_server.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ std::string FastFlowLMServer::get_flm_installed_version() {
457457
}
458458

459459
try {
460-
// Run flm --version command using the full path (not relying on PATH)
461-
std::string command = "\"" + flm_path + "\" --version 2>&1";
460+
// Run flm version --json command using the full path (not relying on PATH)
461+
std::string command = "\"" + flm_path + "\" version --json 2>&1";
462462
#ifdef _WIN32
463463
FILE* pipe = _popen(command.c_str(), "r");
464464
#else
@@ -480,6 +480,24 @@ std::string FastFlowLMServer::get_flm_installed_version() {
480480
pclose(pipe);
481481
#endif
482482

483+
// Parse JSON output: { "version": "0.9.34" }
484+
try {
485+
json j = utils::JsonUtils::parse(output);
486+
if (j.contains("version") && j["version"].is_string()) {
487+
std::string version_str = j["version"].get<std::string>();
488+
// If the version doesn't start with 'v', prepend it
489+
// for backend_versions.json compatibility (e.g. "v0.9.34").
490+
if (!version_str.empty() && version_str[0] != 'v') {
491+
cached = "v" + version_str;
492+
} else {
493+
cached = version_str;
494+
}
495+
return cached;
496+
}
497+
} catch (...) {
498+
// Fallback to legacy parsing if JSON parsing fails
499+
}
500+
483501
// Parse output like "FLM v0.9.23" - look for "FLM v" specifically
484502
// to avoid matching 'v' in other text (like error messages)
485503
size_t pos = output.find("FLM v");

0 commit comments

Comments
 (0)