summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJohannes Gäßler <johannesg@5d6.de>2024-05-08 21:53:08 +0200
committerGitHub <noreply@github.com>2024-05-08 21:53:08 +0200
commitc12452c7aec8a02264afc00196a13caa591a13ac (patch)
tree59fb7c3e827b71dac73312194cb24592eebac7a0 /common
parent9da243b36ac0b9d609adfaaa4c8f1cc8c592f737 (diff)
JSON: [key] -> .at(key), assert() -> GGML_ASSERT (#7143)
Diffstat (limited to 'common')
-rw-r--r--common/common.cpp14
-rw-r--r--common/json-schema-to-grammar.h4
2 files changed, 12 insertions, 6 deletions
diff --git a/common/common.cpp b/common/common.cpp
index 4a9da284..0535508b 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -1,4 +1,6 @@
#include "common.h"
+// Change JSON_ASSERT from assert() to GGML_ASSERT:
+#define JSON_ASSERT GGML_ASSERT
#include "json.hpp"
#include "json-schema-to-grammar.h"
#include "llama.h"
@@ -1969,18 +1971,18 @@ static bool llama_download_file(const std::string & url, const std::string & pat
try {
metadata_in >> metadata;
fprintf(stderr, "%s: previous metadata file found %s: %s\n", __func__, metadata_path.c_str(), metadata.dump().c_str());
- if (metadata.contains("url") && metadata["url"].is_string()) {
- auto previous_url = metadata["url"].get<std::string>();
+ if (metadata.contains("url") && metadata.at("url").is_string()) {
+ auto previous_url = metadata.at("url").get<std::string>();
if (previous_url != url) {
fprintf(stderr, "%s: Model URL mismatch: %s != %s\n", __func__, url.c_str(), previous_url.c_str());
return false;
}
}
- if (metadata.contains("etag") && metadata["etag"].is_string()) {
- etag = metadata["etag"];
+ if (metadata.contains("etag") && metadata.at("etag").is_string()) {
+ etag = metadata.at("etag");
}
- if (metadata.contains("lastModified") && metadata["lastModified"].is_string()) {
- last_modified = metadata["lastModified"];
+ if (metadata.contains("lastModified") && metadata.at("lastModified").is_string()) {
+ last_modified = metadata.at("lastModified");
}
} catch (const nlohmann::json::exception & e) {
fprintf(stderr, "%s: error reading metadata file %s: %s\n", __func__, metadata_path.c_str(), e.what());
diff --git a/common/json-schema-to-grammar.h b/common/json-schema-to-grammar.h
index e1abed30..41623b34 100644
--- a/common/json-schema-to-grammar.h
+++ b/common/json-schema-to-grammar.h
@@ -1,4 +1,8 @@
#pragma once
+
+#include "ggml.h"
+// Change JSON_ASSERT from assert() to GGML_ASSERT:
+#define JSON_ASSERT GGML_ASSERT
#include "json.hpp"
std::string json_schema_to_grammar(const nlohmann::ordered_json& schema);