3333from .common import build_unified_search_result
3434
3535HF_API_URL = "https://huggingface.co/api"
36- HF_AUTHOR_FALLBACKS = ["Comfy-Org" ]
36+ HF_AUTHOR_FALLBACKS = ["Comfy-Org" , "Kijai" ]
3737BRAVE_SEARCH_API_URL = "https://api.search.brave.com/res/v1/web/search"
3838HF_AUTHOR_INDEX_CACHE_TTL_SECONDS = 24 * 60 * 60
3939HF_AUTHOR_INDEX_CACHE_VERSION = 1
@@ -284,6 +284,33 @@ def get_author_fallback_index_status(author: str = "Comfy-Org") -> Dict[str, Any
284284 }
285285
286286
287+ def get_known_author_fallback_indexes_status () -> Dict [str , Any ]:
288+ """Return aggregate status for all known HuggingFace author indexes."""
289+ author_statuses = [
290+ get_author_fallback_index_status (author ) for author in HF_AUTHOR_FALLBACKS
291+ ]
292+ updated_times = [
293+ status ["updated_at" ]
294+ for status in author_statuses
295+ if isinstance (status .get ("updated_at" ), (int , float ))
296+ ]
297+ cached_author_count = sum (bool (status ["exists" ]) for status in author_statuses )
298+ fully_cached = cached_author_count == len (author_statuses )
299+
300+ return {
301+ "authors" : author_statuses ,
302+ "author_count" : len (author_statuses ),
303+ "cached_author_count" : cached_author_count ,
304+ "exists" : cached_author_count > 0 ,
305+ "fully_cached" : fully_cached ,
306+ "updated_at" : max (updated_times ) if updated_times else None ,
307+ "stale" : not fully_cached
308+ or any (bool (status ["stale" ]) for status in author_statuses ),
309+ "repo_count" : sum (int (status ["repo_count" ]) for status in author_statuses ),
310+ "file_count" : sum (int (status ["file_count" ]) for status in author_statuses ),
311+ }
312+
313+
287314def refresh_author_fallback_index (
288315 token : Optional [str ] = None , author : str = "Comfy-Org"
289316) -> Dict [str , Any ]:
@@ -297,6 +324,25 @@ def refresh_author_fallback_index(
297324 return status
298325
299326
327+ def refresh_known_author_fallback_indexes (
328+ token : Optional [str ] = None ,
329+ ) -> Dict [str , Any ]:
330+ """Force refresh all known public HuggingFace author indexes."""
331+ refresh_results = [
332+ refresh_author_fallback_index (token , author ) for author in HF_AUTHOR_FALLBACKS
333+ ]
334+ status = get_known_author_fallback_indexes_status ()
335+ failed_authors = [
336+ result ["author" ] for result in refresh_results if not result .get ("success" )
337+ ]
338+ status ["success" ] = not failed_authors
339+ status ["persisted" ] = all (
340+ bool (result .get ("persisted" )) for result in refresh_results
341+ )
342+ status ["failed_authors" ] = failed_authors
343+ return status
344+
345+
300346def parse_huggingface_url (url : str ) -> Optional [Dict [str , str ]]:
301347 """
302348 Parse a HuggingFace URL to extract repo and filename.
0 commit comments