MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / json_value

Function json_value

subprojects/llama.cpp/tools/server/server-common.h:33–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32template <typename T>
33static T json_value(const json & body, const std::string & key, const T & default_value) {
34 // Fallback null to default value
35 if (body.contains(key) && !body.at(key).is_null()) {
36 try {
37 return body.at(key);
38 } catch (NLOHMANN_JSON_NAMESPACE::detail::type_error const & err) {
39 LOG_WRN("Wrong type supplied for parameter '%s'. Expected '%s', using default value: %s\n", key.c_str(), json(default_value).type_name(), err.what());
40 return default_value;
41 }
42 } else {
43 return default_value;
44 }
45}
46
47// https://community.openai.com/t/openai-chat-list-of-error-codes-and-types/357791/11
48enum error_type {

Callers 15

errorMethod · 0.85
init_routesMethod · 0.85
params_from_json_cmplMethod · 0.85
res_errFunction · 0.85
init_routesMethod · 0.85
ex_wrapperFunction · 0.85
parse_lora_requestFunction · 0.85
handle_mediaFunction · 0.85

Calls 4

containsMethod · 0.65
atMethod · 0.65
type_nameMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected