MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / api_get

Function api_get

common/hf-cache.cpp:199–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static nl::json api_get(const std::string & url,
200 const std::string & token) {
201 auto [cli, parts] = common_http_client(url);
202
203 httplib::Headers headers = {
204 {"User-Agent", "llama-cpp/" + std::string(llama_build_info())},
205 {"Accept", "application/json"}
206 };
207
208 if (is_valid_hf_token(token)) {
209 headers.emplace("Authorization", "Bearer " + token);
210 } else if (!token.empty()) {
211 LOG_WRN("%s: invalid token, authentication disabled\n", __func__);
212 }
213
214 if (auto res = cli.Get(parts.path, headers)) {
215 auto body = res->body;
216
217 if (res->status == 200) {
218 return nl::json::parse(res->body);
219 }
220 try {
221 body = nl::json::parse(res->body)["error"].get<std::string>();
222 } catch (...) { }
223
224 throw std::runtime_error("GET failed (" + std::to_string(res->status) + "): " + body);
225 } else {
226 throw std::runtime_error("HTTPLIB failed: " + httplib::to_string(res.error()));
227 }
228}
229
230static std::string get_repo_commit(const std::string & repo_id,
231 const std::string & token) {

Callers 2

get_repo_commitFunction · 0.85
get_repo_filesFunction · 0.85

Calls 6

common_http_clientFunction · 0.85
stringClass · 0.85
is_valid_hf_tokenFunction · 0.85
to_stringFunction · 0.50
emptyMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected