
    is                       d dl mZ d dlZd dlmc mZ d dlm	Z
 d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZmZ d dlmZmZmZmZmZ d dlmZ  d dlm!Z" d dl#m$Z$m%Z% d d	l&m'Z'm(Z(m)Z)m*Z* d d
l+m,Z,m-Z-m.Z. erd dl/m0Z0 d dl1m2Z2  ejf                  d      Z4 e
jj                   e             Z6	 	 	 	 ddZ7ejp                   G d d             Z9	 d	 	 	 	 	 	 	 	 	 d dZ:	 d!	 	 	 	 	 	 	 d"dZ;	 	 	 	 	 	 d#dZ<	 	 d$	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZ=	 	 d$	 	 	 	 	 	 	 	 	 	 	 d&dZ>	 d'	 	 	 	 	 	 	 	 	 	 	 d(dZ?d)dZ@	 	 	 	 d*dZAd+dZBd,dZC	 d-	 	 	 	 	 d.dZD	 	 	 	 	 	 d/dZEy)0    )annotationsN)	cpu_count)EmptyQueue)TYPE_CHECKINGAnyOptionalUnioncast)schemas)utils)ZSTD_AVAILABLECompressedTraces)_AUTO_SCALE_DOWN_NEMPTY_TRIGGER_AUTO_SCALE_UP_NTHREADS_LIMIT_AUTO_SCALE_UP_QSIZE_TRIGGER	_BOUNDARY)SerializedFeedbackOperationSerializedRunOperation#combine_serialized_queue_operations)Context)Clientzlangsmith.clientmax_workersc                    ddl m}  |t              }| D ]Z  }|j                  |j                  |j
                  |j                  |j                  |j                  f}||   j                  |       \ |S )z3Group batch items by endpoint and auth combination.r   )defaultdict)
collectionsr   listapi_urlapi_keyservice_key	tenant_idauthorizationcookieappend)batchr   groupeditemkeys        n/home/jang/Projects/ai-researcher/.venv/lib/python3.12/site-packages/langsmith/_internal/_background_thread.py_group_batch_by_api_endpointr+   )   sp     ($G 	"LLLLNNKK
 	D!	" N    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Z	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZy)TracingQueueItemzAn item in the tracing queue.

    Attributes:
        priority (str): The priority of the item.
        item (Any): The item itself.
        otel_context (Optional[Context]): The OTEL context of the item.
    strpriority:Union[SerializedRunOperation, SerializedFeedbackOperation]r(   Optional[str]r   r    r!   r"   r#   r$   Optional[Context]otel_context	r0   r(   r    r   r!   r"   r#   r$   r4   Nc
                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        y Nr5   )
selfr0   r(   r    r   r!   r"   r#   r$   r4   s
             r*   __init__zTracingQueueItem.__init__g   sF     !	&"*(r,   c                    | j                   | j                  j                  f|j                   |j                  j                  fk  S r7   )r0   r(   	__class__r8   others     r*   __lt__zTracingQueueItem.__lt__}   s;    tyy223NNJJ  7
 
 	
r,   c                    t        |t              xrE | j                  | j                  j                  f|j                  |j                  j                  fk(  S r7   )
isinstancer.   r0   r(   r;   r<   s     r*   __eq__zTracingQueueItem.__eq__   sM    %!12 4MMII8
 nnejj22384 	4r,   )NNNNNNN)r0   r/   r(   r1   r    r2   r   r2   r!   r2   r"   r2   r#   r2   r$   r2   r4   r3   returnNone)r=   r.   rB   bool)r=   objectrB   rD   )	__name__
__module____qualname____doc____annotations__	__slots__r9   r>   rA    r,   r*   r.   r.   G   s     M
DD  ##
I  "&!%%)#''+ $*.)) I) 	)
 ) #) !) %) ) () 
),
4r,   r.   c                   g }d}	 | j                  |d      x}r:|j                  |       |dkD  r$||j                  j                         z  }||kD  r|S 	 	 | j                  |d      }|j                  |       |dkD  r%||j                  j                         z  }||kD  r	 |S |rt        |      |k\  r	 |S c# t        $ r Y |S w xY w# t        $ r Y |S w xY w)Nr   g      ?)blocktimeout皙?)getr%   r(   calculate_serialized_sizer   len)tracing_queuelimitrN   max_size_bytes
next_batchcurrent_sizer(   s          r*   _tracing_thread_drain_queuerY      s%    *,JL$ !$$5$$??4?d#!		 C C EE.0%% $((ud(C
 d# !		 C C EE  .0 	 ZE1 -   $ '"  sH   AC	 C	 B9 *8C	 %C	 8C	 9	CC	 CC	 		CCc                   	 | j                   y| j                   j                  5  | j                   j                  }| j                  xs |}||dk  rt	        d|       ||dk  rt	        d|       |||k  r%|| j                   j
                  |k  r
	 d d d        y| j                   j                  j                  dt         dj                                | j                   j                  j                          | j                   j                  j                         }| j                   j                  }t        t        t        |      d| j                   j                          ||f}| j                   j#                          d d d        j%                  d       |fS # 1 sw Y   xY w# t&        $ r t(        j+                  dd	
       Y yw xY w)N)NNr   z!size_limit must be positive; got z*size_limit_bytes must be nonnegative; got z--z--
contextuLangSmith tracing error: Failed to submit trace data.
This does not affect your application's runtime.
Error details:Texc_info)compressed_traceslockuncompressed_size_max_batch_size_bytes
ValueErrortrace_countcompressor_writerwriter   encodeclosebuffertellsetattrr   r   _contextresetseek	Exceptionloggererror)client
size_limitsize_limit_bytespre_compressed_sizerX   filled_buffercompressed_traces_infos          r*   '_tracing_thread_drain_compressed_bufferrx      s   3##+%%** #	-"(":":"L"L%;;O?O%*/ #DZL!QRR+0@10D @AQ@RS 
 !(,?BR,R"f&>&>&J&JZ&W!##	- #	-( $$66<<YKv&--/ $$66<<>!33::??AL"44;;MS-(((11 ':<%H"$$**,G#	-J 	1566M#	- #	-N  	 	 	 	
 	s;   F1 F1 A4F%F1 "C&F%F1 %F.*F1 1 GGc                   	 |D cg c]  \  }}}|
 }}}|D cg c]  }|j                  d       }}| j                  t        d      t        | j                  |            }t	        |      t	        |      k7  r#t        dt	        |       dt	        |             |D cg c]  }|j                  d       }}||k7  rt        d| d|       t        ||      D ];  \  \  }	}}
}|	dk(  r | j                  |fi |
 #|	dk(  s) | j                  |fi |
 = | j                  r| j                  j                          yyc c}}w c c}w c c}w # t        $ r t        j                  d	d
       Y yw xY w)z1Process a batch of run operations asynchronously.idNzAprocess_buffered_run_ops should not be None when processing batchzGprocess_buffered_run_ops must return the same number of runs. Expected z, got zKprocess_buffered_run_ops must preserve run IDs in the same order. Expected postpatchzLangSmith buffered run ops processing error: Failed to process batch.
This does not affect your application's runtime.
Error details:Tr]   )rQ   _process_buffered_run_opsRuntimeErrorr   rS   rc   zip_create_run_update_run_data_available_eventsetro   rp   rq   )rr   batch_to_process_run_data	run_dictsrunoriginal_idsprocessed_runsprocessed_ids	operation	write_ctxprocessed_runs               r*   _process_buffered_run_ops_batchr      s   
-
4DE.!XqXE	E1:;#;; ++3S  f>>yIJ ~#i.0	N+6#n2E1FH 
 3AA3AAL((>@  9<n9
 	?4%Y9} F""""=>I>g%"""=>I>	? ''((,,. (E F;  B&  
 	 	 	

s?   E EE EA1E $E<AE 	;E E  E98E9c           
     d   	 t        |      }|j                         D ]  \  \  }}}	}
}}}|s$t        |D cg c]  }|j                   c}      }nA|D ch c]  }|j                  j                   }}|D cg c]  }|j                  |v s| }}|r| j                  ||||	|
||       t        d |D              r4t        j                  d       |D cg c]  }t        |t              s| }}| j                  t        t        t           |      |||	|
||        	 |r||D ]  }	 |j%                           yyyc c}w c c}w c c}w c c}w # t        $ r2}t        j!                  dd       | j#                  |       Y d}~id}~ww xY w# t&        $ r1}dt)        |      v rt        j+                  d	|        n Y d}~d}~ww xY w# |rY|V|D ]P  }	 |j%                          # t&        $ r1}dt)        |      v rt        j+                  d	|        n Y d}~Jd}~ww xY w w w w xY w)
a  Handle a batch of tracing queue items by sending them to LangSmith.

    Args:
        client: The LangSmith client to use for sending data.
        tracing_queue: The queue containing tracing items (used for task_done calls).
        batch: List of tracing queue items to process.
        use_multipart: Whether to use multipart endpoint for sending data.
        mark_task_done: Whether to mark queue tasks as done after processing.
            Set to False when called from parallel execution to avoid double counting.
        ops: Pre-combined serialized operations to use instead of combining from batch.
            If None, operations will be combined from the batch items.
    )r   r    r!   r"   r#   r$   c              3  <   K   | ]  }t        |t                y wr7   )r@   r   ).0ops     r*   	<genexpr>z/_tracing_thread_handle_batch.<locals>.<genexpr>[  s     Wrz"&ABWs   z;Feedback operations are not supported in non-multipart moder\   Tr]   N!task_done() called too many times3Ignoring harmless task_done error during shutdown: )r+   itemsr   r(   rz   _multipart_ingest_opsanyrp   warningr@   r   _batch_ingest_run_opsr   r   r   ro   rq   _invoke_tracing_error_callback	task_donerc   r/   debug)rr   rT   r&   use_multipartmark_task_doneopsgrouped_batchesr   r    r!   r"   r#   r$   group_batchr(   	group_ops	group_idsr   er   s                       r*   _tracing_thread_handle_batchr   &  s   ,G6u= *//1,	  
?+674TYY7	 7BBdTYY\\B	B*-DB)1CRD	D,,## +'"/! -  WYWWNNU
 #,!)".IJ !I !
 ,,45yA## +'"/! - I,	n m7 
!++- 8>[ 8 CD"!  1 	 	 	
 	--a001 " :c!fD QRSQTU 			 m7 
!++-! :c!fD QRSQTU 		 8>s   4E E
	E E2E 8EEAE E12E #G .FE 	F (FG FG 	G'G

G
H/G.-H/.	H(	7'H#	H/#H(	(H/c                   	 |#t        |D cg c]  }|j                   c}      }|D cg c]  }t        |t              s| }}|D ci c]=  }t        |j                  t              r!|j                  j                  |j
                  ? }}|r>| j                  | j                  j                  ||       nt        j                  d       |r||D ]  }
	 |j                           yyyc c}w c c}w c c}w # t        $ r2}	t        j                  dd       | j                  |	       Y d}	~	dd}	~	ww xY w# t        $ r1}	dt        |	      v rt        j                  d|	        n Y d}	~	d}	~	ww xY w# |rY|V|D ]P  }
	 |j                          # t        $ r1}	dt        |	      v rt        j                  d|	        n Y d}	~	Jd}	~	ww xY w w w w xY w)ad  Handle a batch of tracing queue items by exporting them to OTEL.

    Args:
        client: The LangSmith client containing the OTEL exporter.
        tracing_queue: The queue containing tracing items (used for task_done calls).
        batch: List of tracing queue items to process.
        mark_task_done: Whether to mark queue tasks as done after processing.
            Set to False when called from parallel execution to avoid double counting.
        ops: Pre-combined serialized operations to use instead of combining from batch.
            If None, operations will be combined from the batch items.
    NzLangSmith tracing error: Failed to submit OTEL trace data.
This does not affect your application's runtime.
Error details: client.otel_exporter is NonezpOTEL tracing error: Failed to submit trace data.
This does not affect your application's runtime.
Error details:Tr]   r   r   )r   r(   r@   r   rz   r4   otel_exporterexport_batchrp   rq   ro   r   r   rc   r/   r   )rr   rT   r&   r   r   r(   r   run_opsotel_context_mapr   r   s              r*   !_otel_tracing_thread_handle_batchr     s   ();5U6STtyy6STC #N"z"6L'M2NN 
$))%;< IILL$+++
 

 ##/$$11';KLB m7 
!++- 8>7 7TN
  1 	 	 	
 	--a001 " :c!fD QRSQTU 			 m7 
!++-! :c!fD QRSQTU 		 8>s   C= C.C= C3C3C= AC8AC= D;.C= =	D8(D3.E8 3D88E8 ;	E5'E00E58
GFG	G	'G		G	G	Gc           
        t        |D cg c]  }|j                   c}      }t        j                  |      }t        j                  |      }	 t	        j
                  d      5 }	|	j                  t        | |||d|      }
|	j                  t        | ||d|      }|
j                          |j                          ddd       |r||D ]  }	 |j                           yyyc c}w # 1 sw Y   -xY w# t        $ rM}dt        |      v r5t        j                  d       t        | |||d|       t        | ||d|       n Y d}~d}~ww xY w# t        $ r1}dt        |      v rt        j                  d|        n Y d}~d}~ww xY w)	a  Handle a batch of tracing queue items by sending to both both LangSmith and OTEL.

    Args:
        client: The LangSmith client to use for sending data.
        tracing_queue: The queue containing tracing items (used for task_done calls).
        batch: List of tracing queue items to process.
        use_multipart: Whether to use multipart endpoint for LangSmith.
        mark_task_done: Whether to mark queue tasks as done after processing.
            Set to False primarily for testing when items weren't actually queued.
       r   FNz6cannot schedule new futures after interpreter shutdownz@Interpreter shutting down, falling back to sequential processingr   r   )r   r(   copydeepcopycfThreadPoolExecutorsubmitr   r   resultr~   r/   rp   r   r   rc   )rr   rT   r&   r   r   r(   r   langsmith_opsotel_opsexecutorfuture_langsmithfuture_otelr   r   s                 r*   #_hybrid_tracing_thread_handle_batchr     s   $ .U.KTtyy.K
LC MM#&M}}S!H'""q1 	!X',  #//1K ##% -	!P -3 	A
'')	 4~a /L	! 	!.  Cs1vM LLR )umUM .ueX 	*  6#a&@ LLMaSQ 		sO   C"C3 %AC';C3 E'C0,C3 3	E	<AEE		F'FFc                     t        j                  d      } | 	 t        |       S y # t        $ r t        j                  d|  d       Y y w xY w)NBATCH_INGEST_SIZE_LIMITz+Invalid value for BATCH_INGEST_SIZE_LIMIT: z, continuing with default)ls_utilsget_env_varintrc   rp   r   )size_limit_strs    r*   get_size_limit_from_envr     sg    ))!N !	~&&   	NN=n=M N* * 	s   
% "A
	A
c                    t        j                  dd dt        t        t              }| s|S 	 | j
                  s|S t               }||| j
                  d<   | j
                  S # t        $ r |cY S w xY w)NTd   )use_multipart_endpointrt   rs   scale_up_nthreads_limitscale_up_qsize_triggerscale_down_nempty_triggerrs   )
ls_schemasBatchIngestConfigr   r   r   batch_ingest_configr   BaseException)infodefault_configenv_size_limits      r*   _ensure_ingest_configr   &  s      11# =;"AN ''!!02%5CD$$\2''' s   A" &A" "A0/A0c                 n    t        j                  d      } t        j                  d      }| sy| }|}||fS )an  Get the current tracing mode configuration.

    Returns:
        tuple[bool, bool]:
            - hybrid_otel_and_langsmith: True if both OTEL and LangSmith tracing
              are enabled, which is default behavior if OTEL_ENABLED is set to
              true and OTEL_ONLY is not set to true
            - is_otel_only: True if only OTEL tracing is enabled
    OTEL_ENABLED	OTEL_ONLY)FF)r   is_env_var_truish)otel_enabled	otel_onlyhybrid_otel_and_langsmithis_otel_onlys       r*   get_tracing_moder   >  sD     --n=L**;7I $-L$l22r,   c                P    |        y j                   }d }||u}|st        j                  d|fd||f      dt        j                         v st        j
                  |      rt        j                  |      ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}}t        j                        }|d   }|d   }|d	   }	j                   xr |j                  d
d      }
g dt        st        j                  d       t!        j"                  d      xs j$                  d uxs t         }|s|
rΉj                  j&                  xs i j                  dd      st        j)                  d       nt+        j,                         _        t1               _        t5        j6                         _        t5        j:                  t<        t+        j>                        fj@                        jC                          dz  dfd} |       rD ]$  }|jE                         rjG                  |       & tI              |k  ro|jK                         |	kD  r\t5        j:                  tL        t+        j>                        |
fj@                        }jO                  |       |jC                          tQ               \  }}jR                  xs |j                  d      xs d}tU        |||      x}r/|rtW        |||
       n|rtY        ||       nt[        |||
        |       rtQ               \  }}jR                  xs |j                  d      xs d}tU        ||d|      x}r|r$t        j                  d       tW        |||
       nH|r#t        j                  d       tY        ||       n#t        j                  d       t[        |||
       tU        ||d|      x}rt        j                  d       y )Nis notz%(py0)s is not %(py3)srT   py0py3assert %(py5)spy5rs   r   r   r   T   zUzstandard package is not installed. Falling back to uncompressed multipart ingestion.DISABLE_RUN_COMPRESSIONzstd_compression_enabledFz~Run compression is not enabled. Please update to the latest version of LangSmith. Falling back to regular multipart ingestion.)targetargsdaemon   c                 p   rt        d      r"j                  rt        j                  d       yt	        j
                         j                         st        j                  d       yt        t        d      r=t        j                        t              z   kD  } | st        j                  d       | S y)N_manual_cleanupz3Client is being cleaned up, stopping tracing threadFz,Main thread is dead, stopping tracing threadgetrefcountzeClient refs count indicates we're the only remaining reference to the client, stopping tracing threadT)
hasattrr   rp   r   	threadingmain_threadis_alivesysr   rS   )should_keep_threadrr   num_known_refssub_threadss    r*   keep_thread_activez7tracing_control_thread_func.<locals>.keep_thread_active  s    F-.63I3ILLNO$$&//1LLGH3& "%!8>CM < " &= &% r,   rt   r   rU   rV   rU   rN   rV   zHybrid mode cleanupOTEL-only cleanupLangSmith-only cleanupz'Tracing control thread is shutting downrB   rD   ).rT   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   r   _multipart_disabledrQ   r   rp   r   r   r   r   instance_flagsr   weakrefWeakSet_futuresr   r_   r   Eventr   Thread-tracing_control_thread_func_compress_parallelref_use_daemon_threadsstartr   removerS   qsize_tracing_sub_thread_funcr%   r   rb   rY   r   r   r   )
client_refrT   @py_assert2@py_assert1@py_format4@py_format6r   rs   r   r   r   disable_compressionr   thread
new_threadr   r   max_batch_sizerW   rr   r   r   s                      @@@r*   tracing_control_thread_funcr  U  s   \F~((M $$=$$$$=$$$$$$=$$$=$$$$$$$$$$/<),7J#67P#Q"56N"O222 7J7N7N $8M +-KN @	

 	""#<= 	t+	 
 =**0b55&
 NNU
 &oo/FO'7'9F$+4??+<F(Dkk&)+11 egaN< 
! 	+F??$""6*	+ 66##%(>>"))/kk&)=911J
 z*2B2D/!<(( "&&'9: 	
 5N
 
: 
 )3M:} 1&-T -M:}G 
P /?.@+|$$X(;(?(?@R(SXWX  4Zu^ *  %LL.//z= LL,--fmZP LL12(z=! 4Zu^ * & LL:;r,   c                v    |        y t         j                  d       j                  j                  j                  t         j                  d       y t        j                        }|d   }j                  xs |j                  dd      }ddfd}t        j                         }	 j                  j                  d	
      } |       sn|r~j                  j                          t        ||      \  }}	|=	 t        j!                  j"                  ||	      }
j                  j%                  |
       t        j                         }nwt        j                         |z
  |k\  r]t        dd      \  }}	|6	 t)        j                  t        j!                  j"                  ||	      g       t        j                         }	 t        dd      \  }}	|6	 t)        j                  t        j!                  j"                  ||	      g       t         j                  d       y # t&        $ r j#                  ||	       Y w xY w# t&        $ r j#                  ||	       Y w xY w# t&        $ r j#                  ||	       Y vw xY w# t*        $ r t         j                  dd       Y w xY w)Nz4Tracing control thread func compress parallel calledzLangSmith tracing error: Required compression attributes not initialized.
This may affect trace submission but does not impact your application's runtime.rs   rt     @   c                 X   rt        d      r"j                  rt        j                  d       yt	        j
                         j                         st        j                  d       yt        t        d      r1t        j                        kD  } | st        j                  d       | S y)Nr   z7Client is being cleaned up, stopping compression threadFz0Main thread is dead, stopping compression threadr   ziClient refs count indicates we're the only remaining reference to the client, stopping compression threadT)	r   r   rp   r   r   r   r   r   r   )r   rr   r   s    r*   r   zItracing_control_thread_func_compress_parallel.<locals>.keep_thread_active  s    F-.63I3ILLRS$$&//1LLKL3& "%!8>!I%A &% r,   TrP   )rO   r   )rs   rt   zuLangSmith tracing error: Failed during final cleanup.
This does not affect your application's runtime.
Error details:r]   z1Compressed traces control thread is shutting downr   )rp   r   r_   r   r  rq   r   r   rb   rQ   time	monotonicwaitclearrx   LANGSMITH_CLIENT_THREAD_POOLr   _send_compressed_multipart_reqaddr~   r   ro   )r  flush_intervalr   rs   rt   r   last_flush_time	triggereddata_streamrw   futurefinal_data_streamrr   r   s               @@r*   r
  r
    s    \F~
LLGH  (''/??"1	

 	/<),7J33 7J7N7NJ8
 N4 nn&O
0055d5C	!# ((..0 8j"234/K/ &9@@==#.F
 OO''/ #nn.O  ?2~E <q1* * < C C$*$I$I$/$:!" #'.."2i n
 4q1
	
" (4;;"AA-2, LLDEC $ 99#.4 ( =='24   55%*  
 	 	 	

sT   <H1 5I J &5I4 1III10I14JJ JJ  J87J8c                \    |        }|y 	 |j                   sy 	 |j                  }d }||u}|st        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}}t        |j                         }	|	j                  dd	      }
d
}t        j                          j#                         r||	d   k  r|j$                  xs |	j                  d      xs d
}t'        ||
|      x}r?d
}t)               \  }}|rt+        ||||       n$|rt-        |||       nt/        ||||       n|dz  }t        j                          j#                         r	||	d   k  rt)               \  }}|j$                  xs |	j                  d      xs d
}t'        ||
d|      x}rk|rt+        ||||       nH|r#t        j                  d       t-        |||       n#t        j                  d       t/        ||||       t'        ||
d|      x}rkt        j                  d       y # t        $ r }t        j                  d|       Y d }~y d }~ww xY w)Nz#Error in tracing control thread: %sr   r   rT   r   r   r   rs   r   r   r   rt   r   r   Fr   r   r   z+Tracing control sub-thread is shutting down)r   r   rp   r   rT   r   r   r   r   r   r   r  r  r   rQ   r   r   r   rb   rY   r   r   r   r   )r  r   rr   r   rT   r  r  r  r  r   rs   seen_successive_empty_queuesr  rW   r   r   s                   r*   r  r  w  s    \F~{{ 
 ((M $$=$$$$=$$$$$$=$$$=$$$$$$$$$$/<$((s;J#$ 
 	((*(:;< (( "&&'9: 	
 5N
 
: 
 ,-(6F6H3%|(3M:} 1&-T -M:} )A-(= 	((*(:;<> /?.@+|$$X(;(?(?@R(SXWX  4Zu^ *  %/z= LL,--fmZP LL12(z= 4Zu^ * $ LL>?G  :A>s   J 	J+J&&J+)r&   list[TracingQueueItem]rB   z}dict[tuple[Optional[str], Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]], list[TracingQueueItem]])r   Tr   )
rT   r   rU   r   rN   rD   rV   r   rB   r.  )r   r  )rr   r   rs   r   rt   z
int | NonerB   z6tuple[Optional[io.BytesIO], Optional[tuple[int, int]]])rr   r   r   z0list[tuple[str, dict, dict[str, Optional[str]]]]rB   rC   )TN)rr   r   rT   r   r&   r.  r   rD   r   rD   r   JOptional[list[Union[SerializedRunOperation, SerializedFeedbackOperation]]]rB   rC   )rr   r   rT   r   r&   r.  r   rD   r   r/  rB   rC   )T)rr   r   rT   r   r&   r.  r   rD   r   rD   rB   rC   )rB   zOptional[int])r   zls_schemas.LangSmithInforB   zls_schemas.BatchIngestConfig)rB   ztuple[bool, bool])r  weakref.ref[Client]rB   rC   )g      ?)r  r0  r&  floatrB   rC   )r  r0  r   rD   rB   rC   )F
__future__r   builtinsr   _pytest.assertion.rewrite	assertionrewriter   concurrent.futuresfuturesr   r   	functoolsiologgingr   r   r  r  multiprocessingr   queuer   r   typingr   r   r	   r
   r   	langsmithr   r   r   r   &langsmith._internal._compressed_tracesr   r   langsmith._internal._constantsr   r   r   r   langsmith._internal._operationsr   r   r   opentelemetry.context.contextr   langsmith.clientr   	getLoggerrp   r   r#  r+   total_orderingr.   rY   rx   r   r   r   r   r   r   r   r  r
  r  rL   r,   r*   <module>rG     s   "       	  
    %  < < + ' S   5'			-	.4r44M !
< ?4 ?4 ?4F WX++!$+37+PS++^ KU66 #6=G6;6r2
2
F2
 
2
t   	]]] "] 	]
 ]
] 
]H   	=== "= 	=

= 
=J  NNN "N 	N
 N 
Nb
"!03.N<d >ANF#NF5:NF	NFbM@#M@M@ 
M@r,   