// // Created by ruoyi.sjd on 2024/12/24. // Copyright (c) 2024 Alibaba Group Holding Limited All rights reserved. // #pragma once #include #include #include namespace mls { struct RepoInfo { std::string model_id; std::string revision; std::string sha; std::vector siblings; }; struct RepoItem { std::string model_id; std::string created_at; int downloads; std::vector tags; }; struct HfFileMetadata { std::string commit_hash; std::string location; std::string etag; size_t size; }; //a benchmark referenced llama.cpp class HfApiClient { public: std::vector SearchRepos(const std::string& keyword); HfApiClient(); static std::tuple ParseUrl(const std::string &url); static bool PerformRequestWithRetry(std::function request_func, int max_attempts, int retry_delay_seconds); RepoInfo GetRepoInfo(const std::string &repo_name, const std::string &revision, std::string& error_info); void DownloadRepo(const RepoInfo& repo_info); private: std::vector SearchReposInner(const std::string& keyword, std::string& error_info); int max_attempts_{3}; int retry_delay_seconds_{1}; std::string host_{"hf-mirror.com"}; std::string cache_path_{}; }; }//mls