Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 927d188

Browse files
committed
update
1 parent fc83e91 commit 927d188

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

engine/utils/huggingface_utils.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ struct HuggingFaceGgufInfo {
3030

3131
static cpp::result<HuggingFaceGgufInfo, std::string> FromJson(
3232
const Json::Value& json) {
33+
if (json.isNull() || json.type() == Json::ValueType::nullValue) {
34+
return cpp::fail("gguf info is null");
35+
}
3336
try {
3437
return HuggingFaceGgufInfo{
3538
.total = json["total"].asUInt64(),
@@ -39,6 +42,13 @@ struct HuggingFaceGgufInfo {
3942
return cpp::fail("Failed to parse gguf info: " + std::string(e.what()));
4043
}
4144
}
45+
46+
Json::Value ToJson() {
47+
Json::Value root;
48+
root["total"] = total;
49+
root["architecture"] = architecture;
50+
return root;
51+
}
4252
};
4353

4454
struct HuggingFaceModelRepoInfo {
@@ -98,6 +108,12 @@ struct HuggingFaceModelRepoInfo {
98108
.createdAt = body["createdAt"].asString(),
99109
};
100110
}
111+
112+
Json::Value ToJson() {
113+
Json::Value root;
114+
root["gguf"] = gguf->ToJson();
115+
return root;
116+
}
101117
};
102118

103119
inline std::optional<std::string> GetHuggingFaceToken() {

0 commit comments

Comments
 (0)