
    `i                         d dl mZ d dlmZ ddlmZmZ d dlmZ erd dlm	Z	m
Z
 	 d dlZn# e$ r  ed          w xY w	 	 	 	 ddZdS )    wraps)DidNotEnable   execute_tool_spanupdate_execute_tool_span)TYPE_CHECKING)AnyCallableNzOpenAI Agents not installedoriginal_get_all_toolsCallable[..., Any]returnc                 |     t          t           d          r j        n           	 	 	 	 	 	 	 	 d fd
            }|S )z
    Wraps the agents.Runner._get_all_tools method of the Runner class to wrap all function tools with Sentry instrumentation.
    __func__clsagents.Runneragentagents.Agentcontext_wrapperagents.RunContextWrapperr   list[agents.Tool]c           
      V  K    	|           d {V }g }|D ]}|j         j        dk    r|                    |           (|j        }	 	 	 	 	 	 d	fd}t	          j        |j        |j        |j         |||          |j	        |j
                  }|                    |           |S )
NFunctionToolcurrent_toolagents.Toolcurrent_on_invoker   r   c                 R     t                    	 	 	 	 	 	 d fd            }|S )Nargsr   kwargsr   c                     K   t          g| R i |5 } | i | d {V }t          ||           d d d            n# 1 swxY w Y   |S )Nr   )r   r    spanresultr   r   r   s       /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/sentry_sdk/integrations/openai_agents/patches/tools.pysentry_wrapped_on_invoke_toolz_create_get_all_tools_wrapper.<locals>.wrapped_get_all_tools.<locals>.create_wrapped_invoke.<locals>.sentry_wrapped_on_invoke_tool3   s       +<I$III&II 	TT (9'8$'I&'I'I!I!I!I!I!I!I0ulFSSS	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T "Ms   !AAA)r   r   r    r   r   r   r   )r   r   r%   r   s   `` r$   create_wrapped_invokez[_create_get_all_tools_wrapper.<locals>.wrapped_get_all_tools.<locals>.create_wrapped_invoke0   sc     ())" ",1"" " " " " " " *)"  54    )namedescriptionparams_json_schemaon_invoke_toolstrict_json_schema
is_enabled)r   r   r   r   r   r   )	__class____name__appendr+   agentsr   r(   r)   r*   r,   r-   )
r   r   r   toolswrapped_toolstooloriginal_on_invoker&   wrapped_toolr   s
    `       r$   wrapped_get_all_toolsz<_create_get_all_tools_wrapper.<locals>.wrapped_get_all_tools   s      -,UODDDDDDDD '	/ '	/D~&.88$$T*** "&!45+5@T5%5 5 5 5 5 5, ".Y ,#'#:44T;MNN#'#:?  L   ....r'   )r   r   r   r   r   r   r   r   )r   hasattrr   )r   r7   s   ` r$   _create_get_all_tools_wrapperr9      s     ):66	$''# 
222 42 
	2 2 2 2 2 
2h ! r'   )r   r   r   r   )	functoolsr   sentry_sdk.integrationsr   spansr   r	   typingr
   r   r   r1   ImportErrorr9    r'   r$   <module>r@      s          0 0 0 0 0 0 ? ? ? ? ? ? ? ?             %$$$$$$$$6MMMM 6 6 6
,4
5
556@!0@!@! @! @! @! @! @!s   + <