
    a
i                    
   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 ddlmZmZmZmZmZmZmZ dd	lmZ dd
lmZmZmZmZmZmZmZ ddl m!Z!m"Z"m#Z# eeeedf         Z$ee%e&eeedf         Z' G d de          Z(e%e&ee)e&e*f         e(e)e&ef         f         f         Z+	 e G d de                      Z, G d de          Z- G d de#          Z.ee(e.e)e&e*f         e)e&ef         f         Z/ G d de          Z0e0Z1 G d de0          Z2 G d de#          Z3 G d de-          Z4 G d de-          Z5 G d d e          Z6 G d! d"e          Z7e7Z8 G d# d$e&e          Z9 G d% d&e          Z:e!d'         Z; G d( d)e#d*+          Z< G d, d-e:          Z= G d. d/e          Z>d0 Z? G d1 d2e          Z@ G d3 d4e@          ZA G d5 d6e&e          ZB G d7 d8e#d*+          ZC G d9 d:e@          ZD G d; d<e          ZE G d= d>eE          ZF G d? d@eE          ZG G dA dBe          ZH G dC dDe          ZI G dE dFe#d*+          ZJ G dG dHe#d*+          ZK G dI dJeI          ZL G dK dLeI          ZM G dM dNe          ZN G dO dPeN          ZOe G dQ dRe                      ZP G dS dTe#d*+          ZQ G dU dVe#d*+          ZR G dW dXe          ZS G dY dZeS          ZT G d[ d\e#d*+          ZU G d] d^e          ZVe4W                                  G d_ d`e          ZX G da dbe          ZY G dc dde#d*+          ZZ G de dfe#d*+          Z[ G dg dhe          Z\ G di dje          Z] G dk dle          Z^ G dm dne          Z_ G do dpe          Z` G dq dre          Za G ds dte&e          Zb G du dve#d*+          Zc G dw dxe#d*+          Zd G dy dze#d*+          Ze G d{ d|e#d*+          Zf G d} d~e#          Zg G d de#d*+          Zh G d de#          Zi G d de4          Zj G d de#          Zk G d de#          Zl G d de          Zm G d de          Zn G d de          Zo G d de          ZpddddZq G d d          Zr G d d          Zs G d de          Zt G d de          Zu G d de          Zv G d de          Zw G d dev          Zx G d de          ZydS )zSchemas for the LangSmith API.    )annotations)Iterator)datetime	timedeltatimezone)Decimal)Enum)Path)	AnnotatedAny
NamedTupleOptionalProtocolUnionruntime_checkable)UUID)	BaseModel
ConfigDictFieldPrivateAttr
StrictBoolStrictFloat	StrictInt)LiteralNotRequired	TypedDictNc                  (    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__     C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\langsmith/schemas.pyr   r   $   s3            NNNr*   r   c                  .    e Zd ZdZdddZdddZddZdS )BinaryIOLikez$Protocol for binary IO-like objects.sizeintreturnbytesc                    dS )zRead function.Nr)   )selfr/   s     r+   readzBinaryIOLike.readD       r*   r   offsetwhencec                    dS )zSeek function.Nr)   )r4   r7   r8   s      r+   seekzBinaryIOLike.seekH   r6   r*   c                    dS )zGet value function.Nr)   r4   s    r+   getvaluezBinaryIOLike.getvalueL   r6   r*   N)r.   )r/   r0   r1   r2   )r   )r7   r0   r8   r0   r1   r0   )r1   r2   )r$   r%   r&   r'   r5   r:   r=   r)   r*   r+   r-   r-   @   s`        ..             r*   r-   c                      e Zd ZU dZded<    ed          Zded<    ed          Zded<    ed          Zded	<    e	d
d
          Z
dS )ExampleBasezExample base model.r   
dataset_idNdefaultOptional[dict[str, Any]]inputsoutputsmetadataT)frozenarbitrary_types_allowed)r$   r%   r&   r'   r(   r   rD   rE   rF   r   model_configr)   r*   r+   r?   r?   Q   s         ',uT':':':F::::(-d(;(;(;G;;;;).t)<)<)<H<<<<:T4HHHLLLr*   r?   c                  $    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+   rK   rK   \   s'         NNNr*   rK   c                      e Zd ZU dZdZded<    ed           Zded<    ed	          Zd
ed<    ed	          Z	d
ed<    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<   dZded<    fdZ xZS )ExampleCreatez Example upload with attachments.NOptional[UUID]idc                 >    t          j        t          j                  S Nr   nowr   utcr)   r*   r+   <lambda>zExampleCreate.<lambda>j       hl9S9S r*   default_factoryr   
created_atrA   rC   rD   rE   rF   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__r4   r"   	__class__s     r+   rf   zExampleCreate.__init__t   &      4     r*   )r$   r%   r&   r'   rO   r(   r   rY   rD   rE   rF   r[   r\   r^   r`   ra   rf   __classcell__rh   s   @r+   rM   rM   f   s$        **B 51S1STTTJTTTT',uT':':':F::::(-d(;(;(;G;;;;).t)<)<)<H<<<<-1E11118<K<<<<#####6:::::$(M((((! ! ! ! ! ! ! ! !r*   rM   c                      e Zd ZU dZded<   dS )ExampleUpsertWithAttachmentsz Example create with attachments.r   r@   Nr#   r)   r*   r+   rm   rm   |   s$         **r*   rm   c                  2    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+   ro   ro      s<         !!r*   ro   c                  D    e Zd ZU dZded<    ed           Zded<    e ed          	          Zded
<    ed	          Z	ded<   dZ
ded<    ed	          Zded<   	  ed	          Zded<    ed	          Zded<   	 	 dd fdZedd            Zd Z xZS )ExamplezExample model.r   rO   c                 B    t          j        dt          j                  S )Nr   )tz)r   fromtimestampr   rT   r)   r*   r+   rU   zExample.<lambda>   s     6qX\ J J J r*   rW   r   rY   z$00000000-0000-0000-0000-000000000000rA   r@   NOptional[datetime]modified_atrN   ra   z#Optional[dict[str, AttachmentInfo]]r\   rr   	_host_url
_tenant_idkwargsr   r1   Nonec                V     t                      j        di | || _        || _        dS )Initialize a Dataset object.Nr)   )re   rf   rz   r{   )r4   rz   r{   r|   rh   s       r+   rf   zExample.__init__   s4     	""6""""$r*   c                    | j         rDd| 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)rz   r@   rO   r{   r   )r4   paths     r+   urlzExample.url   so     > 	-===DG==D J.IIS-A-AI4IIIn,d,,,tr*   c                F    | j          d| j         d| j         d| j         dS )5Return a string representation of the RunBase object.(id=z, dataset_id=z, link=''))rh   rO   r@   r   r<   s    r+   __repr__zExample.__repr__   s3    .aadgaaDOaaUYU]aaaar*   )NN)rz   rr   r{   rN   r|   r   r1   r}   r1   rr   )r$   r%   r&   r'   r(   r   rY   r   r@   ry   ra   r\   r   rz   r{   rf   propertyr   r   rj   rk   s   @r+   rt   rt      sz        HHH 5JJ  J     uTT*P%Q%QRRRJRRRR&+eD&9&9&9K9999$(M((((7<uT7J7J7JKJJJJ.*{4888I8888!,T!:!:!:J:::: $(%)	% 	% 	% 	% 	% 	% 	%    Xb b b b b b br*   rt   c                      e Zd ZU dZded<   dS )ExampleSearchzExample returned via search.r   rO   Nr#   r)   r*   r+   r   r      s         &&HHHHHr*   r   c                  \    e Zd ZU dZ eed          Zded<    eed          Z	ded<   d	S )
AttachmentsOperationsz%Operations to perform on attachments.z,Mapping of old attachment names to new names)rX   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~         //"U*X  F     *L  F      r*   r   c                       e Zd ZU dZded<   dZded<    ed          Zded	<    ed          Zded
<    ed          Z	ded<   dZ
ded<   dZded<   dZded<    ed          Z fdZ xZS )ExampleUpdatez Example update with attachments.r   rO   NrN   r@   rA   rC   rD   rE   rF   rZ   r[   zOptional[Attachments]r\   zOptional[AttachmentsOperations]attachments_operationsTrG   c                :     t                      j        di | dS rc   rd   rg   s     r+   rf   zExampleUpdate.__init__   ri   r*   )r$   r%   r&   r'   r(   r@   r   rD   rE   rF   r[   r\   r   r   rI   rf   rj   rk   s   @r+   r   r      s         **HHH!%J%%%%',uT':':':F::::(-d(;(;(;G;;;;).t)<)<)<H<<<<-1E1111)-K---->BBBBB:T***L! ! ! ! ! ! ! ! !r*   r   c                      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#        &&	B
CDDDr*   r   c                  R    e Zd ZU dZded<   dZded<   dZded<    ed	
          ZdS )DatasetBasezDataset base model.r   nameNrr   r   zOptional[DataType]	data_typeTr   )	r$   r%   r&   r'   r(   r   r   r   rI   r)   r*   r+   r   r      sS         III!%K%%%%$(I((((:T***LLLr*   r   )remove_system_messagesconvert_to_openai_messageconvert_to_openai_toolremove_extra_fieldsextract_tools_from_runc                  (    e Zd ZU dZded<   ded<   dS )DatasetTransformationz#Schema for dataset transformations.r   r   z%Union[DatasetTransformationType, str]transformation_typeNr#   r)   r*   r+   r   r      s-         --OOO>>>>>>r*   r   F)totalc                  D    e Zd ZU dZded<   ded<    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<   dZded<   dZded<   dZded<    ed          Zded<    ed          Zded<    ed          Zded<   	 	 	 dd  fdZed!d            Z xZS )"DatasetzDataset ORM model.r   rO   r   rY   NrA   rx   ry   Optional[int]example_countsession_countlast_session_start_timerC   inputs_schemaoutputs_schemaz%Optional[list[DatasetTransformation]]transformationsrF   rr   rz   rN   r{   _public_pathr|   r   r1   r}   c                    d|v r|                     d          |d<   d|v r|                     d          |d<    t                      j        di | || _        || _        || _        dS )r   inputs_schema_definitionr   outputs_schema_definitionr   Nr)   )popre   rf   rz   r{   r   )r4   rz   r{   r   r|   rh   s        r+   rf   zDataset.__init__  s     &//&,jj1K&L&LF?#&&00'-zz2M'N'NF#$""6""""$(r*   c                    | j         rU| j        r| j          | j         S | j        r&| j          dt          | j                   d| j         S | j          d| j         S dS )r   r   r   N)rz   r   r{   r   rO   r<   s    r+   r   zDataset.url!  s     > 	:  >.=$*;=== W.VVS-A-AVVTWVVVn99999tr*   )NNN)
rz   rr   r{   rN   r   rr   r|   r   r1   r}   r   )r$   r%   r&   r'   r(   r   ry   r   r   r   r   r   r   rF   r   rz   r{   r   rf   r   r   rj   rk   s   @r+   r   r      sz        HHH&+eD&9&9&9K9999#'M''''#'M''''266666.2M2222/3N3333=AOAAAA)-H----*{4888I8888!,T!:!:!:J::::"-+d";";";L;;;; $(%)&*	) ) ) ) ) ) )&    X    r*   r   c                  ,    e Zd ZU dZdZded<   ded<   dS )DatasetVersionz%Class representing a dataset version.Nr_   tagsr   as_of)r$   r%   r&   r'   r   r(   r)   r*   r+   r   r   -  s0         // $D$$$$OOOOOr*   r   c                 
    di iS )NrF   r)   r)   r*   r+   _default_extrar   4  s    r*   c                     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          Zded<   	 d	Z	ded<   	 d	Z
ded<   	 d	Zded<   	  ee          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          Zded<   	 ed'd             Zed(d!            Zed)d#            Zd$ Z e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   rO   r   r   r   
start_timerun_typeNrx   end_timerW   Optional[dict]extrarr   error
serializedOptional[list[dict]]eventsr   rD   rE   rN   reference_example_idparent_run_idr_   r   z-Union[Attachments, dict[str, AttachmentInfo]]r\   r1   dict[str, Any]c                T    | j         i | _         | j                             di           S zRetrieve the metadata (if any).NrF   )r   
setdefaultr<   s    r+   rF   zRunBase.metadatau  s+     :DJz$$Z444r*   c                6    | j                             d          S )z"Retrieve the revision ID (if any).revision_id)rF   getr<   s    r+   r   zRunBase.revision_id|  s     }  ///r*   Optional[float]c                V    | j         dS | j         | j        z
                                  S )zLatency in seconds.N)r   r   total_secondsr<   s    r+   latencyzRunBase.latency  s,     = 4/>>@@@r*   c                F    | j          d| j         d| j         d| j         dS )r   r   z, name='z', run_type='r   )rh   rO   r   r   r<   s    r+   r   zRunBase.__repr__  s1    .``dg``ty``t}````r*   T)rH   r1   r   )r1   rN   )r1   r   )r$   r%   r&   r'   r(   r   r   r   r   r   r   r   r   rD   rE   r   r   r   r\   r   rF   r   r   r   r   rI   r)   r*   r+   r   r   8  s          HHH(III* MMM" $(H''''-!E.AAAEAAAA=E;!%J%%%%F#'F'''' 5...F....""G""""/+/////@$(M((((@ $D$$$$6AFB B BK    
 5 5 5 X5 0 0 0 X0 A A A XAa a a :d;;;LLLr*   r   c                      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"#          Zd$ed%<   	 dZd&ed'<   	  ed#          Zded(<   d;d< fd-Zed=d.            Zed>d0            Z ed>d1            Z!ed?d3            Z"ed?d4            Z#ed@d6            Z$ed@d7            Z%edAd9            Z&edAd:            Z' xZ(S )BRunz$Run schema when loading from the DB.NrN   
session_idOptional[list[UUID]]child_run_idszOptional[list[Run]]
child_runsrC   feedback_statsrr   app_pathmanifest_idstatusr   prompt_tokenscompletion_tokenstotal_tokenszOptional[dict[str, int]]prompt_token_detailscompletion_token_detailsrx   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 rA   r   dotted_orderOptional[bool]
in_datasetrz   r|   r   r1   r}   c                X   |                     d          sd|                     d          i|}|                    dd          pi } t                      j        di |d|i || _        | j        j        *| j                            t          j	                  | _        | j
        6| j
        j        *| j
                            t          j	                  | _
        | j                                        s0| j        s+| j                                         | j         | _        dS dS dS )Initialize a Run object.r   rO   rD   Ntzinfor)   )r   r   re   rf   rz   r   r   replacer   rT   r   r   stripr   	isoformatrO   )r4   rz   r|   rD   rh   s       r+   rf   zRun.__init__  s2   zz*%% 	> &**T"2"2=f=FHd++1r11611&1111"?!)"o55X\5JJDO=$)=)E M111FFDM &&(( 	J1C 	J#'?#<#<#>#> I I ID	J 	J 	J 	Jr*   c                B    | j         r| j        r| j          | j         S dS )r   N)rz   r   r<   s    r+   r   zRun.url  s1     > 	6dm 	6n5dm555tr*   
int | Nonec                    | j         S )zAlias for prompt_tokens.)r   r<   s    r+   input_tokenszRun.input_tokens  s     !!r*   c                    | j         S )zAlias for completion_tokens.)r   r<   s    r+   output_tokenszRun.output_tokens  s     %%r*   Decimal | Nonec                    | j         S )zAlias for prompt_cost.)r   r<   s    r+   
input_costzRun.input_cost  s     r*   c                    | j         S )zAlias for completion_cost.)r   r<   s    r+   output_costzRun.output_cost  s     ##r*   dict[str, int] | Nonec                    | j         S )zAlias for prompt_token_details.)r   r<   s    r+   input_token_detailszRun.input_token_details   s     ((r*   c                    | j         S )zAlias for output_token_details.)r   r<   s    r+   output_token_detailszRun.output_token_details  s     ,,r*   dict[str, Decimal] | Nonec                    | j         S )zAlias for prompt_cost_details.)r   r<   s    r+   input_cost_detailszRun.input_cost_details
  s     ''r*   c                    | j         S )z"Alias for completion_cost_details.)r   r<   s    r+   output_cost_detailszRun.output_cost_details  s     ++r*   rQ   rz   rr   r|   r   r1   r}   r   )r1   r  )r1   r  )r1   r  )r1   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   rz   rf   r   r   r  r  r  r
  r  r  r  r  rj   rk   s   @r+   r   r     sj        ..!%J%%%%-*.M....4&*J****M/3N3333&"H""""7"&K&&&&: F    .#'M''''/'+++++/"&L&&&&1599999 :>==== ,0////-$(J((((M%)K))))G)-O----C8<<<<< =A@@@@ ,0N////!NNNCb)))L))))
 "&J%%%%+*{4888I8888J J J J J J J    X " " " X" & & & X&       X  $ $ $ X$ ) ) ) X) - - - X- ( ( ( X( , , , X, , , , ,r*   r   c                  .    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    s7        ??DE
CIIFFFFr*   r  c                     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   rD   rE   rx   r   r   rr   r   r   rN   r   r   r   r   r_   r   inputs_s3_urlsoutputs_s3_urlsrO   r   session_namer   input_attachmentsoutput_attachmentsr   r   r   Attachmentsr\   Nr#   r)   r*   r+   r  r  !  s2        00III    !!!!    """"####((((%%%%&&&&NNNr*   r  c                  2    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.Nrx   last_reviewed_timeadded_at)r$   r%   r&   r'   r(  r(   r)  r)   r*   r+   r'  r'  >  s>         00-11111.#'H''''33r*   r'  c                  b    e Zd ZU dZded<   	  ee          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   typerW   rC   rF   NzOptional[Union[UUID, str]]user_idrr   	user_name)
r$   r%   r&   r'   r(   r   r   rF   r-  r.  r)   r*   r+   r+  r+  G  sp           III*).t)D)D)DHDDDD6*.G....:#I####<<r*   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+   r0  r0  X  s)          D      r*   r0  c                  "    e Zd ZU dZdZded<   dS )ModelFeedbackSourcezModel feedback source.modelzLiteral['model']r,  Nr2  r)   r*   r+   r4  r4  ^  s)           $D$$$$$$r*   r4  c                      e Zd ZdZdZ	 dZdS )FeedbackSourceTypezFeedback source type.r1  r5  N)r$   r%   r&   r'   APIMODELr)   r*   r+   r7  r7  d  s#        
C2E""r*   r7  c                     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<   	 dZded<   	  ed          ZdS )FeedbackBasezFeedback schema.r   rO   Nrx   rY   ry   rN   run_idr   r   key
SCORE_TYPEscore
VALUE_TYPEvaluerr   commentzUnion[str, dict, None]
correctionOptional[FeedbackSourceBase]feedback_sourcer   r   comparative_experiment_idfeedback_group_idr   r   Tr   )r$   r%   r&   r'   r(   rY   ry   r?  rA  rB  rC  rE  r   r   rF  rG  r   r   rI   r)   r*   r+   r;  r;  m  sT        HHH(%)J)))),&*K****2<>HHHAE+EQ!G!!!!2)-J----!48O8888%!%J%%%%T%)J))))E044444X(,,,,,1 !E    ':T***LLLr*   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.floatrA  rr   labelNr#   r)   r*   r+   rI  rI    s0         55LLLCNNr*   rI  c                  B    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+   rM  rM    sW         DD::::440000@ @r*   rM  c                  >    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+  rE  NzOptional[FeedbackConfig]feedback_configr   r   )r$   r%   r&   r'   r(   rS  r   r)   r*   r+   rR  rR    sL         ,,''''%04O4444% E      r*   rR  c                  D    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   rO   r   rY   ry   NrD  rE  )r$   r%   r&   r'   r(   rE  r)   r*   r+   rU  rU    sP         &&HHH,248O888822r*   rU  c                      e Zd ZU dZded<   	  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<   	 ded<   	 ded<   	  ed          Zded<   dd  fdZed!d            Zed"d            Zed#d            Z xZS )$TracerSessionzbTracerSession schema for the API.

    Sessions are also referred to as "Projects" in the UI.
    r   rO   c                 >    t          j        t          j                  S rQ   rR   r)   r*   r+   rU   zTracerSession.<lambda>  rV   r*   rW   r   r   Nrx   r   rr   r   r   rC   r   	tenant_idrN   reference_dataset_idrA   rz   r|   r   r1   r}   c                     t                      j        di | || _        | j        j        ,| j                            t          j                  | _        dS dS )r   Nr   r)   )re   rf   rz   r   r   r   r   rT   )r4   rz   r|   rh   s      r+   rf   zTracerSession.__init__  sZ    ""6""""?!)"o55X\5JJDOOO *)r*   c                F    | j         r| j          d| j         d| j         S dS )r   r   /projects/p/N)rz   rY  rO   r<   s    r+   r   zTracerSession.url  s6     > 	OnNNNNTWNNNtr*   r   c                @    | j         	d| j         vri S | j         d         S r   r   r<   s    r+   rF   zTracerSession.metadata  *     :4:!=!=Iz*%%r*   r   c                @    | j         	d| j         vrg S | j         d         S )zRetrieve the tags (if any).Nr   r_  r<   s    r+   r   zTracerSession.tags  s*     :tz!9!9Iz&!!r*   rQ   r  r   r   r1   r   )r$   r%   r&   r'   r(   r   r   r   r   r   r   r   rz   rf   r   r   rF   r   rj   rk   s   @r+   rW  rW    sq         
 HHH  51S1STTTJTTTT+#'H'''')!%K%%%%)D"&*E****)OOO0((((J*{4888I8888K K K K K K K    X & & & X& " " " X" " " " "r*   rW  c                     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S )TracerSessionResultzqA project, hydrated with additional information.

    Sessions are also referred to as "Projects" in the UI.
    Nr   	run_countOptional[timedelta]latency_p50latency_p99r   r   r   rx   last_run_start_timerC   r   session_feedback_statsOptional[list[dict[str, Any]]]
run_facetsr   r   r   r   first_token_p50first_token_p99r   
error_rate)r$   r%   r&   r'   re  r(   rg  rh  r   r   r   ri  r   rj  rl  r   r   r   rm  rn  ro  r)   r*   r+   rd  rd    s^         
  $I####,'+K++++?'+K++++6"&L&&&&=#'M''''D'+++++H.222228/3N3333)7;;;;;115J5555-$(J((((M%)K))))G)-O----C+/O////G+/O////>"&J&&&&))r*   rd  c                  D    e Zd ZU dZded<   	 ded<   	 ed	d            ZdS )
BaseMessageLikez7A protocol representing objects similar to BaseMessage.r   contentzdict[Any, Any]additional_kwargsr1   c                    dS )z,Type of the Message, used for serialization.Nr)   r<   s    r+   r,  zBaseMessageLike.type*  s      r*   Nr1   r   )r$   r%   r&   r'   r(   r   r,  r)   r*   r+   rq  rq  !  sU         AALLL%%%%%C; ; ; X; ; ;r*   rq  c                  6    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   r@   share_tokenr   r   Nr#   r)   r*   r+   rw  rw  /  s?         44 ,HHH((r*   rw  c                  N    e Zd ZU dZded<   	 ded<   	 ded<   	 ded<   	 d	ed
<   dS )AnnotationQueueRubricItemzRepresents a rubric item assigned to an annotation queue.

    Links a feedback config to a queue with optional per-queue customization.
    r   feedback_keyrr   r   zOptional[dict[str, str]]value_descriptionsscore_descriptionsr   is_requiredNr#   r)   r*   r+   rz  rz  :  sf          
 =C000070000(NNr*   rz  c                      e Zd ZU dZded<   	 ded<   	 dZded<   	  ed	 
          Zded<   	  ed 
          Zded<   	 ded<   dS )AnnotationQueuezRepresents an annotation queue.r   rO   r   r   Nrr   r   c                 >    t          j        t          j                  S rQ   rR   r)   r*   r+   rU   zAnnotationQueue.<lambda>U  rV   r*   rW   r   rY   c                 >    t          j        t          j                  S rQ   rR   r)   r*   r+   rU   zAnnotationQueue.<lambda>W  rV   r*   
updated_atrY  )	r$   r%   r&   r'   r(   r   r   rY   r  r)   r*   r+   r  r  L  s         ))HHH8III+!%K%%%%: 51S1STTTJTTTT> 51S1STTTJTTTTCOOODDr*   r  c                  "    e Zd ZU dZdZded<   dS )AnnotationQueueWithDetailsz,Represents an annotation queue with details.Nrr   rubric_instructions)r$   r%   r&   r'   r  r(   r)   r*   r+   r  r  ]  s*         66)-----;;r*   r  c                  Z    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.r]   use_multipart_endpointr0   scale_up_qsize_triggerscale_up_nthreads_limitscale_down_nempty_trigger
size_limitr   size_limit_bytesNr#   r)   r*   r+   r  r  d  sl         ,,    D<    7""""AOOO/####88r*   r  c                  R    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   versionNrx   license_expiration_timezOptional[BatchIngestConfig]batch_ingest_configrC   instance_flags)	r$   r%   r&   r'   r  r(   r  r  r  r)   r*   r+   r  r  u  sg         11G.266666+7;;;;;/3N333333r*   r  c                  F    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   rO   display_namer   rY   Nrr   tenant_handle)r$   r%   r&   r'   r(   r  r)   r*   r+   r  r    sS         ,,GGG)*#'M''''''r*   r  c                  6    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   rO   r   r   r   
expires_atNr#   r)   r*   r+   r  r    s<         <<HHH.HHH3++r*   r  c                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )	RunEventzRun event schema.r   r   zUnion[datetime, str]timerC   r|   Nr#   r)   r*   r+   r  r    s?         III$$$$,,r*   r  c                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )TimeDeltaInputzTimedelta input schema.r0   dayshoursminutesNr#   r)   r*   r+   r  r    s9         !!IIIJJJLLLr*   r  c                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )DatasetDiffInfoz;Represents the difference information between two datasets.z
list[UUID]examples_modifiedexamples_addedexamples_removedNr#   r)   r*   r+   r  r    sB         EE!!!!=:    <<r*   r  c                      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            ZdS )ComparativeExperimentzRepresents a comparative experiment.

    This information summarizes evaluation results comparing
    two or more models on a given dataset.
    r   rO   Nrr   r   r   rY  r   rY   ry   rZ  rC   r   r   experiments_infor   r1   r   c                @    | j         	d| j         vri S | j         d         S r   r_  r<   s    r+   rF   zComparativeExperiment.metadata  r`  r*   r   )r$   r%   r&   r'   r(   r   r   r   r  r   r   rF   r)   r*   r+   r  r    s           HHH?D:!%K%%%%@OOOGDJJ&*E****?-11111\/3N3333P& & & X& & &r*   r  c                  N    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  r    sZ         ..JJJ0III!(%r*   r  c                      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          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   rO   r   r  r  NrN   r   repo_id	parent_idrr   r  rx   rY   r  rW   r   example_run_idsr   r   num_downloads	num_viewsparent_commit_hash)r$   r%   r&   r'   r(   r   r  r  r  rY   r  r   r   r  r  r  r  r)   r*   r+   r  r    s        EEHHH6JJJ)III3"&K&&&&O"G""""5 $I$$$$8!%K%%%%*%)J))))=%)J))))B,1E$,G,G,GOGGGGH#$M$$$$> I    :(,,,,,11r*   r  c                  :   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_handleNrr   r   readmerO   rY  r   rY   r  r]   	is_publicis_archivedr   r   original_repo_idupstream_repo_idr  	full_namer0   	num_likesr  r  r   liked_by_auth_userlast_commit_hashnum_commitsoriginal_repo_full_nameupstream_repo_full_name)r$   r%   r&   r'   r(   r   r  r  r  r  r  r  r  r)   r*   r+   r  r    sx        ,,!!%K%%%%( F    #GGGNNN,*-OOO')OOO.&*****3&*****30NNN<NNN"NNN)-----@&*****& -11111:-11111::r*   r  c                  *    e Zd ZU dZded<   	 ded<   dS )ListPromptsResponsez A list of prompts with metadata.zlist[Prompt]reposr0   r   Nr#   r)   r*   r+   r  r  K  s0         **JJJ&&r*   r  c                  (    e Zd ZdZdZ	 dZ	 dZ	 dZdS )PromptSortFieldz$Enum for sorting fields for prompts.r  r  r  r  N)r$   r%   r&   r'   r  r  r  r  r)   r*   r+   r  r  T  s3        ..#MIJIr*   r  c                  Z    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 )
InputTokenDetailsz~Breakdown of input token counts.

    Does *not* need to sum to full input token count. Does *not* need to have all keys.
    r0   audiocache_creation
cache_readcache_read_over_200kephemeral_5m_input_tokensephemeral_1h_input_tokensNr#   r)   r*   r+   r  r  a  sy          
 JJJ OOO """"S""""QQr*   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.
    r0   r  	reasoningNr#   r)   r*   r+   r  r  |  s7          
 JJJNNN r*   r  c                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )InputCostDetailszvBreakdown of input token costs.

    Does *not* need to sum to full input cost. Does *not* need to have all keys.
    rJ  r  r  r  Nr#   r)   r*   r+   r  r    sM          
 LLL%  r*   r  c                  *    e Zd ZU dZded<   	 ded<   dS )OutputCostDetailszxBreakdown of output token costs.

    Does *not* need to sum to full output cost. Does *not* need to have all keys.
    rJ  r  r  Nr#   r)   r*   r+   r  r    s:          
 LLL& r*   r  c                      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.
    r0   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          
 JPA7777 :999 #"""'####(""""'5555/777700r*   r  c                      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 )ExtractedUsageMetadatazUsage metadata dictionary extracted from a run.

    Should be the same as UsageMetadata, but does not require all
    keys to be present.
    r0   r  r  r   r  r  r  r  rJ  r  r
  r   r  r  r  r  Nr#   r)   r*   r+   r  r    s           33******,,,,+'('((((/****00r*   r  c                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )	UpsertExamplesResponsezCResponse object returned from the upsert_examples_multipart method.r0   countr   example_idszNotRequired[str | None]r   Nr#   r)   r*   r+   r  r    s?         MMJJJ45""""ccr*   r  c                  6    e Zd ZU dZ ee          Zded<   dS )ExampleWithRunszExample with runs.rW   z	list[Run]runsN)r$   r%   r&   r'   r   r   r  r(   r)   r*   r+   r  r    s6         eD111D1111""r*   r  c                      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   re  rf  rg  rh  r   r   r   rx   ri  rk  rl  r   r   r   r   rm  rn  r   ro  Nr#   r)   r*   r+   r  r    s         ++,$$$$?$$$$6=    D$$$$H++++8....-!!!!M""""G&&&&C((((G((((>))r*   r  c                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )	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  $  sH           1!!!!6111111r*   r  c                  ~    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            ZddZdS )InsightsReportzHAn Insights Report created by the Insights Agent over a tracing project.
UUID | strrO   r   r   r   N
str | Noner   
project_idhost_urlrY  r1   c           	         | j          dt          | j                   dt          | j                   dt          | j                   S )z1URL to view this Insights Report in LangSmith UI.r   r]  z?tab=4&clusterJobId=)r  r   rY  r  rO   r<   s    r+   linkzInsightsReport.link=  sK     -}}C$7$7}}SEYEY}}orswszo{o{}}}r*   c                (    d| j          d| j         dS )Nz	<a href="z2", target="_blank" rel="noopener">InsightsReport('z')</a>)r  r   r<   s    r+   _repr_html_zInsightsReport._repr_html_B  s!    k49kkY]Ybkkkkr*   ru  )	r$   r%   r&   r'   r(   r   r   r  r  r)   r*   r+   r  r  2  s         RRNNNIIIKKKEMMM~ ~ ~ X~l l l l l lr*   r  c                  \    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Zded<   dS )InsightsHighlightedTracez2A trace highlighted in an insights report summary.r  r<  NUUID | str | None
cluster_idr  cluster_namer0   rankr   highlight_reasonsummary)r$   r%   r&   r'   r(   r  r  r  r)   r*   r+   r  r  F  sl         <<$(J((((#L####IIIGr*   r  c                  t    e Zd ZU dZ ee          Zded<   dZded<    ee          Z	ded	<   dZ
d
ed<   dS )InsightsSummaryReportzIHigh-level summary of an insights job: key points and highlighted traces.rW   r   
key_pointsNr  titlezlist[InsightsHighlightedTrace]highlighted_traceszdatetime | NonerY   )r$   r%   r&   r'   r   r   r  r(   r  r  rY   r)   r*   r+   r  r  Q  sw         SS!E$777J7777E9>t9T9T9TTTTT"&J&&&&&&r*   r  c                  p    e Zd ZU 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ed<   dZded<   dS )InsightsClusterz/A single cluster of runs in an insights report.r  rO   Nr  r  r0   levelr   r   r   r  parent_namenum_runsdict[str, Any] | Nonestats)r$   r%   r&   r'   r(   r  r
  r  r)   r*   r+   r  r  Z  s{         99NNN#'I''''JJJIII"K""""MMM#'E''''''r*   r  )r  clientr   r   
str | UUIDjob_idr  str | UUID | Noner1   list[dict[str, Any]]c                  ddl m} g }d}d}|||d}|t          |          |d<   |                     dd| d	| d
|          }	|                    |	           |	                                }
|
                    dg           pg }|                    |           |
                    d          }|d}nt          |          }|sd}||S )zHFetch runs for an Insights job, optionally filtered to a single cluster.r   )utilsd   N)limitr7   r  GETz
/sessions/z
/insights/z/runs)paramsr  r7   )		langsmithr  r   request_with_retriesraise_for_status_with_textjsonr   extendr0   )r  r   r  r  ls_utilsall_runsr  next_offsetr  respbodybatchreturned_offsets                r+   _fetch_insights_runsr%  g  s    ,+++++%'HEK

!+0K!H!H!#&z??F< **<<<v<<< + 
 

 	++D111yy{{$$*((8,,"KKo..K #") 
!* Or*   c                  >    e Zd ZdZdZdd	ZddZddZddZddZ	dS )_ClusterWithTraceszYCluster wrapper that can load its traces from the API. Returned by report.clusters[name]._cluster_reportclusterr  reportInsightsReportResultr1   r}   c                "    || _         || _        d S rQ   r(  )r4   r+  r,  s      r+   rf   z_ClusterWithTraces.__init__  s    r*   r   r   r   c                ,    t          | j        |          S rQ   )getattrr)  )r4   r   s     r+   __getattr__z_ClusterWithTraces.__getattr__  s    t}d+++r*   r   c                    t          t          t          | j                            t          t          | j                            z            S rQ   )r   setdirrh   r)  r<   s    r+   __dir__z_ClusterWithTraces.__dir__  s9    CDN++,,s3t}3E3E/F/FFGGGr*   c                "    d| j         j        dS )Nz_ClusterWithTraces(name=))r)  r   r<   s    r+   r   z_ClusterWithTraces.__repr__  s    A$-*<AAAAr*   r  c                   t          | j        dd          }|t          d          t          | j        dd          }t          | j        dd          }||t          d          t          |||| j        j                  S )z.Fetch run dicts for this cluster from the API._clientNzMReport not attached to a client; get reports via Client.get_insights_report()_session_id_job_idzReport missing session/job ids)r  r   r  r  )r0  r*  
ValueErrorr%  r)  rO   r4   r  r   r  s       r+   load_tracesz_ClusterWithTraces.load_traces  s    y$77>_   T\=$??
y$77=>>>#!}'	
 
 
 	
r*   N)r+  r  r,  r-  r1   r}   )r   r   r1   r   rb  ru  )r1   r  )
r$   r%   r&   r'   	__slots__rf   r1  r5  r   r>  r)   r*   r+   r'  r'    s        cc'I   , , , ,H H H HB B B B
 
 
 
 
 
r*   r'  c                  <    e Zd ZdZdZdd	ZddZd ZddZddZ	dS )_ClustersMapzWList-like map of clusters by name. Supports report.clusters['name'] and .load_traces().)	_clustersr*  clusterslist[InsightsCluster]r,  r-  r1   r}   c                <    t          |          | _        || _        d S rQ   )r   rB  r*  )r4   rC  r,  s      r+   rf   z_ClustersMap.__init__  s    
 hr*   r=  	str | intr'  c           	        t          |t                    r| j        |         }nQd | j        D             }||vr4t          d|dt	          |                                                     ||         }t          || j                  S )Nc                    i | ]
}|j         |S r)   )r   ).0cs     r+   
<dictcomp>z,_ClustersMap.__getitem__.<locals>.<dictcomp>  s    999Qqvq999r*   zCluster z not found; available: )
isinstancer0   rB  KeyErrorr   keysr'  r*  )r4   r=  r+  by_names       r+   __getitem__z_ClustersMap.__getitem__  s    c3 	#nS)GG99$.999G'!!SsSST',,..=Q=QSS   clG!'4<888r*   c                *      fd j         D             S )Nc              3  B   K   | ]}t          |j                  V  d S rQ   )r'  r*  )rI  rJ  r4   s     r+   	<genexpr>z(_ClustersMap.__iter__.<locals>.<genexpr>  s0      LL"1dl33LLLLLLr*   )rB  r<   s   `r+   __iter__z_ClustersMap.__iter__  s    LLLLT^LLLLr*   r0   c                *    t          | j                  S rQ   lenrB  r<   s    r+   __len__z_ClustersMap.__len__  s    4>"""r*   r   c                2    dt          | j                   dS )Nz_ClustersMap(n_clusters=r7  rV  r<   s    r+   r   z_ClustersMap.__repr__  s    @#dn*=*=@@@@r*   N)rC  rD  r,  r-  r1   r}   )r=  rF  r1   r'  )r1   r0   ru  )
r$   r%   r&   r'   r?  rf   rP  rT  rX  r   r)   r*   r+   rA  rA    s        aa(I   
9 
9 
9 
9M M M# # # #A A A A A Ar*   rA  c                  ~   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<   dZded<    ee          Zded<   dZded<    ee          Zded<   	  ed          Zded<    ed          Zded<    ed          Zded<    ed !          Zd,d(Zd-d*Zd-d+ZdS ).r-  zVFull result of fetching an Insights report (job + clusters + summary + optional runs).r  rO   r   r   r   Nzdatetime | str | Noner   r   rY   r  rF   r  shaper  r   r  	config_idrW   rD  rC  zInsightsSummaryReport | Noner,  r  r  rA   r   r9  r:  r;  allowr_  r  r   r  r  r1   r}   c                @   t                               | d|           t                               | dt          |                     t                               | dt          |                     t                               | dt          | j        |                      dS )zXAttach client and ids so clusters can load traces. Called by Client.get_insights_report.r9  r:  r;  rC  N)object__setattr__r   rA  rC  r=  s       r+   _attach_clientz#InsightsReportResult._attach_client  s     	4F3334J@@@4CKK888--	
 	
 	
 	
 	
r*   r   c                ^   | j         }t          |d          r!t                              | d|j                   	 |                     d          t          |d          rt                              | d|           S S # t          |d          rt                              | d|           w w xY w)z?Return the report as a JSON-serializable dict (raw JSON shape).rB  rC  r  mode)rC  hasattrr_  r`  rB  
model_dump)r4   clusters_vals     r+   to_jsonzInsightsReportResult.to_json  s    }<-- 	ItZ1GHHH	C???//|[11 C""4\BBBBCw|[11 C""4\BBBBCs   A= =/B,c                .    |                      d          S )zHReturn the report as a JSON-serializable dict (e.g. for saving to file).r  rc  )rf  r<   s    r+   model_dump_json_dictz)InsightsReportResult.model_dump_json_dict  s    F+++r*   )r  r   r   r  r  r  r1   r}   r   )r$   r%   r&   r'   r(   r   r   rY   rF   r[  r   r\  r   r   rC  r,  r  r   r9  r:  r;  r   rI   ra  rh  rj  r)   r*   r+   r-  r-    s        ``NNNIIIKKK(,J,,,,&*H****(,J,,,,&*H****#'E''''E#'I''''&+eD&A&A&AHAAAA+/F////!&t!<!<!<D<<<<8;t,,,G,,,,"{4000K0000;t,,,G,,,,:G,,,L
 
 
 
 	C 	C 	C 	C, , , , , ,r*   r-  c                  2    e Zd ZU dZded<   ded<   ded<   dS )	FeedbackFormulaWeightedVariablezBA feedback key and weight used when calculating feedback formulas.zLiteral['weighted_key']	part_typerJ  weightz#Annotated[str, Field(min_length=1)]r=  Nr#   r)   r*   r+   rl  rl    s9         LL&&&&MMM,,,,,,r*   rl  c                  j    e Zd ZU dZdZded<   dZded<   ded<   ded	<    ed
dd          Zded<   dS )FeedbackFormulaCreatez,Schema used for creating a feedback formula.NrN   r@   r   r   r{  Literal['sum', 'avg']aggregation_type.   2   
min_length
max_length%list[FeedbackFormulaWeightedVariable]formula_parts)	r$   r%   r&   r'   r@   r(   r   r   ry  r)   r*   r+   rp  rp    s         66!%J%%%%!%J%%%%++++;@5b< < <M      r*   rp  c                  N    e Zd ZU dZded<   ded<    eddd	          Zd
ed<   dS )FeedbackFormulaUpdatez,Schema used for updating a feedback formula.r   r{  rq  rr  .rs  rt  ru  rx  ry  N)r$   r%   r&   r'   r(   r   ry  r)   r*   r+   r{  r{  !  se         66++++;@5b< < <M      r*   r{  c                  2    e Zd ZU dZded<   ded<   ded<   dS )FeedbackFormulaz%Schema for getting feedback formulas.r   rO   r   rY   ry   Nr#   r)   r*   r+   r}  r}  +  s9         //HHHr*   r}  c                  R    e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
Zded<   d
S )FeedbackConfigSchemaa  Represents a feedback configuration for a tenant's feedback key.

    Feedback configurations define how feedback with a given key should be
    interpreted, including its type (continuous, categorical, or freeform),
    scoring bounds, and valid categories.
    r   r{  rM  rS  r   rY  r   ry   Nr   is_lower_score_better)r$   r%   r&   r'   r(   r  r)   r*   r+   r  r  3  si           A####HOOOE=,00000KKr*   r  )
r  r   r   r  r  r  r  r  r1   r  )zr'   
__future__r   collections.abcr   r   r   r   decimalr   enumr	   pathlibr
   typingr   r   r   r   r   r   r   uuidr   pydanticr   r   r   r   r   r   r   typing_extensionsr   r   r   r>  r   r   r@  r   tupler2   r%  r-   r?   rK   _AttachmentLikerM   ExampleUploadWithAttachmentsrm   ro   rt   r   r   r   ExampleUpdateWithAttachmentsr   r   DatasetTransformationTyper   r   r   r   r   r   r  r  r'  r+  r0  r4  r7  r;  rI  rM  rR  rU  rW  rd  rq  rw  rz  r  r  r  r  model_rebuildr  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'  rA  r-  rl  rp  r{  r}  r  r)   r*   r+   <module>r     s4   $ $ " " " " " " $ $ $ $ $ $ 2 2 2 2 2 2 2 2 2 2                                                           > = = = = = = = = =:y+t;<
4j)[$FG
       * 3eCJ/U39=MMNNO     8    I I I I I) I I I    i   
 sEz!2E#t)4DD
! ! ! ! !I ! ! !&  -     =       Y   'b 'b 'b 'b 'bk 'b 'b 'bT    K       I   ! ! ! ! !I ! ! !&  -     sD   + + + + +) + + + $ ? ? ? ? ?IU ? ? ? ?- - - - -k - - -`    Y     T< T< T< T< T<i T< T< T<nC, C, C, C, C,' C, C, C,L	 	 	 	 	#t 	 	 	    )5    :4 4 4 4 4 4 4 4= = = = = = = ="! ! ! ! !* ! ! !% % % % %, % % %# # # # # # # #&+ &+ &+ &+ &+9 &+ &+ &+RO O O O Oy O O O O@ @ @ @ @Ye @ @ @ @! ! ! ! !\ ! ! !	3 	3 	3 	3 	3| 	3 	3 	33" 3" 3" 3" 3"I 3" 3" 3"l%* %* %* %* %*- %* %* %*P 
; 
; 
; 
; 
;h 
; 
; 
;) ) ) ) )% ) ) ) )O O O O O	 O O O O$E E E E Ei E E E"< < < < < < < <9 9 9 9 9	 9 9 9 9"	4 	4 	4 	4 	4I 	4 	4 	4      	( 	( 	( 	( 	(	 	( 	( 	(, , , , ,) , , ,- - - - -y - - - -    Ye    = = = = =i = = =!& !& !& !& !&I !& !& !&H         9      (2 (2 (2 (2 (2 (2 (2 (2V.; .; .; .; .;Y .; .; .;b' ' ' ' ') ' ' '
 
 
 
 
c4 
 
 
R R R R R	 R R R R6    %         y    *    	     1 1 1 1 1I 1 1 1D1 1 1 1 1Ye 1 1 1 1:d d d d dY d d d# # # # #g # # #* * * * * * * *B2 2 2 2 2	 2 2 2l l l l lY l l l(    y   ' ' ' ' 'I ' ' '
( 
( 
( 
( 
(i 
( 
( 
($ %)" " " " " "J#
 #
 #
 #
 #
 #
 #
 #
L A  A  A  A  A  A  A  AF5, 5, 5, 5, 5,9 5, 5, 5,p- - - - -i - - -	 	 	 	 	I 	 	 	    I       +   L L L L L9 L L L L Lr*   