
    Kip                     \    S SK r S SKrS SKrS SKJr  S SKJrJ	r	J
r
JrJrJrJr  S SKJr  S SKJr  S SKJrJr  S SKJr  S S	KJrJrJrJrJrJr  S S
KJ r J!r!  S SK"J#r#  S SK$J%r%  S SK&J'r'J(r(  S SK)J*r*  \RV                  " S5      r,\ " S S5      5       r-\ " S S\-5      5       r.\\-\.4   r/\	\\/4   r0 " S S\5      r1S r2S\S\	\3\4   4S jr4\ " S S5      5       r5S\\#\64   S\54S jr7S\!S\54S jr8S \9S\:4S! jr;S"\\	\3\4      S#\S\\3   4S$ jr<S%\9S\34S& jr=g! \ a	    \" S5      ef = f)'    NzEPlease install LangChain to use this feature: 'pip install langchain')	dataclass)AnyDictListOptionalSequenceUnioncast)UUID)BaseCallbackHandler)AgentActionAgentFinish)Document)	AIMessageBaseMessageFunctionMessageHumanMessageSystemMessageToolMessage)ChatGeneration	LLMResult)	BaseModel)default_client)get_model_paramswith_privacy_mode)Clientposthogc                   j    \ rS rSr% \\S'    \\S'    \\   \S'    \\   \S'    \	S\4S j5       r
Srg	)
SpanMetadata+   name
start_timeend_timeinputreturnc                 X    U R                   (       d  gU R                   U R                  -
  $ )Nr   )r#   r"   )selfs    `/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/posthog/ai/langchain/callbacks.pylatencySpanMetadata.latency6   s    }}}}t..     N)__name__
__module____qualname____firstlineno__str__annotations__floatr   r   propertyr)   __static_attributes__r,   r+   r(   r   r   +   sF    
I7 uoC=</ / /r+   r   c                       \ rS rSr% Sr\\   \S'    Sr\\   \S'    Sr	\\
\\4      \S'    Sr\\   \S'    Sr\\\
\\4         \S'   Srg)	GenerationMetadata=   Nprovidermodelmodel_paramsbase_urltoolsr,   )r-   r.   r/   r0   r9   r   r1   r2   r:   r;   r   r   r<   r=   r   r5   r,   r+   r(   r7   r7   =   sn    "Hhsm"0E8C=-1L(4S>*1D"Hhsm"9,0E8Dc3h()0&r+   r7   c                      \ rS rSr% Sr\\S'    \\\	\
\\4      \S'    \\\	\
\\4      \S'    \\   \S'    \\	   \S'    \\\	\4      \S'    \\S	'    \\\4   \S
'     SNSSSSSS.S\\   S\\\	\
\\4      S\\\	\
\\4      S\\\	\4      S\S\\\	\4      4S jjjrSSS.S\\	\4   S\\	\4   S\S\\   S\\\	\4      4
S jjrSS.S\\	\4   S\S\\   S\4S jjrSS.S \S\S\\   S\4S! jjrSS.S\\	\4   S"\\\      S\S\\   4S# jjrSS.S\\	\4   S$\\	   S\S\\   S\4
S% jjrSS.S&\	S\S\\   S\S'\4
S( jjrSS.S)\S\S\\   S\4S* jjrSS.S \S\S\\   S\4S+ jjrSSS.S\\\	\4      S,\	S\S\\   S\\\	\4      S\S'\4S- jjrSS.S.\	S\S\\   S\S'\4
S/ jjrSSS0.S \S\S\\   S1\\ \	      S\S'\4S2 jjr!SSS.S\\\	\4      S3\	S\S\\   S\\\	\4      S\S'\4S4 jjr"SS.S5\#\$   S\S\\   S\4S6 jjr%SSS0.S \S\S\\   S1\\ \	      S\S'\4S7 jjr&SS.S8\'S\S\\   S\S'\4
S9 jjr(SS.S:\)S\S\\   S\S'\4
S; jjr*SNS\S\\   4S< jjr+S\4S= jr,S\S'\4S> jr- SNS\\\	\4      S?\S\S\\   4S@ jjr.  SOS\\	\4   S\S"\\\\	\4      \\	   4   S\\\	\4      SA\\\	\4      4
SB jjr/S\S'\\0   4SC jr1S\4SD jr2S\S\S\\   4SE jr3S\S\\   S\4SF jr4S\S\SG\5S\S\\   4
SH jr6S\S\\   S)\\\4   4SI jr7 SNS\S\SG\8S.\\\4   S\\   4
SJ jjr9 SNSK\	S\S\\   4SL jjr:SMr;g)PCallbackHandlerO   z?
The PostHog LLM observability callback handler for LangChain.
_client_distinct_id	_trace_id_trace_input_trace_name_properties_runs_parent_treeNF)distinct_idtrace_id
propertiesprivacy_modegroupsclientrI   rJ   rK   rL   rM   c                    U=(       d    [         nUc  [        S5      eXpl        X l        X0l        U=(       d    0 U l        XPl        U=(       d    0 U l        0 U l        0 U l	        g)a  
Args:
    client: PostHog client instance.
    distinct_id: Optional distinct ID of the user to associate the trace with.
    trace_id: Optional trace ID to use for the event.
    properties: Optional additional metadata to use for the trace.
    privacy_mode: Whether to redact the input and output of the trace.
    groups: Optional additional PostHog groups to use for the trace.
NzPostHog client is required)
r   
ValueErrorrA   rB   rC   rF   _privacy_mode_groupsrG   rH   )r'   rN   rI   rJ   rK   rL   rM   posthog_clients           r(   __init__CallbackHandler.__init__o   s]    &  1>!9::%'!%+)|
r+   )parent_run_idmetadata
serializedinputsrun_idrV   rW   c                p    U R                  SX4US9  U R                  X45        U R                  " XX440 UD6  g )Non_chain_start)rY   _log_debug_event_set_parent_of_run_set_trace_or_span_metadata)r'   rX   rY   rZ   rV   rW   kwargss          r(   r\   CallbackHandler.on_chain_start   sC     	.fU6((	
9?	
r+   )rV   outputsra   c                J    U R                  SX#US9  U R                  X#U5        g )Non_chain_end)rc   r^   "_pop_run_and_capture_trace_or_span)r'   rc   rZ   rV   ra   s        r(   re   CallbackHandler.on_chain_end   s)     	nfWU//wOr+   errorc                J    U R                  SX#US9  U R                  X#U5        g )Non_chain_errorri   rf   r'   ri   rZ   rV   ra   s        r(   rk   CallbackHandler.on_chain_error   s*     	.US//uMr+   messagesc                    U R                  SX4US9  U R                  X45        U VVs/ s H  of  H  n[        U5      PM     M     nnnU R                  " XU40 UD6  g s  snnf )Non_chat_model_start)ro   )r^   r_   _convert_message_to_dict_set_llm_metadata)	r'   rX   ro   rZ   rV   ra   rowmessager$   s	            r(   rq   #CallbackHandler.on_chat_model_start   sw     	!68 	 	
 	69A
9A#QTg$W-QT- 	 
 	z5CFC
s   Apromptsc                p    U R                  SX4US9  U R                  X45        U R                  " XU40 UD6  g )Non_llm_start)rw   )r^   r_   rs   )r'   rX   rw   rZ   rV   ra   s         r(   ry   CallbackHandler.on_llm_start   s<     	nfWU6z7EfEr+   tokenr%   c                &    U R                  SX#US9  g)z?Run on new LLM token. Only available when streaming is enabled.on_llm_new_token)r{   N)r^   )r'   r{   rZ   rV   ra   s        r(   r}    CallbackHandler.on_llm_new_token   s     	0&uUr+   responsec                J    U R                  SX#XS9  U R                  X#U5        g)z
The callback works for both streaming and non-streaming runs. For streaming runs, the chain must set `stream_usage=True` in the LLM.

on_llm_end)r   ra   Nr^   _pop_run_and_capture_generation)r'   r   rZ   rV   ra   s        r(   r   CallbackHandler.on_llm_end   s0     	&( 	 	
 	,,VHMr+   c                J    U R                  SX#US9  U R                  X#U5        g )Non_llm_errorrl   r   rm   s        r(   r   CallbackHandler.on_llm_error   s)     	nf5Q,,VEJr+   	input_strc                p    U R                  SX4US9  U R                  X45        U R                  " XX440 UD6  g )Non_tool_start)r   r]   )r'   rX   r   rZ   rV   rW   ra   s          r(   r   CallbackHandler.on_tool_start   sI     	Vi 	 	
 	6((6	
<B	
r+   outputc                J    U R                  SX#US9  U R                  X#U5        g )Non_tool_end)r   rf   )r'   r   rZ   rV   ra   s        r(   r   CallbackHandler.on_tool_end  s)     	mV6R//vNr+   )rV   tagsr   c                J    U R                  SX#US9  U R                  X#U5        g )Non_tool_errorrl   rf   r'   ri   rZ   rV   r   ra   s         r(   r   CallbackHandler.on_tool_error  s)     	ovER//uMr+   queryc                p    U R                  SX4US9  U R                  X45        U R                  " XX440 UD6  g )Non_retriever_start)r   r]   )r'   rX   r   rZ   rV   rW   ra   s          r(   r   "CallbackHandler.on_retriever_start"  sD     	2FQVW6((v	
8>	
r+   	documentsc                J    U R                  SX#US9  U R                  X#U5        g )Non_retriever_end)r   rf   )r'   r   rZ   rV   ra   s        r(   r    CallbackHandler.on_retriever_end2  s0     	 	 	
 	//yQr+   c                J    U R                  SX#US9  U R                  X#U5        g)zRun when Retriever errors.on_retriever_errorrl   Nrf   r   s         r(   r   "CallbackHandler.on_retriever_error?  s+     	2FQVW//uMr+   actionc                r    U R                  SX#US9  U R                  X#5        U R                  " SXU40 UD6  g)zRun on agent action.on_agent_action)r   Nr]   )r'   r   rZ   rV   ra   s        r(   r   CallbackHandler.on_agent_actionL  s@     	/vV6((v}WPVWr+   finishc                J    U R                  SX#US9  U R                  X#U5        g )Non_agent_finish)r   rf   )r'   r   rZ   rV   ra   s        r(   r   CallbackHandler.on_agent_finishY  s*     	/vV//vNr+   c                 (    Ub  X R                   U'   gg)zT
Set the parent run ID for a chain run. If there is no parent, the run is the root.
NrH   )r'   rZ   rV   s      r(   r_   "CallbackHandler._set_parent_of_rund  s     $(5f% %r+   c                 \     U R                   R                  U5        g! [         a     gf = f)z+
Remove the parent run ID for a chain run.
N)rH   popKeyError)r'   rZ   s     r(   _pop_parent_of_run"CallbackHandler._pop_parent_of_runk  s-    	!!&) 		s    
++c                 h    UnX R                   ;   a   U R                   U   nX R                   ;   a  M   U$ )z#
Finds the root ID of a chain run.
r   )r'   rZ   ids      r(   _find_root_runCallbackHandler._find_root_runt  s8     %%%""2&B %%%	r+   r$   c                     Uc  SOSn[        U40 UD6=(       d    Un[        Xr[        R                  " 5       S S9U R                  U'   g )Ntracespanr!   r$   r"   r#   )_get_langchain_run_namer   timerG   )r'   rX   r$   rZ   rV   ra   default_namerun_names           r(   r`   +CallbackHandler._set_trace_or_span_metadata}  sD     #0"7wV*:@@PL)499;


6r+   invocation_paramsc                    [        U40 UD6=(       d    Sn[        Xs[        R                  " 5       S S9n[        U[        5      (       a.  [        U5      Ul        UR                  S5      =n	(       a  Xl        [        U[        5      (       a<  UR                  S5      =n
(       a  Xl	        UR                  S5      =n(       a  Xl
         US   S   nUb  Xl        XR                  U'   g ! [         a     Nf = f)N
generationr   r=   ls_model_namels_providerra   openai_api_base)r   r7   r   
isinstancedictr   r;   getr=   r:   r9   r<   r   rG   )r'   rX   rZ   ro   rW   r   ra   r   r   r=   r:   r9   r<   s                r(   rs   !CallbackHandler._set_llm_metadata  s     +:@@PL'diikD

 '..&67H&IJ#)--g66u6#( h%% _55u5#( #<<66x6&.#	!(+,=>H#&.# (

6  		s   	C) )
C65C6c                     [         R                   " 5       n U R                  R                  U5      nX#l        U$ ! [         a    [        R                  SU 35         g f = f)NzNo run metadata found for run )r   rG   r   r   logwarningr#   )r'   rZ   r#   runs       r(   _pop_run_metadata!CallbackHandler._pop_run_metadata  sX    99;	**..(C  
	  	KK8AB	s   : "AAc                 `    U R                   =(       d    U R                  U5      nU(       d  U$ U$ N)rC   r   )r'   rZ   rJ   s      r(   _get_trace_idCallbackHandler._get_trace_id  s(    >>@T%8%8%@Mr+   c                 .    Ub  X0R                   ;  a  U$ U$ )zb
Replace the parent run ID with the trace ID for second level runs when a custom trace ID is set.
r   )r'   rJ   rZ   rV   s       r(   _get_parent_run_id"CallbackHandler._get_parent_run_id  s      $>O>O)OOr+   c                 "   U R                  U5      nU R                  U5        U R                  U5      nU(       d  g [        U[        5      (       a  [
        R                  SU S35        g U R                  UUUUU R                  XAU5      5        g )NRun zB is a generation, but attempted to be captured as a trace or span.)	r   r   r   r   r7   r   r   _capture_trace_or_spanr   )r'   rZ   rV   rc   rJ   r   s         r(   rg   2CallbackHandler._pop_run_and_capture_trace_or_span  s     %%f-'$$V,c-..KKvh`a ####HmD	
r+   r   c                 8   Uc  SOSnU[        U R                  U R                  UR                  5      UR                  UR
                  US.nUb  XWS'   U R                  (       a  UR                  U R                  5        [        U[        5      (       a  [        U5      US'   SUS'   O'Ub$  [        U R                  U R                  U5      US'   U R                  c  S	US
'   U R                  R                  U R                  =(       d    UUUU R                  S9  g )Nz	$ai_tracez$ai_span)$ai_trace_idz$ai_input_state$ai_latency$ai_span_name$ai_span_id$ai_parent_id	$ai_errorT$ai_is_errorz$ai_output_stateF$process_person_profilerI   eventrK   rM   )r   rA   rQ   r$   r)   r!   rF   updater   BaseException_stringify_exceptionrB   capturerR   )r'   rJ   rZ   r   rc   rV   
event_nameevent_propertiess           r(   r   &CallbackHandler._capture_trace_or_span  s    %2$9[z
$0d00#))  ;; XX!
 $0=_-##D$4$45g}--,@,I[)/3^, 3Dd00'4/0 $:?67))3V'<<	 	 	
r+   c                 "   U R                  U5      nU R                  U5        U R                  U5      nU(       d  g [        U[        5      (       d  [
        R                  SU S35        g U R                  UUUUU R                  XAU5      5        g )Nr   zC is not a generation, but attempted to be captured as a generation.)	r   r   r   r   r7   r   r   _capture_generationr   )r'   rZ   rV   r   rJ   r   s         r(   r   /CallbackHandler._pop_run_and_capture_generation  s     %%f-'$$V,#122KKvhab   ##HmD	
r+   c                    UUUR                   UUR                  UR                  UR                  [	        U R
                  U R                  UR                  5      SUR                  UR                  S.nUR                  (       a.  [	        U R
                  U R                  UR                  5      US'   [        U[        5      (       a"  [        U5      US'   [        U5      US'   SUS'   O[        U5      nUR                   US'   UR"                  US	'   UR$                  US
'   UR&                  US'   UR(                  US'   UR*                  S   n[        US   [,        5      (       a4  U V	s/ s H&  n	[/        [1        [,        U	5      R2                  5      PM(     n
n	OU V	s/ s H  n	[5        U	5      PM     n
n	[	        U R
                  U R                  U
5      US'   U R6                  (       a  UR9                  U R6                  5        U R:                  c  SUS'   U R
                  R=                  U R:                  =(       d    USUU R>                  S9  g s  sn	f s  sn	f )N   )r   r   r   r   z$ai_providerz	$ai_modelz$ai_model_parametersz	$ai_input$ai_http_statusr   z$ai_base_urlz	$ai_toolsr   r   Tr   z$ai_input_tokensz$ai_output_tokensz$ai_cache_creation_input_tokensz$ai_cache_read_input_tokensz$ai_reasoning_tokensz$ai_output_choicesFr   z$ai_generationr   ) r!   r9   r:   r;   r   rA   rQ   r$   r)   r<   r=   r   r   _get_http_statusr   _parse_usageinput_tokensoutput_tokenscache_write_tokenscache_read_tokensreasoning_tokensgenerationsr   rr   r
   ru   _extract_raw_esponserF   r   rB   r   rR   )r'   rJ   rZ   r   r   rV   r   usagegeneration_resultr   completionss              r(   r   #CallbackHandler._capture_generation  sO    %! XX*LL$'$4$4*4<<9K9KSYYW";;LL
 99,=""		-[) fm,,2B62J./,@,H[)/3^, !(E383E3E/0494G4G01(( >? ?D>U>U:;7<7M7M34 !' 2 22 6+B/@@ '8&7
 -T.*-M-U-UV&7   HYGX(4GX   6Gd00+612 ##D$4$45$:?67))5X"'<<	 	 	
%
s   +-IIr   c           
      v    [         R                  SU S[        U5      S S  S[        U5      S S  SU 35        g )NzEvent: z
, run_id:    z, parent_run_id: z
, kwargs: )r   debugr1   )r'   r   rZ   rV   ra   s        r(   r^    CallbackHandler._log_debug_event`  sK     			j\CKO+<<McR_N`acbcNdMeeopvowx	
r+   )rA   rB   rR   rH   rQ   rF   rG   rC   r   )NN)<r-   r.   r/   r0   __doc__r   r2   r   r	   r1   intr3   r   r   r   RunMetadataStorageboolrT   r\   re   r   rk   r   r   rq   ry   r}   r   r   r   r   r   listr   r   r   r   r   r   r   r   r   r   r_   r   r   r`   rs   RunMetadatar   r   r   rg   r   r   r   r7   r   r^   r5   r,   r+   r(   r?   r?   O   s<    O"5c5$!6788>c3t3455_3-?#/$sCx.))8jtTz"" $( ?C;?/3"+/  eCeT$9:;	
 5c5$!678 T#s(^,  c3h(J )--1
cN
 S#X

 
  ~
 4S>*
* )-	Pc3h	P 		P
  ~	P 	P  )-	N	N 		N
  ~	N 	N" )-DcND tK()D
 D  ~D0 )-FcNF cF
 F  ~F F$ )-	V	V 		V
  ~	V 	V 
	V  )-NN 	N
  ~N N* )-	K	K 		K
  ~	K 	K" )--1
T#s(^,
 

 
  ~
 4S>*
 
 

. )-	O	O 		O
  ~	O 	O 
	O  )-$(
N
N 	
N
  ~
N tCy!
N 
N 

N$ )--1
T#s(^,
 

 
  ~
 4S>*
 
 

* )-RH%R 	R
  ~R R$ )-$(NN 	N
  ~N tCy!N N 
N$ )-XX 	X
  ~X X 
X$ )-	O	O 		O
  ~	O 	O 
	O6 6htn 6 T d  )-
T#s(^,
 
 	

  ~
& .26:(cN( ( T#s(^,d3i78	(
 4S>*( $DcN3(< +1F D %):B4.

+3D>
DG
*'
'
 '
 	'

 '
  ~'
R

  ~
 	=01	
< )-E
E
 E
  	E

 i./E
  ~E
V )-		
	
 	
  ~		
 	
r+   r?   c                     U R                   b8  U R                   R                  5       S:w  a  U R                   R                  5       $ [        U S5      (       a  U R                  R                  $ g)z<Extract the response from the last response of the LLM call. ru   )textstriphasattrru   additional_kwargs)last_responses    r(   r   r   l  s_     %-*<*<*B*B*D*J!!''))			*	*$$666 r+   ru   r%   c                    [        U [        5      (       a  SU R                  S.nO[        U [        5      (       a  SU R                  S.nO[        U [        5      (       a  SU R                  S.nOl[        U [
        5      (       a  SU R                  S.nOG[        U [        5      (       a  SU R                  S.nO"U R                  [        U R                  5      S.nU R                  (       a  UR                  U R                  5        U$ )Nuser)rolecontent	assistantsystemtoolfunction)r   r   r  r   r   r   r   typer1   r  r   )ru   message_dicts     r(   rr   rr   y  s    '<(( &7??C	GY	'	' +H	G]	+	+ (W__E	G[	)	) &7??C	G_	-	- *wG 'W__9MN  G556r+   c                   f    \ rS rSr% \\   \S'   \\   \S'   \\   \S'   \\   \S'   \\   \S'   Srg)	
ModelUsagei  r   r   r   r   r   r,   N)r-   r.   r/   r0   r   r  r2   r5   r,   r+   r(   r  r    s4    3-C=  %}$sm#r+   r  r   c                 r   [        U [        5      (       a  U R                  n / SQn0 nU H6  u  p4X0;   d  M  X   n[        U[        5      (       a  [	        U5      OUnXbU'   M8     SU ;   aF  [        U S   [
        5      (       a.  U S   R                  S5      US'   U S   R                  S5      US'   SU ;   a/  [        U S   [
        5      (       a  U S   R                  S5      US'   SS	S
SSS.n[        S0 UR                  5        VV	s0 s H  u  pXR                  U5      =(       d    S_M!     sn	nD6$ s  sn	nf )N))r   r$   )r   r   cache_creation_input_tokenscache_writecache_read_input_tokens
cache_read)prompt_token_countr$   )candidates_token_countr   )cached_content_token_countr!  )thoughts_token_count	reasoning)inputTokenCountr$   )outputTokenCountr   )cacheCreationInputTokenCountr  )cacheReadInputTokenCountr!  )prompt_tokensr$   )completion_tokensr   r  r  )input_token_countr$   )generated_token_countr   input_token_detailscache_creationr  r!  output_token_detailsr&  r   r   r   r   r   )r$   r   r  r!  r&  r   r,   )	r   r   __dict__r  sumr   r   r  items)
r   conversion_listparsed_usage	model_keytype_keycaptured_countfinal_countfield_mapping
mapped_keydataclass_keys
             r(   _parse_usage_modelr>    ss    %##O4 L.	"-N nd33 N##  &1"  / %*#$d+ + ',,A&B&F&FGW&X]#%*+@%A%E%El%S\" &:$%t, , %**@$A$E$Ek$R[!  !+)'M   .;-@-@-B
-B)
 ++J7<1<-B
 
s   &D3r   c                    SS/n[        S S S S S S9nU R                  bC  U H=  nU R                  R                  U5      (       d  M%  [        U R                  U   5      n  O   [	        U S5      (       Ga  U R
                   GH  nSU;   a  [        US   5      n  U$ U H  nUR                  (       a+  SUR                  ;   a  [        UR                  S   5      n  M\  [        US0 5      n[        US0 5      n[        U[        5      (       a  UR                  SS 5      OS n[        U[        5      (       a  UR                  SS 5      OS n	[        USS 5      n
U=(       d    U	=(       d    U
nU(       d  M  [        U5      n  GM     GM     U$ )	Ntoken_usager   )r   r   r   r   r   r   usage_metadataru   response_metadataz amazon-bedrock-invocationMetrics)
r  
llm_outputr   r>  r  r   generation_infogetattrr   r   )r   llm_usage_keys	llm_usagekeyr   generation_chunkmessage_chunkrB  bedrock_anthropic_usagebedrock_titan_usageollama_usagechunk_usages               r(   r   r     s   #W-N&I &!C""&&s++.x/B/B3/GH	 "
 x''"..J*$.z'/BC	J G %/ #33$(8(H(HH 2(889IJ!I  '(8)R H$+M;NPR$S! ""3T:: &))'48 ( ""3T:: &)):D  $  '!#3T 
 ,R/BRl  ; 2; ?IC %/ /P r+   ri   c           	      6    [        U S[        U SS5      5      nU$ )Nstatus_codecoder   )rE  )ri   rP  s     r(   r   r     s!     %vq0IJKr+   rX   ra   c                     SU;   a  US   b  US   $ U c  g U S   $ ! [         [        4 a     Of = f U S   S   $ ! [         [        4 a     gf = f)aK  Retrieve the name of a serialized LangChain runnable.

The prioritization for the determination of the run name is as follows:
- The value assigned to the "name" key in `kwargs`.
- The value assigned to the "name" key in `serialized`.
- The last entry of the value assigned to the "id" key in `serialized`.
- "<unknown>".

Args:
    serialized (Optional[Dict[str, Any]]): A dictionary containing the runnable's serialized data.
    **kwargs (Any): Additional keyword arguments, potentially including the 'name' override.

Returns:
    str: The determined name of the Langchain runnable.
r!   Nr   r   )r   	TypeError)rX   ra   s     r(   r   r   $  s~    $ F6N6f~&!!i  $##i  s    //; AA	exceptionc                     [        U 5      nU(       a  U R                  R                   SU 3$ U R                  R                  $ )Nz: )r1   	__class__r-   )rT  descriptions     r(   r   r   E  s>    i.K%%../r+??'''r+   )>	langchainImportErrorModuleNotFoundErrorloggingr   dataclassesr   typingr   r   r   r   r   r	   r
   uuidr   langchain.callbacks.baser   langchain.schema.agentr   r   langchain_core.documentsr   langchain_core.messagesr   r   r   r   r   r   langchain_core.outputsr   r   pydanticr   r   r   posthog.ai.utilsr   r   posthog.clientr   	getLoggerr   r   r7   r  r  r?   r   r1   rr   r  r   r>  r   r   r  r   r   r   r,   r+   r(   <module>rh     s     !    8 ; -  =  " @ !	" / / /" 
' 
' 
' L"445$+, Z
) Z
z
k d38n * $ $ $ED!EEP:9 : :zM c c3h(47c]B(M (c (E  
O s   D D+