
    Mi6                        S SK JrJrJrJrJrJr  S SKJr  S SKJ	r	J
r
JrJrJrJrJr  S SKJr  S SKJrJr  S SKJr  S SKJr  SS	KJr  S S
KJr  S SKJr  \ " S S5      5       r\ " S S5      5       r " S S\5      r\ " S S5      5       r " S S\5      r\ " S S5      5       r  " S S\5      r!\ " S S5      5       r" " S S\5      r# " S S\5      r$ " S  S!\5      r% " S" S#\&5      r'\" S$\%S%9r( " S& S'\\(   5      r)\\)\(   \\(S(4   4   r* " S) S*\5      r+S+ r, " S, S-\5      r- " S. S/\5      r. " S0 S1\5      r/ " S2 S3\5      r0 " S4 S5\5      r1g()6    )	BaseModelHttpUrlPrivateAttrField
ConfigDictBeforeValidator)	Annotated)ListDictOptionalCallable	AwaitableUnionAny)AsyncGenerator)GenericTypeVar)Enum)	dataclass   )SSLCertificate)datetime)	timedeltac                   @    \ rS rSr% Sr\\S'   Sr\\S'   Sr\	\S'   Sr
g)DomainState   r   last_request_timecurrent_delay
fail_count N)__name__
__module____qualname____firstlineno__r   float__annotations__r   r   int__static_attributes__r        i/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/crawl4ai/models.pyr   r      s!     u M5Jr)   r   c                       \ rS rSr% \\S'   \\S'   S\S'   \\S'   \\S'   \\\4   \S'   \\\4   \S	'   S
r	\\S'   Sr
\\S'   Sr\\S'   \S\4S j5       rSrg)CrawlerTaskResult   task_idurlCrawlResultresultmemory_usagepeak_memory
start_timeend_time error_messager   retry_count        	wait_timereturnc                 .    U R                   R                  $ N)r1   successselfs    r*   r>   CrawlerTaskResult.success$   s    {{"""r)   r    N)r!   r"   r#   r$   strr&   r%   r   r   r7   r8   r'   r:   propertyboolr>   r(   r    r)   r*   r,   r,      ss    L	Hho&&HeO$$M3KIu# # #r)   r,   c                   $    \ rS rSrSrSrSrSrSrg)CrawlStatus(   QUEUEDIN_PROGRESS	COMPLETEDFAILEDr    N)	r!   r"   r#   r$   rH   rI   rJ   rK   r(   r    r)   r*   rF   rF   (   s    FKIFr)   rF   c                       \ rS rSr% \\S'   \\S'   \\S'   Sr\\	\
\4      \S'   Sr\\	\
\4      \S'   Sr\\S	'   Sr\\S
'   Sr\\S'   Sr\\S'   Sr\\S'   Sr\\S'   \S\4S j5       rSrg)
CrawlStats.   r.   r/   statusNr4   r5   r9   r2   r3   r6   r7   r:   r   r8   Fcounted_requeuer;   c                    U R                   (       d  gU R                   n[        U[        5      (       a  [        R                  " U5      nU R
                  =(       d    [        R                  " 5       n[        U[        5      (       a  [        R                  " U5      nX!-
  n[        [        [        UR                  5       5      S95      $ )Nz0:00)seconds)r4   
isinstancer%   r   fromtimestampr5   nowrB   r   r'   total_seconds)r@   startenddurations       r*   rY   CrawlStats.duration<   s     eU##**51E mm-x||~c5!!((-C;9S)?)?)A%BCDDr)   r    )r!   r"   r#   r$   rB   r&   rF   r4   r   r   r   r%   r5   r2   r3   r7   r:   r8   r'   rP   rD   rC   rY   r(   r    r)   r*   rM   rM   .   s    L	H37Jx/0715HhuXu_-.5L%KM3IuK!OT!E# E Er)   rM   c                       \ rS rSrSrSrSrg)DisplayModeO   DETAILED
AGGREGATEDr    N)r!   r"   r#   r$   r^   r_   r(   r    r)   r*   r\   r\   O   s    HJr)   r\   c                   h    \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\
\   \S'   Sr\
\   \S'   S	rg)

TokenUsageW   r   completion_tokensprompt_tokenstotal_tokensNcompletion_tokens_detailsprompt_tokens_detailsr    )r!   r"   r#   r$   rc   r'   r&   rd   re   rf   r   dictrg   r(   r    r)   r*   ra   ra   W   s?    sM3L#04x~4,08D>0r)   ra   c                   .    \ rS rSr% \\S'   Sr\\S'   Srg)UrlModel_   r/   Fforcedr    N)	r!   r"   r#   r$   r   r&   rl   rD   r(   r    r)   r*   rj   rj   _   s    	LFDr)   rj   c                       \ rS rSr% Sr\R                  " 5       r\\S'   Sr	\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S	'   S
rg)TraversalStatse   z$Statistics for the traversal processr4   r   urls_processedurls_failedurls_skippedtotal_depth_reachedcurrent_depthr    N)r!   r"   r#   r$   __doc__r   rU   r4   r&   rp   r'   rq   rr   rs   rt   r(   r    r)   r*   rn   rn   e   sH    .#<<>J)NCKL#  M3r)   rn   c                   j    \ rS rSr% \\S'   \\S'   \\S'   \\\4   \S'   \\\4   \S'   Sr	\\S'   S	r
g
)DispatchResultp   r.   r2   r3   r4   r5   r6   r7   r    N)r!   r"   r#   r$   rB   r&   r%   r   r   r7   r(   r    r)   r*   rw   rw   p   s;    Lho&&HeO$$M3r)   rw   c                   b    \ rS rSr% \\S'   \\S'   \\S'   Sr\\   \S'   Sr\\   \S'   S r	S	r
g)
MarkdownGenerationResultx   raw_markdownmarkdown_with_citationsreferences_markdownNfit_markdownfit_htmlc                     U R                   $ r=   )r|   r?   s    r*   __str__ MarkdownGenerationResult.__str__   s       r)   r    )r!   r"   r#   r$   rB   r&   r   r   r   r   r(   r    r)   r*   rz   rz   x   s5      "&L(3-&"Hhsm"!r)   rz   c                   >  ^  \ rS rSr% \\S'   \\S'   Sr\\   \S'   \\S'   Sr	\\   \S'   0 r
\\\\   4   \S'   0 r\\\\   4   \S	'   Sr\\\      \S
'   Sr\\\\4      \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   \" SS9r\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr \\!   \S'   Sr"\\#   \S'   Sr$\\   \S'   Sr%\\   \S'   Sr&\\\\\4         \S'   Sr'\\\\\4         \S'   \(" \)S9r*\\   \S'   Sr+\\   \S'   Sr,\\-   \S '   Sr.\\   \S!'   Sr/\\\\4      \S"'   \0" S#S$9r1U 4S% jr2\3S& 5       r4\4Rj                  S' 5       r4\3S( 5       r6\3S) 5       r7\3S* 5       rU 4S+ jr8S,r9U =r:$ )-r0      r/   htmlNr   r>   cleaned_htmlmedialinksdownloaded_filesjs_execution_result
screenshotpdfmhtml)default	_markdownextracted_contentmetadatar7   
session_idresponse_headersstatus_codessl_certificatedispatch_resultredirected_urlredirected_status_codenetwork_requestsconsole_messages)default_factorytableshead_fingerprint	cached_atcache_statuscrawl_statsTarbitrary_types_allowedc                    > UR                  SS 5      n[        TU ]  " S0 UD6  Ub(  [        U[        5      (       a  [        S0 UD6OUU l        g g )Nmarkdownr    )popsuper__init__rS   rh   rz   r   )r@   datamarkdown_result	__class__s      r*   r   CrawlResult.__init__   sT    ((:t4 4 & ot44 );?;$ N 'r)   c                 H    U R                   c  g[        U R                   5      $ )a1  
Property that returns a StringCompatibleMarkdown object that behaves like
a string but also provides access to MarkdownGenerationResult attributes.

This approach allows backward compatibility with code that expects 'markdown'
to be a string, while providing access to the full MarkdownGenerationResult.
N)r   StringCompatibleMarkdownr?   s    r*   r   CrawlResult.markdown   s      >>!'77r)   c                     Xl         g)z#
Setter for the markdown property.
Nr   )r@   values     r*   r   r      s	    
 r)   c                     [        S5      e)z
Deprecated property that raises an AttributeError when accessed.

This property exists to inform users that 'markdown_v2' has been
deprecated and they should use 'markdown' instead.
a  The 'markdown_v2' attribute is deprecated and has been removed. Please use 'markdown' instead, which now returns a MarkdownGenerationResult, with
            following properties:
            - raw_markdown: The raw markdown string
            - markdown_with_citations: The markdown string with citations
            - references_markdown: The markdown string with references
            - fit_markdown: The markdown string with fit text
            AttributeErrorr?   s    r*   markdown_v2CrawlResult.markdown_v2   s     	
 		
r)   c                     [        S5      e)B
Deprecated property that raises an AttributeError when accessed.
zlThe 'fit_markdown' attribute is deprecated and has been removed. Please use 'markdown.fit_markdown' instead.r   r?   s    r*   r   CrawlResult.fit_markdown   s    
 :
 	
r)   c                     [        S5      e)r   zdThe 'fit_html' attribute is deprecated and has been removed. Please use 'markdown.fit_html' instead.r   r?   s    r*   r   CrawlResult.fit_html   s    
 6
 	
r)   c                    > [         TU ]  " U0 UD6nS H2  nXC;   d  M
  [        X4   [        5      (       d  M#  [	        X4   5      X4'   M4     U R
                  b  U R
                  R                  5       US'   U$ )aa  
Override model_dump to include the _markdown private attribute in serialization.

This override is necessary because:
1. PrivateAttr fields are excluded from serialization by default
2. We need to maintain backward compatibility by including the 'markdown' field
   in the serialized output
3. We're transitioning from 'markdown_v2' to enhancing 'markdown' to hold
   the same type of data

Future developers: This method ensures that the markdown content is properly
serialized despite being stored in a private attribute. If the serialization
requirements change, this is where you would update the logic.
)r   r   r   r   )r   
model_dumprS   rC   rB   r   )r@   argskwargsr1   keyr   s        r*   r   CrawlResult.model_dump   sp     #T4V4 ?C}FK!B!B "&+.	 ? >>%!%!:!:!<F:r)   r   );r!   r"   r#   r$   rB   r&   r   r   rD   r   r   r   r
   r   r   r   r   r   r   bytesr   r   r   rz   r   r   rh   r7   r   r   r   r'   r   r   r   rw   r   r   r   r   r   listr   r   r   r%   r   r   r   model_configr   rC   r   setterr   r   r   r(   __classcell__r   s   @r*   r0   r0      sh   	H
I"Hhsm"M"&L(3-&#%E4T$Z %#%E4T$Z %,0htCy)048$sCx.18 $J$C%E8C=4?4MIx01M'+x}+#Hhtn##'M8C=' $J$'+htn+!%K#%04OXn-404OXn-4$(NHSM(,0HSM07;htDcN34;7;htDcN34;t4FDJ4&*hsm*!%Ix%"&L(3-&,0K$sCx.)0d;L 
8 
8 __  
 
$ 
 
 
 
 r)   r0   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )r   i  zRA string subclass that also provides access to MarkdownGenerationResult attributesc                 6   > [         TU ]  XR                  5      $ r=   )r   __new__r|   )clsr   r   s     r*   r    StringCompatibleMarkdown.__new__  s    ws$@$@AAr)   c                     Xl         g r=   _markdown_result)r@   r   s     r*   r   !StringCompatibleMarkdown.__init__  s     /r)   c                 .    [        U R                  U5      $ r=   )getattrr   )r@   names     r*   __getattr__$StringCompatibleMarkdown.__getattr__  s    t,,d33r)   r   )
r!   r"   r#   r$   ru   r   r   r   r(   r   r   s   @r*   r   r     s    \B04 4r)   r   CrawlResultT)boundc                   V    \ rS rSrS\\\\   4   4S jrS rS r	S r
S rS rS	 rS
rg)CrawlResultContaineri"  resultsc                 L    [        U[        5      (       a  Xl        g U/U l        g r=   )rS   r   _results)r@   r   s     r*   r   CrawlResultContainer.__init__#  s    gt$$#M$IDMr)   c                 ,    [        U R                  5      $ r=   )iterr   r?   s    r*   __iter__CrawlResultContainer.__iter__*  s    DMM""r)   c                <   #    U R                    H  nU7v   M
     g 7fr=   r   )r@   items     r*   	__aiter__CrawlResultContainer.__aiter__-  s     MMDJ "s   c                      U R                   U   $ r=   r   )r@   indexs     r*   __getitem__ CrawlResultContainer.__getitem__1  s    }}U##r)   c                 ,    [        U R                  5      $ r=   )lenr   r?   s    r*   __len__CrawlResultContainer.__len__4  s    4==!!r)   c                     U R                   (       a  [        U R                   S   U5      $ [        U R                  R                   SU S35      e)Nr   z object has no attribute '')r   r   r   r   r!   )r@   attrs     r*   r    CrawlResultContainer.__getattr__7  sF    ==4==+T22 7 788RSWRXXYZ[[r)   c                 P    U R                   R                   SU R                  < S3$ )N())r   r!   r   r?   s    r*   __repr__CrawlResultContainer.__repr__=  s%    ..))*!DMM+<A>>r)   r   N)r!   r"   r#   r$   r   r   r
   r   r   r   r   r   r   r   r(   r    r)   r*   r   r   "  s<    &lD4F&F G &#$"\?r)   r   Nc                   n   \ rS rSr% \\S'   \\\4   \S'   Sr\\\\	4      \S'   \
\S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S	'   Sr\\\\   /\\   4      \S
'   Sr\\\      \S'   Sr\\   \S'   Sr\\   \S'   Sr\\
   \S'   Sr\\\\\	4         \S'   Sr\\\\\	4         \S'   \" SS9rSrg)AsyncCrawlResponseiK  r   r   Nr   r   r   pdf_data
mhtml_dataget_delayed_contentr   r   r   r   r   r   Tr   r    )r!   r"   r#   r$   rB   r&   r   r   r   r   r'   r   r   r   r   r   r   r%   r   r   r
   r   r   r   r   r   r   r   r   r(   r    r)   r*   r   r   K  s   
I38n$48$sCx.18 $J$ $Hhuo$ $J$QU(HUO+<in+L"MNU,0htCy)004OXn-4$(NHSM(,0HSM07;htDcN34;7;htDcN34;d;Lr)   r   c                 N    U c  g [        U 5      $ ! [        [        4 a     gf = f)zJCoerce to int or return None for non-numeric values like '100%' or 'auto'.N)r'   
ValueError	TypeError)vs    r*   _coerce_intr  `  s/    y1v	" s   
 $$c                       \ rS rSr% Sr\\   \S'   Sr\\   \S'   Sr	\\   \S'   Sr
\\   \S'   Sr\\   \S'   S	r\\S
'   Sr\\   \S'   Sr\\   \S'   Sr\\\   \" \5      4   \S'   Srg)	MediaItemii  r6   srcr   altdescr   scoreimagetypegroup_idNformatwidthr    )r!   r"   r#   r$   r  r   rB   r&   r   r  r  r  r'   r
  r  r  r  r	   r   r  r(   r    r)   r*   r  r  i  s    C#D(3-C#D(3-E8C=D#Hhsm FHSM DHE9Xc]OK$@@AHr)   r  c                       \ rS rSr% Sr\\   \S'   Sr\\   \S'   Sr	\\   \S'   Sr
\\   \S'   Sr\\\\4      \S'   Sr\\   \S	'   Sr\\   \S
'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Srg)Linkiu  r6   hreftexttitlebase_domainN	head_datahead_extraction_statushead_extraction_errorintrinsic_scorecontextual_scoretotal_scorer    )r!   r"   r#   r$   r  r   rB   r&   r  r  r  r  r   r   r  r  r  r%   r  r  r(   r    r)   r*   r  r  u  s    D(3-D(3-E8C=!#K##*.IxS#X'.,0HSM0+/8C=/'+OXe_+(,huo,#'K%'r)   r  c                   f    \ rS rSr% / r\\   \S'   / r\\   \S'   / r	\\   \S'   / r
\\   \S'   Srg)Mediai  imagesvideosaudiosr   r    N)r!   r"   r#   r$   r  r
   r  r&   r  r  r   r   r(   r    r)   r*   r  r    sR     FDO  	 D 
 	 D  FDJr)   r  c                   >    \ rS rSr% / r\\   \S'   / r\\   \S'   Sr	g)Linksi  internalexternalr    N)
r!   r"   r#   r$   r!  r
   r  r&   r"  r(   r    r)   r*   r   r     s    Hd4jHd4jr)   r   c                   r    \ rS rSr% \\S'   \\S'   \" 5       r\\S'   \	" 5       r
\	\S'   0 r\\\4   \S'   Srg)	ScrapingResulti  r   r>   r   r   r   r    N)r!   r"   r#   r$   rB   r&   rD   r  r   r   r   r   r   r   r(   r    r)   r*   r$  r$    s7    M7E57E5!Hd38n!r)   r$  )2pydanticr   r   r   r   r   r   typingr	   r
   r   r   r   r   r   r   r   r   r   enumr   dataclassesr   r   r   r   r   r   r,   rF   rM   r\   ra   rj   rn   rw   rz   r0   rB   r   r   r   RunManyReturnr   r  r  r  r  r   r$  r    r)   r*   <module>r*     s   X X  H H H ! #  ! +      # # # $  E E E@$  1 1 1y    Y !y !Q) Qf	4s 	4 ~[9?7<0 ?< &<%&'< <*	I	 	I
(9 
(I I 
"Y "r)   