
    ɢi                     p   d dl Z d dlZd dlmZmZmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZ  e
dej"                   ede e	d      d	       ed
e e	d      d	            Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#e      Z G d$ d%e      Z G d& d'e      Z  G d( d)e      Z! G d* d+e      Z" G d, d-e      Z# G d. d/e      Z$ G d0 d1e      Z% G d2 d3e      Z& G d4 d5e      Z' G d6 d7e      Z( G d8 d9e      Z) G d: d;e      Z* G d< d=e      Z+ G d> d?e      Z, G d@ dAe      Z- G dB dCe      Z. G dD dEe      Z/ G dF dGe      Z0 G dH dIe      Z1y)J    N)
ColumnIntegerStringTextDateTimeJSON
ForeignKeyTableBooleanFloat)relationship)Basebatch_plan_conceptsbatch_plan_idzbatch_plans.idT)primary_key
concept_idconcepts.idc                       e Zd ZdZ eedd      Z e ed      ddd      Z e ed      d      Z	 ee
d	      Z eeej                  j                  	      Z eed      Zd
efdZd
edefdZy)AuraUser
aura_usersTr   indexd   Funiquenullabler      r   defaultpasswordc                     t        j                  |j                  d      t        j                               j	                  d      | _        y Nzutf-8)bcrypthashpwencodegensaltdecodepassword_hashselfr!   s     (/sites/domain-asset-master/app/models.pyset_passwordzAuraUser.set_password   s1    #]]8??7+CV^^EUV]]^ef    returnc                 ~    t        j                  |j                  d      | j                  j                  d            S r#   )r$   checkpwr&   r)   r*   s     r,   check_passwordzAuraUser.check_password   s.    ~~hoog68J8J8Q8QRY8Z[[r.   N)__name__
__module____qualname____tablename__r   r   idr   usernamer)   r   is_adminr   datetimeutcnow
created_at
last_loginstrr-   boolr2    r.   r,   r   r      s     M	T	6BfSk$dKH6#;7Mgu-H(*;*;*B*BCJ40JgS g\s \t \r.   r   c                       e Zd ZdZ eedd      Z e ed      ddd      Z ee	d      Z
 eeej                  j                  ej                  j                        Zy	)
AppSettingsapp_settingsTr   r   Fr   r   r    onupdateN)r3   r4   r5   r6   r   r   r7   r   keyr   valuer   r:   r;   
updated_atr@   r.   r,   rB   rB   !   s[    "M	T	6B
TE
FC4$'E(*;*;*B*BXM^M^MeMefJr.   rB   c                      e Zd ZdZ eedd      Z e ed      d      Z ee	d      Z
 e ed      dd	      Z e ed      dd
	      Z eed      Z e ed      d      Z eed      Z eed      Z eeej&                  j(                        Z eeej&                  j(                  ej&                  j(                        Z edddd      Z eded      Zd Zy)ConceptconceptsTr     Fr      capturedr   r    manualr   r   rD   ConceptRevisionconceptall, delete-orphanz!ConceptRevision.created_at.desc()back_populatescascadeorder_by	BatchPlan	secondaryrU   c                    | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  r| j                  j                         dz   nd | j                  r| j                  j                         dz   nd | j                  rt        | j                        dS ddS )NZr   )r7   title	raw_inputstatussource_type	source_iddomaincontext_snapshottagsr<   rH   revision_count)r7   r]   r^   r_   r`   ra   rb   rc   rd   r<   	isoformatrH   	revisionslenr+   s    r,   to_dictzConcept.to_dict<   s    ''ZZkk++kk $ 5 5II?C$//335;TX?C$//335;TX59^^c$..1
 	
 JK
 	
r.   N)r3   r4   r5   r6   r   r   r7   r   r]   r   r^   r_   r`   ra   rb   r   rc   rd   r   r:   r;   r<   rH   r   rg   r   batch_plansrj   r@   r.   r,   rJ   rJ   *   s    M	T	6B6#;/Ete,IF2J
CFeXFKw.IF3K$/FdT2$&D(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ.yRf  rU  VI{6IZdeK
r.   rJ   c                       e Zd ZdZ eedd      Z ee ed      d      Z e e	d      d      Z
 eed      Z eed      Z eeej                  j                         Z ed	d
      Zd Zy)rQ   concept_revisionsTr   r   Fr   2   r   rJ   rg   rU   c                     | j                   | j                  | j                  | j                  | j                  | j
                  r| j
                  j                         dz   dS d dS )Nr\   )r7   r   revision_typecontentrc   r<   )r7   r   rq   rr   rc   r<   rf   ri   s    r,   rj   zConceptRevision.to_dictY   s_    ''//!//|| $ 5 5?C$//335;
 	
 UY
 	
r.   N)r3   r4   r5   r6   r   r   r7   r	   r   r   rq   r   rr   rc   r   r:   r;   r<   r   rR   rj   r@   r.   r,   rQ   rQ   M   sz    'M	T	6BM!:UKJ6":6MTE*GdT2(*;*;*B*BCJ9[AG
r.   rQ   c                   b   e Zd ZdZ eedd      Z e ed      d      Z e ed      dd	      Z	 ee
d      Z ee
d      Z ee
d      Z eeej                  j                   
      Z eeej                  j                   ej                  j                         Z eded      Zd Zy)rX   rk   Tr   rL   Fr   rM   draftrO   r   rD   rJ   rY   c           
         | j                   | j                  | j                  | j                  | j                  | j
                  | j                  r$| j                  D cg c]  }|j                    c}ng | j                  r| j                  j                         dz   nd | j                  r| j                  j                         dz   d	S d d	S c c}w )Nr\   )	r7   r]   r_   plan_contentdependency_graphparallel_tracksconcept_idsr<   rH   )
r7   r]   r_   rv   rw   rx   rK   r<   rf   rH   )r+   cs     r,   rj   zBatchPlan.to_dictr   s    ''ZZkk -- $ 5 5#33<@MM$--8QADD8r?C$//335;TX?C$//335;

 
	
 UY

 
	
 9s   CN)r3   r4   r5   r6   r   r   r7   r   r]   r_   r   rv   rw   rx   r   r:   r;   r<   rH   r   r   rK   rj   r@   r.   r,   rX   rX   d   s    !M	T	6B6#;/EF2J@F$.LdT2TD1O(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJI1DUbcH
r.   rX   c                      e Zd ZdZ eedd      Z e ed      d      Z e ed      d      Z	 eedd      Z
 e ed      d      Z eed      Z e ed	      dd
      Z e ed      dd      Z eed      Z eeej&                  j(                        Z eeej&                  j(                  ej&                  j(                        Z eddd      ZddZy)
FtpProfileftp_profilesTr   r   Fr      rO   rL   /
   sftpr   rD   FtpProjectBindingprofilerS   rU   rV   c           	      x   | j                   | j                  | j                  | j                  | j                  | j
                  | j                  r| j                  j                         dz   nd | j                  r| j                  j                         dz   nd d}|r| j                  |d<   | j                  |d<   |S )Nr\   )r7   labelportprotocol	base_path
is_defaultr<   rH   hostr8   )r7   r   r   r   r   r   r<   rf   rH   r   r8   )r+   include_hostds      r,   rj   zFtpProfile.to_dict   s    ''ZZII//?C$//335;TX?C$//335;TX	
 		AfI MMAjMr.   N)T)r3   r4   r5   r6   r   r   r7   r   r   r   r   r8   r   encrypted_passwordr   r   r   r   r   r:   r;   r<   rH   r   bindingsrj   r@   r.   r,   r|   r|      s    "M	T	6B6#;/E&+.D'E26DfSkE2Hu5vc{UC@IfRj5&AH/J(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ/	SghHr.   r|   c                   Z   e Zd ZdZ eedd      Z ee ed      d      Z e e	d      dd      Z
 e e	d	      d      Z eed
      Z eeej                  j                   
      Z eeej                  j                   ej                  j                         Z edd      Zd Zy)r   ftp_project_bindingsTr   ftp_profiles.idFr   r   r   r   rL   r   rD   r|   r   ro   c                    | j                   | j                  | j                  | j                  | j                  | j
                  r| j
                  j                  nd | j                  r| j                  j                         dz   dS d dS )Nr\   )r7   ftp_profile_idrb   target_directoryr   profile_labelr<   )	r7   r   rb   r   r   r   r   r<   rf   ri   s    r,   rj   zFtpProjectBinding.to_dict   st    ''"11kk $ 5 5//37<<T\\//T?C$//335;
 	
 UY
 	
r.   N)r3   r4   r5   r6   r   r   r7   r	   r   r   rb   r   r   r   r   r:   r;   r<   rH   r   r   rj   r@   r.   r,   r   r      s    *M	T	6BGZ0A%BUSNF3K%t<FfSkE:.J(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ<
CG	
r.   r   c                   F   e Zd ZdZ eedd      Z ee ed      d      Z e e	d      dd      Z
 e e	d	      dd
      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eeej(                  j*                        Zd Zy)DeploymentLogdeployment_logsTr   r   Fr   r   r   rM   queuedrO   r   r   c                    | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  r| j                  j                         dz   nd | j                  r| j                  j                         dz   nd | j                  r| j                  j                         dz   dS d dS )Nr\   )r7   r   rb   r_   files_uploadedfiles_totalduration_secondserror_message
started_atcompleted_atr<   )r7   r   rb   r_   r   r   r   r   r   rf   r   r<   ri   s    r,   rj   zDeploymentLog.to_dict   s    ''"11kkkk"11++ $ 5 5!//?C$//335;TXCGCTCTD--779C?Z^?C$//335;
 	
 UY
 	
r.   N)r3   r4   r5   r6   r   r   r7   r	   r   r   rb   r_   r   r   r   r   r   r   r   r   r:   r;   r<   rj   r@   r.   r,   r   r      s    %M	T	6BGZ0A%BUSNF3K%t<FF2JAFGQ/N!,Kg54$/M40J(T2L(*;*;*B*BCJ
r.   r   c                   2   e Zd ZdZ eedd      Z e ed      dd      Z e ed      dd	      Z	 eedd
	      Z
 eed      Z eed      Z e ed      d      Z eed      Z eed      Z eeej&                  j(                        Zd Zy)SiteSnapshotsite_snapshotsTr   r   Fr   rM   siterO      r   @   r   c           
      N   | j                   | j                  | j                  | j                  | j                  | j
                  | j                  r| j                  j                         dz   nd | j                  | j                  r| j                  j                         dz   d	S d d	S )Nr\   )	r7   rb   snapshot_typeversion	file_pathcontent_hashpackage_updated_atmetar<   )
r7   rb   r   r   r   r   r   rf   r   r<   ri   s    r,   rj   zSiteSnapshot.to_dict   s    ''kk!//|| --OSOfOf$"9"9"C"C"E"KlpII?C$//335;

 
	
 UY

 
	
r.   N)r3   r4   r5   r6   r   r   r7   r   rb   r   r   r   r   thumbnail_datar   r   r   r   r   r:   r;   r<   rj   r@   r.   r,   r   r      s    $M	T	6BF3K%t<F6":vFMWua8Gtd+ID40N&*t4L48$&D(*;*;*B*BCJ
r.   r   c                       e Zd ZdZ eedd      Z e ed      ddd      Z ee	e
j                  j                        Z eed      Z ee	d      Z e ed      d      Z ed	d
d      Zy)DomaindomainsTr   r   Fr   r   r   Package
domain_relrS   r   N)r3   r4   r5   r6   r   r   r7   r   rb   r   r:   r;   r<   r   analysisanalyzed_atdefault_nicher   packagesr@   r.   r,   r   r      sx    M	T	6BF3KuDIF(*;*;*B*BCJdT*HD1K6#;6MIlL`aHr.   r   c                   0   e Zd ZdZ eedd      Z ee ed      d      Z e e	d      d      Z
 e e	d      d      Z eed      Z eed      Z eed      Z eed      Z eed      Z e e	d      dd	
      Z e e	d      dd
      Z e e	d      dd
      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z e e	d      dd
      Z  e e	d      dd
      Z! ee"e#jF                  jH                        Z% ee"e#jF                  jH                  e#jF                  jH                        Z& e'dd      Z( e'dddd      Z) e'dddd      Z*y)r   r   Tr   z
domains.idFr   r   rn   herorO   zsingle-scrollbalancedrM   standardpremiumr   rD   r   ro   PackageRevisionpackage_relrS   z!PackageRevision.created_at.desc()rT   AugmentzAugment.created_at.desc()N)+r3   r4   r5   r6   r   r   r7   r	   	domain_idr   domain_namechosen_nicher   brand	site_copyr   sales_letterhero_image_urlfeature_imagestemplate_typelayout_styledensitydiscovery_answers
atmospheregraphics_packbusiness_boxsite_designationscalculatorsreference_libraryasset_manifestr   quality_scoreluxury_tier
style_tierr   r:   r;   r<   rH   r   r   rg   augmentsr@   r.   r,   r   r     s   M	T	6Bw
< 85IIu5K&+6L4$'Etd+I$.LD40ND40N6":fEM&*t_MLVBZ$
CGtd3t,J4$/M$.Ltd3-Ktd3D40N540MdJGKr
T9EJ(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJhzBJ.}Vj  vY  ZIImMa  mH  IHr.   r   c                   \   e Zd ZdZ eedd      Z ee ed      d      Z e e	d      d      Z
 e e	d      d      Z e e	d      d      Z eed      Z eed      Z eed      Z eed      Z eed      Z eeej*                  j,                  	      Z ed
d      Zy)r   package_revisionsTr   packages.idFr   rn   r   r   r   rg   ro   N)r3   r4   r5   r6   r   r   r7   r	   
package_idr   rq   section_keyactionr   descriptionr   before_data
after_data	ai_promptai_responser   r:   r;   r<   r   r   r@   r.   r,   r   r   %  s    'M	T	6BM!:UKJ6":6Mt4KF2J/F-K-Kt,Jtd+I-K(*;*;*B*BCJyEKr.   r   c                      e Zd ZdZ eedd      Z ee ed      d      Z e e	d      d      Z
 e e	d      d      Z e e	d      d      Z eed      Z eed      Z eed      Z eeej&                  j(                  	      Z eeej&                  j(                  ej&                  j(                  
      Z edd      Zy)r   r   Tr   r   Fr   r   rn   r   rD   r   ro   N)r3   r4   r5   r6   r   r   r7   r	   r   r   r   augment_typer]   r   r   r   confightml_contentr   r:   r;   r<   rH   r   r   r@   r.   r,   r   r   7  s    M	T	6BM!:UKJu5K&*u5L6#;/E-KD4(F$.L(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJyDKr.   r   c                      e Zd ZdZ eedd      Z e ed      ddd      Z e ed      dd	      Z	 ee
d
      Z eed
      Z eed
      Z ee
d
      Z eed
      Z eed
      Z eed
      Z eeej(                  j*                        Z eeej(                  j*                  ej(                  j*                        Z eddd      Zy)BrandKit
brand_kitsTr   r   F)r   r   r   rM   pendingrO   r   r   rD   BrandKitAsset	brand_kitrS   r   N)r3   r4   r5   r6   r   r   r7   r   rb   r_   r   raw_textr   	extractedimage_classificationsprocessing_errorsummarygap_analysisimage_suggestionsr   r:   r;   r<   rH   r   assetsr@   r.   r,   r   r   H  s     M	T	6BF3K%tDIFF2J	BFdT*Htd+I"4$7dT2TD)G$.Ltd3(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ/+OcdFr.   r   c                      e Zd ZdZ eedd      Z ee ed      d      Z e e	d      d      Z
 e e	d      d      Z eed      Z eed      Z e e	d	      dd
      Z e e	d      d      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eeej6                  j8                        Z edd      Zy)r   brand_kit_assetsTr   zbrand_kits.idFr   rM   r   r   r   rn   r   r   r   r   ro   N) r3   r4   r5   r6   r   r   r7   r	   brand_kit_idr   
asset_typefilenamer   r   	file_size	file_hashclassificationr   rd   ai_description
sort_orderr   is_default_logosuggested_sectionsused_in_sectionsr   classified_atr:   r;   r<   r   r   r@   r.   r,   r   r   [  s    &M	T	6B':o#>OLr
U3JfSkE2Hte,Iw.IvbzD=IF2J6N$&DD40N+JWe4Ot4dT28d3M(*;*;*B*BCJZAIr.   r   c                   R   e Zd ZdZ eedd      Z e ed      d      Z ee	d      Z
 e ed      d      Z e ed      dd	
      Z eeej                  j                        Z eeej                  j                  ej                  j                        Z eed      Zy)RoadmapItemroadmap_itemsTr   r   Fr   rn   rM   plannedrO   r   rD   N)r3   r4   r5   r6   r   r   r7   r   r]   r   r   categoryr_   r   r:   r;   r<   rH   r   r@   r.   r,   r  r  r  s    #M	T	6B6#;/E-KfRj40HF2J	BF(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ(T2Lr.   r  c                      e Zd ZdZ eedd      Z e ed      dd      Z e ed      d      Z	 ee
d      Z e ed	      dd
      Z eed      Z e ed      d      Z eeej                   j"                        Z eeej                   j"                  ej                   j"                        Z eed      Zy)	BuildTaskbuild_tasksTr   r   Fr   rL   r   rM   r   rO   r   r   rn   rD   N)r3   r4   r5   r6   r   r   r7   r   	list_namer]   r   r   r_   r   r  r   r:   r;   r<   rH   r   r@   r.   r,   r
  r
    s    !M	T	6Bvc{U$?I6#;/E-KF2J	BF+JfRj40H(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ(T2Lr.   r
  c                   J   e Zd ZdZ eedd      Z e ed      dd      Z e ed      ddd      Z	 ee
d	      Z eed
      Z eed	      Z eeej                   j"                        Z eeej                   j"                  ej                   j"                        Zy)SiteProfilesite_profilesTr   r   F)r   r   r   r   r   r   r   r   r   rD   N)r3   r4   r5   r6   r   r   r7   r   nameslugr   r   r   r   r   r   r:   r;   r<   rH   r@   r.   r,   r  r    s    #M	T	6B&+d;D&+d$GD-K+JD5)F(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJr.   r  c                       e Zd ZdZ eedd      Z e ed      ddd      Z ee	d      Z
 ee	d      Z eeej                  j                  ej                  j                        Zy	)
ProjectContextproject_contextsTr   r   Fr  r   rD   N)r3   r4   r5   r6   r   r   r7   r   rb   r   context_state	event_logr   r:   r;   rH   r@   r.   r,   r  r    sg    &M	T	6BF3K%DIF4$/Mtd+I(*;*;*B*BXM^M^MeMefJr.   r  c                       e Zd ZdZ eedd      Z eed      Z ee	d      Z
 ee	d      Z eeej                  j                  ej                  j                        Zy)GlobalContextglobal_contextTr   r   rD   N)r3   r4   r5   r6   r   r   r7   r   master_rulesr   style_prefs
guardrailsr   r:   r;   rH   r@   r.   r,   r  r    s_    $M	T	6B$.L-Kt,J(*;*;*B*BXM^M^MeMefJr.   r  c                   n   e Zd ZdZ eedd      Z e ed      ddd      Z e ed      d      Z	 e ed	      d      Z
 e ed
      d      Z eed      Z e ed      d      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z e ed      d      Z eed      Z eed      Z eeej8                  j:                        Z eeej8                  j:                  ej8                  j:                        Zd Z y)JobjobsTr   r   Fr   rn   r   r   rM   r   r   r   rD   c                 >   i d| j                   d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  d| j                  xs d	d
| j                  xs dd| j                  d| j                  r| j                  j                         dz   nd d| j                  d| j                  d| j                  d| j                  d| j                   r| j                   j                         dz   nd d| j"                  r| j"                  j                         dz   nd | j$                  r| j$                  j                         dz   nd | j&                  r | j&                  j                         dz   dS d dS )Njob_idjob_typerb   r_   current_stepcurrent_step_keysteps_completedtotal_stepsr   progress_pctr   steps_detailstep_started_atr\   resulterrorretry_paramsretry_ofr   r   )r<   rH   )r"  r#  rb   r_   r$  r%  r&  r'  r(  r)  r*  rf   r+  r,  r-  r.  r   r   r<   rH   ri   s    r,   rj   zJob.to_dict  s   
dkk

 dkk
 dkk	

 D--
  5 5
 t33
 4++0q
 D--2
 D--
 I]I]t33==?#Ecg
 dkk
 TZZ
 D--
 
  t$//335;TX!
" 4CTCTD--779C?Z^#
$ @D$//335;TX?C$//335;'
 	
& UY'
 	
r.   N)!r3   r4   r5   r6   r   r   r7   r   r"  r#  rb   r_   r   r$  r%  r&  r'  r(  r   r)  r   r*  r+  r,  r-  r.  r   r   r:   r;   r<   rH   rj   r@   r.   r,   r  r    sA   M	T	6BF2Jte4HFfRj51HF3K%0FF2J/F$.LfRj48Wa0O!,K'1-L$.LX5OD4(F4$'E$.LfRj40H40J(T2L(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ
r.   r  c                   ^   e Zd ZdZ eedd      Z e ed      dd      Z e ed      d	      Z	 e ed
      d	      Z
 eed	      Z eeej                  j                        Z eeej                  j                  ej                  j                        Z edddd      ZddZy)ChatConversationchat_conversationsTr   rL   FzNew ChatrO   r   r   r   r   rD   ChatMessageconversationrS   zChatMessage.created_atrT   c                    | j                   | j                  | j                  | j                  | j                  rt        | j                        nd| j                  r| j                  j                         dz   nd | j                  r| j                  j                         dz   nd d}|r/| j                  xs g D cg c]  }|j                          c}|d<   |S c c}w )Nr   r\   )r7   r]   rb   source_pagemessage_countr<   rH   messages)
r7   r]   rb   r5  r7  rh   r<   rf   rH   rj   )r+   include_messagesr   ms       r,   rj   zChatConversation.to_dict  s    ''ZZkk++37==S/a?C$//335;TX?C$//335;TX
 37==3FBHQQYY[HAjM Is   :CNF)r3   r4   r5   r6   r   r   r7   r   r]   rb   r5  r   metadata_jsonr   r:   r;   r<   rH   r   r7  rj   r@   r.   r,   r0  r0    s    (M	T	6B6#;
CEF3K$/Ft4K4$/M(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJM.Rf  rJ  KHr.   r0  c                       e Zd ZdZ eedd      Z ee edd      dd      Z e e	d	      d
      Z
 eed
      Z eed
      Z eeej                   j"                        Z edd      Zd Zy)r2  chat_messagesTr   zchat_conversations.idCASCADEondeleteFr   rM   r   r   r0  r7  ro   c                     | j                   | j                  | j                  | j                  | j                  r| j                  j                         dz   dS d dS )Nr\   )r7   conversation_idrolerr   r<   )r7   rB  rC  rr   r<   rf   ri   s    r,   rj   zChatMessage.to_dict  sV    ''#33II||?C$//335;
 	

 UY
 	
r.   N)r3   r4   r5   r6   r   r   r7   r	   rB  r   rC  r   rr   r   rc   r   r:   r;   r<   r   r3  rj   r@   r.   r,   r2  r2    s    #M	T	6BWj1HS\&]hmuyzO&*u-DTE*GdT2(*;*;*B*BCJ 2:NL
r.   r2  c                      e Zd ZdZ eedd      Z e ed      dd      Z ee e	dd      dd      Z
 e ed	      d
      Z e ed	      d
      Z e ed      d
      Z eed      Z eed      Z eed      Z eed      Z eed      Z e ed      d
d      Z eed      Z eed      Z eeej4                  j6                        Zy)GenerationRungeneration_runsTr   r   r   r   SET NULLr?  r   Fr   rn   rM   successrO   r   N)r3   r4   r5   r6   r   r   r7   r   r   r	   r   	operation
model_usedproviderinput_tokensoutput_tokenstotal_tokensr   cost_estimateresponse_time_msr_   r   r   r   extra_metadatar   r:   r;   r<   r@   r.   r,   rE  rE    s    %M	T	6Bt4@KMJ!OZ^fjkJvc{U3Ise4JfRj51H'D1L7T2M'D1L540Mg5F2J	BF4$/MD40N(*;*;*B*BCJr.   rE  c                   &   e Zd ZdZ eedd      Z e ed      dd      Z ee e	dd	      d
      Z
 e ed      d
      Z eed
      Z eed
      Z eed
      Z e ed      d
      Z eeej&                  j(                        Zy)DomainEventdomain_eventsTr   r   Fr   r   rG  r?  r   r   rn   r   N)r3   r4   r5   r6   r   r   r7   r   r   r	   r   
event_typer   r   r   before_snapshotafter_snapshottriggered_byr   r:   r;   r<   r@   r.   r,   rS  rS  %  s    #M	T	6BuDAKMJ!OZ^_Jse4J-KTD1OD40N&*t4L(*;*;*B*BCJr.   rS  c                      e Zd ZdZ eedd      Z e ed      dd      Z e ed      d      Z	 e ed	      d      Z
 e ed
      d      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z e ed      dd      Z eeej:                  j<                        Zy)ModelShootoutResultmodel_shootout_resultsTr   $   Fr   r   r   r   rn   rM   rH  rO   r   N) r3   r4   r5   r6   r   r   r7   r   shootout_idr   
model_namerK  r   raw_responser   parsed_resultniche_countr   avg_niche_scorerP  rL  rM  rN  rO  	citationsquality_scoresr   r_   r   r:   r;   r<   r@   r.   r,   rZ  rZ  3  s   ,M	T	6Be4@Ku5Kse4JfRj51H$.L4$/M40KUT2Og5'D1L7T2M'D1L540Mtd+ID40N4$/MF2J	BF(*;*;*B*BCJr.   rZ  c                   f   e Zd ZdZ eedd      Z e ed      ddd      Z e ed      d      Z	 e ed	      dd
      Z
 eed      Z e ed	      dd      Z eed      Z eed      Z eed      Z eed      Z eed      Z e ed      dd      Z e ed      d      Z eed      Z eed      Z eeej4                  j6                        Z eeej4                  j6                  ej4                  j6                        Z eddd      Z eddd      Z ddZ!y)LlmProviderllm_providersTr   rn   Fr   r   r      cloudrO   openair   rM   z#6366F1r   r   rD   LlmCredentialrK  rS   r   LlmModelc                 $   i d| j                   d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  d| j                  d	| j                  d
| j                  d| j                  d| j                  d| j                  d| j                  d| j                  d| j                  rt!        | j                        ndd| j"                  r| j"                  j%                         dz   nd }|r7| j&                  r+| j&                  D cg c]  }|j)                          c}|d<   | j                  r+| j                  D cg c]  }|j)                          c}|d<   |S c c}w c c}w )Nr7   r  r  provider_typebase_urlsdk_typesupports_jsonsupports_visionsupports_image_gensupports_streaming	is_activecoloricondisplay_order	meta_jsonmodel_countr   r<   r\   credentialsmodels)r7   r  r  rn  ro  rp  rq  rr  rs  rt  ru  rv  rw  rx  ry  r|  rh   r<   rf   r{  rj   )r+   include_credsr   rz   r9  s        r,   rj   zLlmProvider.to_dictc  s   
$''
DII
 DII
 T//	

 
 
 T//
 t33
 !$"9"9
 !$"9"9
 
 TZZ
 DII
 T//
 
  t{{3t{{+!
" t$//335;TX#
& T--595E5EF		FAm;;04<1199;<AhK  G<s   2F)FNr:  )"r3   r4   r5   r6   r   r   r7   r   r  r  rn  r   ro  rp  r   rq  rr  rs  rt  ru  rv  rw  rx  r   ry  r   r:   r;   r<   rH   r   r{  r|  rj   r@   r.   r,   rf  rf  K  sB   #M	T	6B&*TEFD&+.D6":wGMdT*HfRj5(CH7D1MWe4O76w-I6":i@E&*t,D7A.Mtd+I(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJzSghK*ZI]^Fr.   rf  c                      e Zd ZdZ eedd      Z ee edd      d      Z e e	d	      dd
      Z
 eed      Z eed      Z eed      Z eed      Z e e	d      d      Z eed      Z eeej(                  j*                        Z eeej(                  j*                  ej(                  j*                        Z edd      Zd Zy)rk  llm_credentialsTr   llm_providers.idr>  r?  Fr   r   DefaultrO   r   rM   rD   rf  r{  ro   c                    | j                   | j                  | j                  | j                  | j                  | j
                  rd| j
                  dd  z   nd | j                  r| j                  j                         dz   nd | j                  | j                  | j                  r| j                  j                         dz   d
S d d
S )Nz****ir\   )
r7   provider_idr   r   ru  key_previewlast_tested_atlast_test_statuslast_test_latency_msr<   )r7   r  r   r   ru  encrypted_api_keyr  rf   r  r  r<   ri   s    r,   rj   zLlmCredential.to_dict  s    ''++ZZ//CGCYCY6D$:$:23$??_cGKGZGZd11;;=C`d $ 5 5$($=$=?C$//335;
 	
 UY
 	
r.   N)r3   r4   r5   r6   r   r   r7   r	   r  r   r   r   r  r   r   ru  r   r  r  r  r:   r;   r<   rH   r   rK  rj   r@   r.   r,   rk  rk  ~  s    %M	T	6B*-?)"T_deK6#;	BEte4.Jw-IHt4NfRj48!'D9(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJM-HH
r.   rk  c                      e Zd ZdZ eedd      Z ee edd      d      Z e e	d	      d      Z
 e e	d	      d      Z e e	d
      dd      Z e e	d      dd      Z eed      Z eed      Z eed      Z eed      Z eed      Z eeej.                  j0                        Z edd      Zd Zy)rl  
llm_modelsTr   r  r>  r?  Fr      r   textrO   rM   r   r   rf  r|  ro   c                 R   | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  r| j                  j                         dz   dS d dS )Nr\   )r7   r  model_iddisplay_namemodequality_tiercontext_windowinput_cost_per_mtokoutput_cost_per_mtokru  ry  r<   )r7   r  r  r  r  r  r  r  r  ru  ry  r<   rf   ri   s    r,   rj   zLlmModel.to_dict  s    ''++ --II --"11#'#;#;$($=$=?C$//335;
 	
 UY
 	
r.   N)r3   r4   r5   r6   r   r   r7   r	   r  r   r  r  r  r  r  r   r  r  r   ru  r   ry  r   r:   r;   r<   r   rK  rj   r@   r.   r,   rl  rl    s     M	T	6B*-?)"T_deKfSkE2H&+6L&+v>D&*uiHLGd3N 6!%$7w-Itd+I(*;*;*B*BCJM(CH
r.   rl  c                   2   e Zd ZdZ eedd      Z e ed      dd      Z ee e	dd	      d
      Z
 e ed      d
      Z eed      Z eed      Z eeej                   j"                  ej                   j"                        Z ed      Zd Zy)LlmRoute
llm_routesTr   r   Fr   r  r>  r?  r   r  r   r   rD   rf  c           
      p   | j                   | j                  | j                  | j                  r| j                  j                  nd | j                  r| j                  j
                  nd | j                  | j                  | j                  | j                  r| j                  j                         dz   d	S d d	S )Nr\   )	r7   	stage_keyr  provider_slugprovider_namer  priorityru  rH   )r7   r  r  rK  r  r  r  r  ru  rH   rf   ri   s    r,   rj   zLlmRoute.to_dict  s    ''++37==T]]//d37==T]]//d?C$//335;

 
	
 UY

 
	
r.   N)r3   r4   r5   r6   r   r   r7   r   r  r	   r  r  r  r   ru  r   r:   r;   rH   r   rK  rj   r@   r.   r,   r  r    s     M	T	6Bvc{U$?I*-?)"T_deKfSkE2Hgq)Hw-I(*;*;*B*BXM^M^MeMefJM*H
r.   r  c                      e Zd ZdZ eedd      Z e ed      dd      Z e ed      d      Z	 ee
d      Z e ed	      dd
      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z eed      Z e ed      dd      Z ee
d      Z eed      Z eeej4                  j6                        Z eeej4                  j6                  ej4                  j6                        Zd Zy)MarketplaceListingmarketplace_listingsTr   r   Fr   rn   r   rh  activerO   r   r   rM   rP   rD   c                    i d| j                   d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  d| j                  d	| j                  d
| j                  d| j                  r| j                  j                         dz   nd d| j                  r| j                  j                         dz   nd d| j                  d| j                  d| j                  d| j                   r| j                   j                         dz   nd d| j"                  r| j"                  j                         dz   S d S )Nr7   rb   platformlisting_urllisting_statusasking_pricecurrent_bid	bid_countviewswatchers	listed_atr\   
expires_atsourcenotes
extra_datar<   rH   )r7   rb   r  r  r  r  r  r  r  r  r  rf   r  r  r  r  r<   rH   ri   s    r,   rj   zMarketplaceListing.to_dict  s   
$''
dkk
 
 4++	

 d11
 D--
 4++
 
 TZZ
 
 T^^113c9QU
 t$//335;TX
 dkk
 TZZ
 $//
  t$//335;TX!
" t$//335;#
 	
" UY#
 	
r.   N)r3   r4   r5   r6   r   r   r7   r   rb   r  r   r  r  r   r  r  r  r  r  r   r  r  r  r  r   r  r:   r;   r<   rH   rj   r@   r.   r,   r  r    s   *M	T	6BF3K%t<FfRj51H-KF2JIN%$/L.Kw*I7A&Egq)Hx$/I40JF2JAF4$'Et,J(*;*;*B*BCJ(*;*;*B*BXM^M^MeMefJ
r.   r  )2r:   r$   
sqlalchemyr   r   r   r   r   r   r	   r
   r   r   sqlalchemy.ormr   app.databaser   metadatar   r   rB   rJ   rQ   rX   r|   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r  r0  r2  rE  rS  rZ  rf  rk  rl  r  r  r@   r.   r,   <module>r     s     g g g '  MM
?GZ0@%AtT
<*]";N	 \t \"g$ g 
d  
F
d 
.
 
8 D
 
2
D 
>
4 
8
bT 
bId IDFd F$Ed E"et e&BD B.
3$ 
33 3
g$ 
ggT ggD g-
$ -
`t 8
$ 
,DD D(D$ DD$ D00$ 0f
D 
@ 
t  
F
t 
6(
 (
r.   