Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 3 additions & 30 deletions models/src/models/api/huggingface_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ class CurlHttpClient : public HttpInterface {
}

~CurlHttpClient() {
// Don't call curl_global_cleanup() here as other instances or threads might still be using CURL
// CURL cleanup should happen at program exit
// TODO: Implement proper cleanup strategy
// curl_global_cleanup() is intentionally omitted — other threads may still hold CURL handles.
// CURL global state is cleaned up at process exit by the OS.
}

void requestAsync(
Expand Down Expand Up @@ -149,16 +148,6 @@ class CurlHttpClient : public HttpInterface {
return response;
}

void cancelAll() override {
// TODO: Implement cancellation
}

bool cancelRequest(const std::string& url) override {
(void)url;
// TODO: Implement specific request cancellation
return false;
}

// C-style callback for CURL write function
static size_t curlWriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
size_t realsize = size * nmemb;
Expand Down Expand Up @@ -896,12 +885,6 @@ std::vector<FileInfo> HuggingFaceClient::parseFilesResponse(const std::string& j
return files;
}

std::string HuggingFaceClient::extractNextPageToken(const std::map<std::string, std::string>& headers) {
(void)headers;
// TODO: Implement next page token extraction from headers
return "";
}

// Error handling
void HuggingFaceClient::handleHttpError(int statusCode, const std::string& error, const std::string& endpoint) {
m_lastError = "HTTP " + std::to_string(statusCode) + ": " + error;
Expand All @@ -910,17 +893,7 @@ void HuggingFaceClient::handleHttpError(int statusCode, const std::string& error
}
}

// Request management
void HuggingFaceClient::queueRequest(const http::HttpRequest& request) {
m_requestQueue.push(request);
processRequestQueue();
}

void HuggingFaceClient::processRequestQueue() {
// TODO: Implement rate limiting and queue processing
}

// Download management methods (placeholder implementations)
// Download management methods
void HuggingFaceClient::sortFilesBySize(std::vector<FileDownloadRequest>& files) {
std::sort(files.begin(), files.end(),
[](const FileDownloadRequest& a, const FileDownloadRequest& b) {
Expand Down
10 changes: 0 additions & 10 deletions models/src/models/api/huggingface_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ namespace http {
virtual HttpResponse requestSyncWithProgress(const HttpRequest& request,
ProgressCallback progress) = 0;

// Cancel operations
virtual void cancelAll() = 0;
virtual bool cancelRequest(const std::string& url) = 0;
};

// Factory functions
Expand Down Expand Up @@ -203,7 +200,6 @@ class HuggingFaceClient {

// HTTP client management
std::unique_ptr<http::HttpInterface> m_httpClient;
std::queue<http::HttpRequest> m_requestQueue;
std::unordered_map<std::string, std::string> m_activeRequests; // request_id -> endpoint mapping

// Configuration
Expand Down Expand Up @@ -240,15 +236,9 @@ class HuggingFaceClient {
std::vector<ModelInfo> parseSearchResponse(const std::string& jsonData);
ModelInfo parseModelInfo(const std::string& jsonData);
std::vector<FileInfo> parseFilesResponse(const std::string& jsonData);
std::string extractNextPageToken(const std::map<std::string, std::string>& headers);

// Error handling
void handleHttpError(int statusCode, const std::string& error, const std::string& endpoint);

// Request management
void queueRequest(const http::HttpRequest& request);
void processRequestQueue();

// Download management methods (merged from ModelDownloader)
void sortFilesBySize(std::vector<FileDownloadRequest>& files);
void startNextDownloads(const std::string& modelDownloadId);
Expand Down
3 changes: 0 additions & 3 deletions models/tests/models/test_huggingface_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ class MockHttpClient : public http::HttpInterface {
return requestSync(request);
}

void cancelAll() override {}
bool cancelRequest(const std::string& url) override { (void)url; return false; }

void setNextResponse(int statusCode, const std::string& data, const std::string& error = "") {
nextResponse.statusCode = statusCode;
nextResponse.data = data;
Expand Down
Loading