
    =j                       d Z ddlmZ ddlZddlZddlZddlZddl	Z ej                  e      ZdZdZdZddhZd	d
ddZedk(  r ej$                  ej&                          eej                  j)                  ej*                  j,                         ej.                  d      z
        Z e ej4                  ed             yy)u>   HuggingFace-Helper — HF REST /api/models, sort=lastModified.    )annotationsNz!https://huggingface.co/api/modelsz$aria-radar/0.1 (+aseckzai@gmail.com)   text-generationconversational   )	max_itemsc                   ddt        |dz        dd}t         dt        j                  j	                  |       }t        j
                  j                  |t        dd	      }t        j
                  j                  |t        
      5 }t        j                  |j                               }ddd       g }D ]  }|j                  d      xs d}		 t        j                  j!                  |	j#                  dd            }
|
| k  rO|j                  d      xs |j                  d      xs d}|sz|j'                  |d| |
j)                         d|j                  d      |j                  d      |j                  dg       dd |j                  d      |j                  d      dd       t+        |      |k\  s n t,        j/                  dt+        |             |S # 1 sw Y   9xY w# t$        $ r Y Dw xY w)z@Fetch recently-modified text-generation models from HuggingFace.lastModifiedz-1   r   )sort	directionlimitpipeline_tag?zapplication/json)z
User-AgentAccept)headers)timeoutN Zz+00:00modelIdidzhttps://huggingface.co/huggingface	downloadsr   tags
   likeslibrary_name)r   r   r   r   )titleurldatesourcescorerawzhuggingface: %d items)strHF_MODELS_URLurllibparse	urlencoderequestRequest
USER_AGENTurlopenTIMEOUT_SECONDSjsonloadsreadgetdtdatetimefromisoformatreplace
ValueErrorappend	isoformatlenloginfo)sincer   paramsr   reqresppayloaditemsmodellast_modified_rawlast_modifiedmodel_ids               4/root/aria/scripts/ai-radar/platforms/huggingface.pyfetchrG      s    Y]#)	F O1V\\33F;<
=C
..
 
 ZSe.f
 
gC			_		= ***TYY[)* E !IIn5;	KK556G6O6OPSU]6^_M 5 99Y'@599T?@b,XJ7!++-#YY{+ %		. 9		&"-cr27+ %		. 9	
 	 u:"34 HH$c%j1L?* *  		s   	$G$/G1$G.1	G>=G>__main__)level   )hours)r<      )indent)r<   zdt.datetimer   intreturnz
list[dict])__doc__
__future__r   r3   r2   r.   loggingurllib.parser&   urllib.request	getLogger__name__r:   r%   r+   r-   INTERESTING_PIPELINESrG   basicConfigINFOnowtimezoneutc	timedeltarA   printdumps     rF   <module>rb      s    D "     g!33
*,<=  35 *Z zGgll+8<2<<b;QQRE	*$**U1
%& ra   