
    `i                         d dl mZ d dlmZ erd dlmZ d dlmZ d dlmZm	Z	m
Z
 dddefd	Z	 	 	 	 ddZ	 	 	 	 ddZ	 	 	 	 ddZdS )    )Iterable)TYPE_CHECKING)TextPart)Union)ChatCompletionMessageParam ChatCompletionSystemMessageParamChatCompletionContentPartParammessager   returnc                 ^    t          | t                    o|                     d          dk    S )Nrolesystem)
isinstancedictget)r
   s    y/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/sentry_sdk/ai/_openai_completions_api.py_is_system_instructionr      s(    gt$$HV)<)<)HH    messages$Iterable[ChatCompletionMessageParam] list[ChatCompletionMessageParam]c                 H    t          | t                    sg S d | D             S )Nc                 0    g | ]}t          |          |S  )r   ).0r
   s     r   
<listcomp>z,_get_system_instructions.<locals>.<listcomp>   s&    OOO/Eg/N/NOGOOOr   )r   r   )r   s    r   _get_system_instructionsr      s/     h)) 	OO8OOOOr   content4Union[str, Iterable[ChatCompletionContentPartParam]]	list[str]c                 (   t          | t                    r| gS t          | t                    sg S g }| D ]]}t          |t                    rF|                    d          dk    r-|                    dd           }||                    |           ^|S )Ntypetext)r   strr   r   r   append)r   
text_itemspartr#   s       r   _get_text_itemsr(      s     '3 ygx(( 	J ( (dD!! 	(dhhv&6&6&&@&@88FD))D!!$'''r   system_instructions&list[ChatCompletionSystemMessageParam]list[TextPart]c                     g }| D ]N}t          |t                    s|                    d          }|0d t          |          D             }||z  }O|S )Nr   c                     g | ]}d |dS )r#   )r"   r   r   )r   r#   s     r   r   z2_transform_system_instructions.<locals>.<listcomp>=   s-     (
 (
 (
26V--(
 (
 (
r   )r   r   r   r(   )r)   instruction_text_partsinstructionr   
text_partss        r   _transform_system_instructionsr1   0   s     02* - -+t,, 	//),,?(
 (
:I':R:R(
 (
 (

 	*,!!r   N)r   r   r   r   )r   r   r   r    )r)   r*   r   r+   )collections.abcr   typingr   sentry_sdk._typesr   r   openai.types.chatr   r   r	   boolr   r   r(   r1   r   r   r   <module>r7      s,   $ $ $ $ $ $             ******         I$@ IT I I I IP4P'P P P PC   &"A"" " " " " "r   