NOTE: this is copied from common.cpp to avoid linking with libcommon
| 100 | |
| 101 | // NOTE: this is copied from common.cpp to avoid linking with libcommon |
| 102 | static std::string fs_get_cache_directory() { |
| 103 | std::string cache_directory = ""; |
| 104 | auto ensure_trailing_slash = [](std::string p) { |
| 105 | // Make sure to add trailing slash |
| 106 | if (p.back() != DIRECTORY_SEPARATOR) { |
| 107 | p += DIRECTORY_SEPARATOR; |
| 108 | } |
| 109 | return p; |
| 110 | }; |
| 111 | if (getenv("LLAMA_CACHE")) { |
| 112 | cache_directory = std::getenv("LLAMA_CACHE"); |
| 113 | } else { |
| 114 | #if defined(__linux__) || defined(__FreeBSD__) || defined(_AIX) || defined(__OpenBSD__) |
| 115 | if (std::getenv("XDG_CACHE_HOME")) { |
| 116 | cache_directory = std::getenv("XDG_CACHE_HOME"); |
| 117 | } else { |
| 118 | cache_directory = std::getenv("HOME") + std::string("/.cache/"); |
| 119 | } |
| 120 | #elif defined(__APPLE__) |
| 121 | cache_directory = std::getenv("HOME") + std::string("/Library/Caches/"); |
| 122 | #elif defined(_WIN32) |
| 123 | cache_directory = std::getenv("LOCALAPPDATA"); |
| 124 | #else |
| 125 | # error Unknown architecture |
| 126 | #endif |
| 127 | cache_directory = ensure_trailing_slash(cache_directory); |
| 128 | cache_directory += "llama.cpp"; |
| 129 | } |
| 130 | return ensure_trailing_slash(cache_directory); |
| 131 | } |
| 132 | |
| 133 | struct rpc_server_params { |
| 134 | std::string host = "127.0.0.1"; |