File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -736,21 +736,17 @@ static struct common_hf_file_res common_get_hf_file(const std::string & hf_repo_
736736 std::string mmprojFile;
737737
738738 if (res_code == 200 || res_code == 304 ) {
739- // extract ggufFile.rfilename in json, using regex
740- {
741- std::regex pattern (" \" ggufFile\" [\\ s\\ S]*?\" rfilename\"\\ s*:\\ s*\" ([^\" ]+)\" " );
742- std::smatch match;
743- if (std::regex_search (res_str, match, pattern)) {
744- ggufFile = match[1 ].str ();
739+ try {
740+ auto j = json::parse (res_str);
741+
742+ if (j.contains (" ggufFile" ) && j[" ggufFile" ].contains (" rfilename" )) {
743+ ggufFile = j[" ggufFile" ][" rfilename" ].get <std::string>();
745744 }
746- }
747- // extract mmprojFile.rfilename in json, using regex
748- {
749- std::regex pattern (" \" mmprojFile\" [\\ s\\ S]*?\" rfilename\"\\ s*:\\ s*\" ([^\" ]+)\" " );
750- std::smatch match;
751- if (std::regex_search (res_str, match, pattern)) {
752- mmprojFile = match[1 ].str ();
745+ if (j.contains (" mmprojFile" ) && j[" mmprojFile" ].contains (" rfilename" )) {
746+ mmprojFile = j[" mmprojFile" ][" rfilename" ].get <std::string>();
753747 }
748+ } catch (const std::exception & e) {
749+ throw std::runtime_error (std::string (" error parsing manifest JSON: " ) + e.what ());
754750 }
755751 if (!use_cache) {
756752 // if not using cached response, update the cache file
You can’t perform that action at this time.
0 commit comments