MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / find_model_list

Function find_model_list

src/common/utils.cpp:22–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace utils {
21
22std::string find_model_list() {
23 std::string install_prefix = CMAKE_INSTALL_PREFIX;
24
25 // 1. Check FLM_CONFIG_PATH environment variable
26 const char* env_path = std::getenv("FLM_CONFIG_PATH");
27 if (env_path && *env_path) {
28 if (std::filesystem::exists(env_path)) {
29 std::cerr << "[FLM] Using custom model list path: " << env_path << std::endl;
30 return env_path;
31 }
32 }
33
34 // 2. Check for install prefix
35 std::string installed_path = install_prefix + "/share/flm/model_list.json";
36 if (std::filesystem::exists(installed_path)) {
37 return installed_path;
38 }
39
40 // 3. Check relative to executable
41 std::string exe_dir = get_executable_directory();
42 std::string exe_relative_path = exe_dir + "/model_list.json";
43 if (std::filesystem::exists(exe_relative_path)) {
44 return exe_relative_path;
45 }
46
47 // 4. Check current working directory
48 if (std::filesystem::exists("model_list.json")) {
49 return "model_list.json";
50 }
51
52 // If not found, throw an error
53 throw std::runtime_error("model_list.json not found. Please set FLM_CONFIG_PATH or place it next to the executable.");
54}
55
56std::string find_xclbin_path() {
57 std::string xclbin_prefix = CMAKE_XCLBIN_PREFIX;

Callers 1

mainFunction · 0.85

Calls 1

get_executable_directoryFunction · 0.85

Tested by

no test coverage detected