o
    +i                     @  s  d Z ddlmZ ddlmZ ddlmZmZmZ ddlm	Z	 ddl
mZ ddlmZmZmZmZmZmZ ddlmZ dd	lmZmZ zdd
lmZmZmZmZmZmZ W n eym   dd
l mZmZmZmZmZmZ Y nw ddl!m"Z" ddlm#Z# eeeedf Z$ee%e&df Z'G dd deZ(e%e&ee)e&e*f e(e)e&e"f f f Z+	 eG dd deZ,G dd deZ-G dd deZ.ee(e.e)e&e*f e)e&e"f f Z/G dd deZ0e0Z1G dd de0Z2G dd deZ3G dd de-Z4G dd de-Z5G d d! d!eZ6G d"d# d#eZ7e7Z8G d$d% d%e&eZ9G d&d' d'eZ:e#d( Z;G d)d* d*ed+d,Z<G d-d. d.e:Z=G d/d0 d0eZ>d1d2 Z?G d3d4 d4eZ@G d5d6 d6e@ZAG d7d8 d8e&eZBG d9d: d:ed+d,ZCG d;d< d<e@ZDG d=d> d>eZEG d?d@ d@eEZFG dAdB dBeEZGG dCdD dDeZHG dEdF dFeZIG dGdH dHed+d,ZJG dIdJ dJed+d,ZKG dKdL dLeIZLG dMdN dNeIZMG dOdP dPeZNG dQdR dReNZOeG dSdT dTeZPG dUdV dVed+d,ZQG dWdX dXeZRG dYdZ dZeRZSG d[d\ d\ed+d,ZTG d]d^ d^eZUe4V  G d_d` d`eZWG dadb dbeZXG dcdd dded+d,ZYG dedf dfed+d,ZZG dgdh dheZ[G didj djeZ\G dkdl dleZ]G dmdn dneZ^G dodp dpeZ_G dqdr dreZ`G dsdt dte&eZaG dudv dved+d,ZbG dwdx dxed+d,ZcG dydz dzed+d,ZdG d{d| d|ed+d,ZeG d}d~ d~eZfG dd ded+d,ZgG dd deZhG dd de4ZiG dd deZjG dd deZkG dd deZldS )zSchemas for the LangSmith API.    )annotations)Iterator)datetime	timedeltatimezone)Decimal)Enum)Any
NamedTupleOptionalProtocolUnionruntime_checkable)UUID)NotRequired	TypedDict)	BaseModelFieldPrivateAttr
StrictBoolStrictFloat	StrictInt)Path)LiteralNc                   @  "   e Zd ZU dZded< ded< dS )
Attachmenta  Annotated type that will be stored as an attachment if used.

    Examples:
        ```python
        from langsmith import traceable
        from langsmith.schemas import Attachment


        @traceable
        def my_function(bar: int, my_val: Attachment):
            # my_val will be stored as an attachment
            # bar will be stored as inputs
            return bar
        ```
    str	mime_typeUnion[bytes, Path]dataN__name__
__module____qualname____doc____annotations__ r&   r&   N/var/www/html/psymed-ai/venv/lib/python3.10/site-packages/langsmith/schemas.pyr   0   s   
 r   c                   @  s2   e Zd ZdZddddZddddZdddZdS )BinaryIOLikez$Protocol for binary IO-like objects.sizeintreturnbytesc                 C     dS )zRead function.Nr&   )selfr*   r&   r&   r'   readP      zBinaryIOLike.readr   offsetwhencec                 C  r.   )zSeek function.Nr&   )r/   r2   r3   r&   r&   r'   seekT   r1   zBinaryIOLike.seekc                 C  r.   )zGet value function.Nr&   r/   r&   r&   r'   getvalueX   r1   zBinaryIOLike.getvalueN)r)   )r*   r+   r,   r-   )r   )r2   r+   r3   r+   r,   r+   )r,   r-   )r!   r"   r#   r$   r0   r4   r6   r&   r&   r&   r'   r(   L   s
    r(   c                   @  s^   e Zd ZU dZded< eddZded< eddZded< eddZded	< G d
d dZ	dS )ExampleBasezExample base model.r   
dataset_idNdefaultOptional[dict[str, Any]]inputsoutputsmetadatac                   @  s   e Zd ZdZdZdZdS )zExampleBase.Config#Configuration class for the schema.TN)r!   r"   r#   r$   frozenarbitrary_types_allowedr&   r&   r&   r'   Confige   s    rB   )
r!   r"   r#   r$   r%   r   r<   r=   r>   rB   r&   r&   r&   r'   r7   ]   s   
 r7   c                   @  s   e Zd ZU ded< ded< dS )_AttachmentDictr   r   r   r   N)r!   r"   r#   r%   r&   r&   r&   r'   rC   l   s   
 rC   c                      s   e Zd ZU dZded< edd dZded< ed	d
Zded< ed	d
Zded< ed	d
Z	ded< d	Z
ded< d	Zded< dZded< d	Zded< d	Zded<  fddZ  ZS )ExampleCreatez Example upload with attachments.Optional[UUID]idc                   C     t tjS Nr   nowr   utcr&   r&   r&   r'   <lambda>z       zExampleCreate.<lambda>default_factoryr   
created_atNr9   r;   r<   r=   r>   Optional[Union[str, list[str]]]splitz$Optional[dict[str, _AttachmentLike]]attachmentsFbooluse_source_run_ioOptional[list[str]]use_source_run_attachmentssource_run_idc                      t  jdi | dS zInitialize from dict.Nr&   super__init__r/   r   	__class__r&   r'   r]         zExampleCreate.__init__)r!   r"   r#   r$   r%   r   rP   r<   r=   r>   rR   rS   rU   rW   rX   r]   __classcell__r&   r&   r_   r'   rD   v   s   
 rD   c                   @     e Zd ZU dZded< dS )ExampleUpsertWithAttachmentsz Example create with attachments.r   r8   Nr    r&   r&   r&   r'   rd         
 rd   c                   @  s*   e Zd ZU dZded< ded< ded< dS )	AttachmentInfozInfo for an attachment.r   presigned_urlr(   readerOptional[str]r   Nr    r&   r&   r&   r'   rf      s
   
 rf   c                      s   e Zd ZU dZded< edd dZded< eed	d
Zded< edd
Z	ded< dZ
ded< edd
Zded< 	 edd
Zded< edd
Zded< 		d d! fddZed"ddZdd Z  ZS )#ExamplezExample model.r   rF   c                   C  s   t jdtjdS )Nr   )tz)r   fromtimestampr   rK   r&   r&   r&   r'   rL      s    zExample.<lambda>rN   r   rP   z$00000000-0000-0000-0000-000000000000r9   r8   NOptional[datetime]modified_atrE   rX   z#Optional[dict[str, AttachmentInfo]]rS   ri   	_host_url
_tenant_idkwargsr	   r,   Nonec                   s"   t  jdi | || _|| _dS )Initialize a Dataset object.Nr&   )r\   r]   ro   rp   )r/   ro   rp   rq   r_   r&   r'   r]      s   
zExample.__init__c                 C  sL   | j r$d| j d| j }| jr| j  dt| j | S | j  | S dS )URL of this run within the app.
/datasets/z/e//o/N)ro   r8   rF   rp   r   )r/   pathr&   r&   r'   url   s   zExample.urlc                 C  $   | j  d| j d| j d| j dS )5Return a string representation of the RunBase object.(id=z, dataset_id=z, link=''))r`   rF   r8   rx   r5   r&   r&   r'   __repr__      $zExample.__repr__)NN)ro   ri   rp   rE   rq   r	   r,   rr   r,   ri   )r!   r"   r#   r$   r%   r   rP   r   r8   rn   rX   rS   r   ro   rp   r]   propertyrx   r}   rb   r&   r&   r_   r'   rj      s&   
 	rj   c                   @  rc   )ExampleSearchzExample returned via search.r   rF   Nr    r&   r&   r&   r'   r      re   r   c                   @  s:   e Zd ZU dZeeddZded< eeddZ	ded< d	S )
AttachmentsOperationsz%Operations to perform on attachments.z,Mapping of old attachment names to new names)rO   descriptionzdict[str, str]renamez List of attachment names to keep	list[str]retainN)
r!   r"   r#   r$   r   dictr   r%   listr   r&   r&   r&   r'   r      s   
 r   c                      s   e Zd ZU dZded< dZded< eddZded	< eddZded
< eddZ	ded< dZ
ded< dZded< dZded< G dd dZ fddZ  ZS )ExampleUpdatez Example update with attachments.r   rF   NrE   r8   r9   r;   r<   r=   r>   rQ   rR   zOptional[Attachments]rS   zOptional[AttachmentsOperations]attachments_operationsc                   @     e Zd ZdZdZdS )zExampleUpdate.Configr?   TNr!   r"   r#   r$   r@   r&   r&   r&   r'   rB          rB   c                   rY   rZ   r[   r^   r_   r&   r'   r]      ra   zExampleUpdate.__init__)r!   r"   r#   r$   r%   r8   r   r<   r=   r>   rR   rS   r   rB   r]   rb   r&   r&   r_   r'   r      s   
 r   c                   @  s   e Zd ZdZdZdZdZdS )DataTypezEnum for dataset data types.kvllmchatN)r!   r"   r#   r$   r   r   r   r&   r&   r&   r'   r      s
    r   c                   @  s@   e Zd ZU dZded< dZded< dZded< G d	d
 d
ZdS )DatasetBasezDataset base model.r   nameNri   r   zOptional[DataType]	data_typec                   @  r   )zDatasetBase.Configr?   TNr   r&   r&   r&   r'   rB      r   rB   )r!   r"   r#   r$   r%   r   r   rB   r&   r&   r&   r'   r      s   
 r   )remove_system_messagesconvert_to_openai_messageconvert_to_openai_toolremove_extra_fieldsextract_tools_from_runc                   @  r   )DatasetTransformationz#Schema for dataset transformations.r   rw   z%Union[DatasetTransformationType, str]transformation_typeNr    r&   r&   r&   r'   r     s   
 r   F)totalc                      s   e Zd ZU dZded< ded< eddZded	< dZd
ed< dZd
ed< dZ	ded< dZ
ded< dZded< dZded< dZded< eddZded< eddZded< eddZded< 			d!d" fddZed#dd Z  ZS )$DatasetzDataset ORM model.r   rF   r   rP   Nr9   rm   rn   Optional[int]example_countsession_countlast_session_start_timer;   inputs_schemaoutputs_schemaz%Optional[list[DatasetTransformation]]transformationsr>   ri   ro   rE   rp   _public_pathrq   r	   r,   rr   c                   sT   d|v r| d|d< d|v r| d|d< t jdi | || _|| _|| _dS )rs   inputs_schema_definitionr   outputs_schema_definitionr   Nr&   )popr\   r]   ro   rp   r   )r/   ro   rp   r   rq   r_   r&   r'   r]   $  s   
zDataset.__init__c                 C  sV   | j r)| jr| j  | j S | jr | j  dt| j d| j S | j  d| j S dS )rt   rv   ru   N)ro   r   rp   r   rF   r5   r&   r&   r'   rx   7  s   zDataset.url)NNN)
ro   ri   rp   rE   r   ri   rq   r	   r,   rr   r   )r!   r"   r#   r$   r%   r   rn   r   r   r   r   r   r   r>   r   ro   rp   r   r]   r   rx   rb   r&   r&   r_   r'   r     s*   
 r   c                   @  s&   e Zd ZU dZdZded< ded< dS )DatasetVersionz%Class representing a dataset version.NrV   tagsr   as_of)r!   r"   r#   r$   r   r%   r&   r&   r&   r'   r   C  s   
 r   c                   C  s   di iS )Nr>   r&   r&   r&   r&   r'   _default_extraJ  s   r   c                   @  s&  e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 d	Zd
ed< 	 eedZded< 	 d	Z	ded< 	 d	Z
ded< 	 d	Zded< 	 eedZded< 	 d	Zded< 	 d	Zded< 	 d	Zded< 	 d	Zded< 	 eedZded< 	 ed+d d!Zed,d"d#Zed-d%d&Zd'd( ZG d)d* d*Zd	S ).RunBasea3  Base Run schema.

    A Run is a span representing a single unit of work or operation within your LLM app.
    This could be a single call to an LLM or chain, to a prompt formatting call,
    to a runnable lambda invocation. If you are familiar with OpenTelemetry,
    you can think of a run as a span.
    r   rF   r   r   r   
start_timerun_typeNrm   end_timerN   Optional[dict]extrari   error
serializedOptional[list[dict]]eventsr   r<   r=   rE   reference_example_idparent_run_idrV   r   z-Union[Attachments, dict[str, AttachmentInfo]]rS   r,   dict[str, Any]c                 C  s   | j du ri | _ | j di S zRetrieve the metadata (if any).Nr>   )r   
setdefaultr5   r&   r&   r'   r>     s   
zRunBase.metadatac                 C  s   | j dS )z"Retrieve the revision ID (if any).revision_id)r>   getr5   r&   r&   r'   r     s   zRunBase.revision_idOptional[float]c                 C  s   | j du rdS | j | j  S )zLatency in seconds.N)r   r   total_secondsr5   r&   r&   r'   latency  s   
zRunBase.latencyc                 C  ry   )rz   r{   z, name='z', run_type='r|   )r`   rF   r   r   r5   r&   r&   r'   r}     r~   zRunBase.__repr__c                   @  r   )zRunBase.Configr?   TN)r!   r"   r#   r$   rA   r&   r&   r&   r'   rB     r   rB   r,   r   )r,   rE   )r,   r   )r!   r"   r#   r$   r%   r   r   r   r   r   r   r   r   r<   r=   r   r   r   rS   r   r>   r   r   r}   rB   r&   r&   r&   r'   r   N  sT   
 r   c                      s  e Zd ZU dZdZded< 	 dZded< 	 dZded< 	 dZd	ed
< 	 dZ	ded< 	 dZ
ded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 d ed!< 	 ed"d#Zd$ed%< 	 dZd&ed'< 	 edd#Zded(< dEdF fd-d.ZedGd/d0ZedHd2d3Z edHd4d5Z!edId7d8Z"edId9d:Z#edJd<d=Z$edJd>d?Z%edKdAdBZ&edKdCdDZ'  Z(S )LRunz$Run schema when loading from the DB.NrE   
session_idOptional[list[UUID]]child_run_idszOptional[list[Run]]
child_runsr;   feedback_statsri   app_pathmanifest_idstatusr   prompt_tokenscompletion_tokenstotal_tokenszOptional[dict[str, int]]prompt_token_detailscompletion_token_detailsrm   first_token_timeOptional[Decimal]
total_costprompt_costcompletion_costzOptional[dict[str, Decimal]]prompt_cost_detailscompletion_cost_detailsparent_run_idsr   trace_id r9   r   dotted_orderOptional[bool]
in_datasetro   rq   r	   r,   rr   c                   s~   | dsd| di|}|ddpi }t jdi |d|i || _| j s;| js=| j	  | j
 | _dS dS dS )Initialize a Run object.r   rF   r<   Nr&   )r   r   r\   r]   ro   r   stripr   r   	isoformatrF   )r/   ro   rq   r<   r_   r&   r'   r]     s   
zRun.__init__c                 C  s    | j r| jr| j  | j S dS )rt   N)ro   r   r5   r&   r&   r'   rx     s   zRun.url
int | Nonec                 C     | j S )zAlias for prompt_tokens.)r   r5   r&   r&   r'   input_tokens     zRun.input_tokensc                 C  r   )zAlias for completion_tokens.)r   r5   r&   r&   r'   output_tokens  r   zRun.output_tokensDecimal | Nonec                 C  r   )zAlias for prompt_cost.)r   r5   r&   r&   r'   
input_cost  r   zRun.input_costc                 C  r   )zAlias for completion_cost.)r   r5   r&   r&   r'   output_cost  r   zRun.output_costdict[str, int] | Nonec                 C  r   )zAlias for prompt_token_details.)r   r5   r&   r&   r'   input_token_details  r   zRun.input_token_detailsc                 C  r   )zAlias for output_token_details.)r   r5   r&   r&   r'   output_token_details  r   zRun.output_token_detailsdict[str, Decimal] | Nonec                 C  r   )zAlias for prompt_cost_details.)r   r5   r&   r&   r'   input_cost_details  r   zRun.input_cost_detailsc                 C  r   )z"Alias for completion_cost_details.)r   r5   r&   r&   r'   output_cost_details$  r   zRun.output_cost_detailsrH   ro   ri   rq   r	   r,   rr   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   r   r   r   r   r   r   r   ro   r]   r   rx   r   r   r   r   r   r   r   r   rb   r&   r&   r_   r'   r     s   
 
r   c                   @  s,   e Zd ZdZdZdZdZdZdZdZ	dZ
d	S )
RunTypeEnumz5(Deprecated) Enum for run types. Use string directly.toolchainr   	retriever	embeddingpromptparserN)r!   r"   r#   r$   r   r   r   r   r   r   r   r&   r&   r&   r'   r   *  s    r   c                   @  s   e Zd ZU dZded< ded< ded< ded	< ded
< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< d ed!< ded"< d#ed$< d%S )&RunLikeDictz&Run-like dictionary, for type-hinting.r   r   r   r   r   r   r   r<   r=   rm   r   r   ri   r   r   rE   r   r   r   r   rV   r   inputs_s3_urlsoutputs_s3_urlsrF   r   session_namer   input_attachmentsoutput_attachmentsr   r   r   AttachmentsrS   Nr    r&   r&   r&   r'   r   6  s4   
 r   c                   @  s,   e Zd ZU dZdZded< 	 dZded< dS )RunWithAnnotationQueueInfoz&Run schema with annotation queue info.Nrm   last_reviewed_timeadded_at)r!   r"   r#   r$   r   r%   r   r&   r&   r&   r'   r   S  s   
 r   c                   @  sJ   e Zd ZU dZded< 	 eedZded< 	 dZded	< 	 dZ	d
ed< dS )FeedbackSourceBasezBase class for feedback sources.

    This represents whether feedback is submitted from the API, model, human labeler,
        etc.
    r   typerN   r;   r>   NzOptional[Union[UUID, str]]user_idri   	user_name)
r!   r"   r#   r$   r%   r   r   r>   r  r  r&   r&   r&   r'   r   \  s   
 r   c                   @     e Zd ZU dZdZded< dS )APIFeedbackSourcezAPI feedback source.apizLiteral['api']r  Nr!   r"   r#   r$   r  r%   r&   r&   r&   r'   r  m     
 r  c                   @  r  )ModelFeedbackSourcezModel feedback source.modelzLiteral['model']r  Nr  r&   r&   r&   r'   r	  s  r  r	  c                   @  s   e Zd ZdZdZ	 dZdS )FeedbackSourceTypezFeedback source type.r  r
  N)r!   r"   r#   r$   APIMODELr&   r&   r&   r'   r  y  s    r  c                   @  s   e Zd ZU dZded< 	 dZded< 	 dZded< 	 ded	< 	 ded
< 	 ded< 	 dZded< 	 dZded< 	 dZ	ded< 	 dZ
ded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 dZded< 	 G dd dZdS )FeedbackBasezFeedback schema.r   rF   Nrm   rP   rn   rE   run_idr   r   key
SCORE_TYPEscore
VALUE_TYPEvalueri   commentzUnion[str, dict, None]
correctionOptional[FeedbackSourceBase]feedback_sourcer   comparative_experiment_idfeedback_group_idr   r   c                   @  r   )zFeedbackBase.Configr?   TNr   r&   r&   r&   r'   rB     r   rB   )r!   r"   r#   r$   r%   rP   rn   r  r  r  r  r  r   r  r  r   rB   r&   r&   r&   r'   r    sB   
 r  c                   @  $   e Zd ZU dZded< 	 ded< dS )FeedbackCategoryz+Specific value and label pair for feedback.floatr  ri   labelNr    r&   r&   r&   r'   r       
 r  c                   @  s8   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< d	S )
FeedbackConfigz:Represents _how_ a feedback value ought to be interpreted.z0Literal['continuous', 'categorical', 'freeform']r  r   minmaxz Optional[list[FeedbackCategory]]
categoriesNr    r&   r&   r&   r'   r     s   
 r   c                   @  s6   e Zd ZU dZded< 	 dZded< 	 dZded< dS )	FeedbackCreatez"Schema used for creating feedback.r   r  NzOptional[FeedbackConfig]feedback_configr   r   )r!   r"   r#   r$   r%   r%  r   r&   r&   r&   r'   r$    s   
 r$  c                   @  s:   e Zd ZU dZded< ded< 	 ded< 	 dZded	< dS )
FeedbackzSchema for getting feedback.r   rF   r   rP   rn   Nr  r  )r!   r"   r#   r$   r%   r  r&   r&   r&   r'   r&    s   
 r&  c                      s   e Zd ZU dZded< 	 edd dZded< 	 d	Zd
ed< 	 d	Zded< 	 d	Z	ded< 	 d	Z
ded< 	 ded< 	 ded< 	 ed	dZded< d$d% fddZed&ddZed'dd Zed(d"d#Z  ZS ))TracerSessionzbTracerSession schema for the API.

    Sessions are also referred to as "Projects" in the UI.
    r   rF   c                   C  rG   rH   rI   r&   r&   r&   r'   rL     rM   zTracerSession.<lambda>rN   r   r   Nrm   r   ri   r   r   r;   r   	tenant_idrE   reference_dataset_idr9   ro   rq   r	   r,   rr   c                   s>   t  jdi | || _| jjdu r| jjtjd| _dS dS )r   N)tzinfor&   )r\   r]   ro   r   r*  replacer   rK   )r/   ro   rq   r_   r&   r'   r]     s
   zTracerSession.__init__c                 C  s$   | j r| j  d| j d| j S dS )rt   rv   /projects/p/N)ro   r(  rF   r5   r&   r&   r'   rx     s   zTracerSession.urlr   c                 C  "   | j du s
d| j vri S | j d S r   r   r5   r&   r&   r'   r>         
zTracerSession.metadatar   c                 C  s"   | j du s
d| j vrg S | j d S )zRetrieve the tags (if any).Nr   r.  r5   r&   r&   r'   r     r/  zTracerSession.tagsrH   r   r   r   )r,   r   )r!   r"   r#   r$   r%   r   r   r   r   r   r   r   ro   r]   r   rx   r>   r   rb   r&   r&   r_   r'   r'    s4   
 r'  c                   @  s   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded	< 	 d
ed< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< dS )TracerSessionResultzqA project, hydrated with additional information.

    Sessions are also referred to as "Projects" in the UI.
    r   	run_countOptional[timedelta]latency_p50latency_p99r   r   r   rm   last_run_start_timer;   r   session_feedback_statsOptional[list[dict[str, Any]]]
run_facetsr   r   r   r   first_token_p50first_token_p99r   
error_rateNr    r&   r&   r&   r'   r0    sD   
 r0  c                   @  s4   e Zd ZU dZded< 	 ded< 	 ed
ddZd	S )BaseMessageLikez7A protocol representing objects similar to BaseMessage.r   contentzdict[Any, Any]additional_kwargsr,   c                 C  r.   )z,Type of the Message, used for serialization.Nr&   r5   r&   r&   r'   r  @  s    zBaseMessageLike.typeNr,   r   )r!   r"   r#   r$   r%   r   r  r&   r&   r&   r'   r<  7  s   
 r<  c                   @  s.   e Zd ZU dZded< 	 ded< 	 ded< dS )DatasetShareSchemaz*Represents the schema for a dataset share.r   r8   share_tokenr   rx   Nr    r&   r&   r&   r'   r@  E     
 r@  c                   @  sl   e Zd ZU dZded< 	 ded< 	 dZded< 	 ed	d
 dZded< 	 edd
 dZded< 	 ded< dS )AnnotationQueuezRepresents an annotation queue.r   rF   r   r   Nri   r   c                   C  rG   rH   rI   r&   r&   r&   r'   rL   Y  rM   zAnnotationQueue.<lambda>rN   r   rP   c                   C  rG   rH   rI   r&   r&   r&   r'   rL   [  rM   
updated_atr(  )	r!   r"   r#   r$   r%   r   r   rP   rD  r&   r&   r&   r'   rC  P  s   
 rC  c                   @  s   e Zd ZU dZdZded< dS )AnnotationQueueWithDetailsz,Represents an annotation queue with details.Nri   rubric_instructions)r!   r"   r#   r$   rF  r%   r&   r&   r&   r'   rE  a  s   
 rE  c                   @  sL   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 ded< 	 d	ed
< dS )BatchIngestConfigz"Configuration for batch ingestion.rT   use_multipart_endpointr+   scale_up_qsize_triggerscale_up_nthreads_limitscale_down_nempty_trigger
size_limitr   size_limit_bytesNr    r&   r&   r&   r'   rG  h  s   
 rG  c                   @  sH   e Zd ZU dZdZded< 	 dZded< 	 dZded	< 	 dZd
ed< dS )LangSmithInfoz'Information about the LangSmith server.r   r   versionNrm   license_expiration_timezOptional[BatchIngestConfig]batch_ingest_configr;   instance_flags)	r!   r"   r#   r$   rO  r%   rP  rQ  rR  r&   r&   r&   r'   rN  y  s   
 rN  c                   @  s<   e Zd ZU dZded< 	 ded< 	 ded< 	 dZded	< dS )
LangSmithSettingsz"Settings for the LangSmith tenant.r   rF   display_namer   rP   Nri   tenant_handle)r!   r"   r#   r$   r%   rU  r&   r&   r&   r'   rS    s   
 rS  c                   @  .   e Zd ZU dZded< 	 ded< 	 ded< dS )	FeedbackIngestTokenz2Represents the schema for a feedback ingest token.r   rF   r   rx   r   
expires_atNr    r&   r&   r&   r'   rW    rB  rW  c                   @  rV  )	RunEventzRun event schema.r   r   zUnion[datetime, str]timer;   rq   Nr    r&   r&   r&   r'   rY    rB  rY  c                   @  .   e Zd ZU dZded< 	 ded< 	 ded< dS )TimeDeltaInputzTimedelta input schema.r+   dayshoursminutesNr    r&   r&   r&   r'   r\    rB  r\  c                   @  r[  )DatasetDiffInfoz;Represents the difference information between two datasets.z
list[UUID]examples_modifiedexamples_addedexamples_removedNr    r&   r&   r&   r'   r`    rB  r`  c                   @  s   e Zd ZU dZded< 	 dZded< 	 dZded< 	 ded< 	 d	ed
< 	 d	ed< 	 ded< 	 dZded< 	 dZded< 	 dZ	ded< 	 e
dddZdS )ComparativeExperimentzRepresents a comparative experiment.

    This information summarizes evaluation results comparing
    two or more models on a given dataset.
    r   rF   Nri   r   r   r(  r   rP   rn   r)  r;   r   r   experiments_infor   r,   r   c                 C  r-  r   r.  r5   r&   r&   r'   r>     r/  zComparativeExperiment.metadatar   )r!   r"   r#   r$   r%   r   r   r   re  r   r   r>   r&   r&   r&   r'   rd    s0   
 rd  c                   @  sB   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 ded	< d
S )PromptCommitz$Represents a Prompt with a manifest.r   ownerrepocommit_hashr   manifestz
list[dict]examplesNr    r&   r&   r&   r'   rf    s   
 rf  c                   @  s   e Zd ZU dZded< 	 ded< 	 ded< 	 dZded	< 	 dZded
< 	 dZded< 	 dZded< 	 dZ	ded< 	 dZ
ded< 	 eedZded< 	 dZded< 	 dZded< 	 dZded< dS )ListedPromptCommitz;Represents a listed prompt commit with associated metadata.r   rF   r   rg  rh  NrE   r   repo_id	parent_idri   ri  rm   rP   rD  rN   r   example_run_idsr   r   num_downloads	num_viewsparent_commit_hash)r!   r"   r#   r$   r%   r   rm  rn  ri  rP   rD  r   r   ro  rp  rq  rr  r&   r&   r&   r'   rl    s8   
 rl  c                   @  s  e Zd ZU dZded< 	 dZded< 	 dZded< 	 ded< 	 ded	< 	 d
ed< 	 d
ed< 	 ded< 	 ded< 	 ded< 	 dZded< 	 dZded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 dZ	ded< 	 dZ
ded< 	 ded< 	 dZded< 	 dZded< dS ) Promptz"Represents a Prompt with metadata.r   repo_handleNri   r   readmerF   r(  r   rP   rD  rT   	is_publicis_archivedr   r   original_repo_idupstream_repo_idrg  	full_namer+   	num_likesrp  rq  r   liked_by_auth_userlast_commit_hashnum_commitsoriginal_repo_full_nameupstream_repo_full_name)r!   r"   r#   r$   r%   r   ru  rx  ry  r|  r}  r  r  r&   r&   r&   r'   rs    s\   
 rs  c                   @  r  )ListPromptsResponsez A list of prompts with metadata.zlist[Prompt]reposr+   r   Nr    r&   r&   r&   r'   r  O  r  r  c                   @  s&   e Zd ZdZdZ	 dZ	 dZ	 dZdS )PromptSortFieldz$Enum for sorting fields for prompts.rp  rq  rD  r{  N)r!   r"   r#   r$   rp  rq  rD  r{  r&   r&   r&   r'   r  X  s    r  c                   @  r[  )InputTokenDetailsz~Breakdown of input token counts.

    Does *not* need to sum to full input token count. Does *not* need to have all keys.
    r+   audiocache_creation
cache_readNr    r&   r&   r&   r'   r  e     
 r  c                   @  $   e Zd ZU dZded< 	 ded< dS )OutputTokenDetailszBreakdown of output token counts.

    Does *not* need to sum to full output token count. Does *not* need to have all keys.
    r+   r  	reasoningNr    r&   r&   r&   r'   r  z     
 r  c                   @  r[  )InputCostDetailszvBreakdown of input token costs.

    Does *not* need to sum to full input cost. Does *not* need to have all keys.
    r  r  r  r  Nr    r&   r&   r&   r'   r    r  r  c                   @  r  )OutputCostDetailszxBreakdown of output token costs.

    Does *not* need to sum to full output cost. Does *not* need to have all keys.
    r  r  r  Nr    r&   r&   r&   r'   r    r  r  c                   @  t   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 ded	< 	 d
ed< 	 d
ed< 	 d
ed< 	 ded< 	 ded< dS )UsageMetadatazUsage metadata for a message, such as token counts.

    This is a standard representation of token usage that is consistent across models.
    r+   r   r   r   zNotRequired[InputTokenDetails]r   zNotRequired[OutputTokenDetails]r   zNotRequired[float]r   r   r   zNotRequired[InputCostDetails]r   zNotRequired[OutputCostDetails]r   Nr    r&   r&   r&   r'   r    s,   
 r  c                   @  r  )ExtractedUsageMetadatazUsage metadata dictionary extracted from a run.

    Should be the same as UsageMetadata, but does not require all
    keys to be present.
    r+   r   r   r   r  r   r  r   r  r   r   r   r  r   r  r   Nr    r&   r&   r&   r'   r    s,   
 r  c                   @  r  )UpsertExamplesResponsezCResponse object returned from the upsert_examples_multipart method.r+   countr   example_idsNr    r&   r&   r&   r'   r    r  r  c                   @  s$   e Zd ZU dZeedZded< dS )ExampleWithRunszExample with runs.rN   z	list[Run]runsN)r!   r"   r#   r$   r   r   r  r%   r&   r&   r&   r'   r    s   
 r  c                   @  s   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded	< 	 d
ed< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< dS )ExperimentRunStatsz!Run statistics for an experiment.r   r1  r2  r3  r4  r   r   r   rm   r5  r7  r8  r   r   r   r   r9  r:  r   r;  Nr    r&   r&   r&   r'   r    s<   
 r  c                   @  rV  )	ExperimentResultszResults container for experiment data with stats and examples.

    Breaking change in v0.4.32:
        The 'stats' field has been split into 'feedback_stats' and 'run_stats'.
    r   r   r  	run_statszIterator[ExampleWithRuns]examples_with_runsNr    r&   r&   r&   r'   r     s   
 r  c                   @  sf   e Zd ZU dZded< ded< ded< dZded	< ded
< ded< ded< edddZdddZdS )InsightsReportzHAn Insights Report created by the Insights Agent over a tracing project.z
UUID | strrF   r   r   r   Nz
str | Noner   
project_idhost_urlr(  r,   c                 C  s.   | j  dt| j dt| j dt| j S )z1URL to view this Insights Report in LangSmith UI.rv   r,  z?tab=4&clusterJobId=)r  r   r(  r  rF   r5   r&   r&   r'   link9  s   .zInsightsReport.linkc                 C  s   d| j  d| j dS )Nz	<a href="z2", target="_blank" rel="noopener">InsightsReport('z')</a>)r  r   r5   r&   r&   r'   _repr_html_>  s   zInsightsReport._repr_html_r?  )	r!   r"   r#   r$   r%   r   r   r  r  r&   r&   r&   r'   r  .  s   
 r  )mr$   
__future__r   collections.abcr   r   r   r   decimalr   enumr   typingr	   r
   r   r   r   r   uuidr   typing_extensionsr   r   pydantic.v1r   r   r   r   r   r   ImportErrorpydanticpathlibr   r   r  r   r   r  r   tupler-   r   r(   r7   rC   _AttachmentLikerD   ExampleUploadWithAttachmentsrd   rf   rj   r   r   r   ExampleUpdateWithAttachmentsr   r   DatasetTransformationTyper   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r   r$  r&  r'  r0  r<  r@  rC  rE  rG  rN  update_forward_refsrS  rW  rY  r\  r`  rd  rf  rl  rs  r  r  r  r  r  r  r  r  r  r  r  r  r  r&   r&   r&   r'   <module>   s     $$
&*	0Z 		*	
6($+1	"	!