
    \j                         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y)    )Iterable)TYPE_CHECKING)TextPart)Union)ChatCompletionMessageParam ChatCompletionSystemMessageParamChatCompletionContentPartParammessager   returnc                 N    t        | t              xr | j                  d      dk(  S )Nrolesystem)
isinstancedictget)r
   s    O/root/env/lib/python3.12/site-packages/sentry_sdk/ai/_openai_completions_api.py_is_system_instructionr      s"    gt$HV)<)HH    c                 h    t        | t              sg S | D cg c]  }t        |      s| c}S c c}w )N)r   r   r   )messagesr
   s     r   _get_system_instructionsr      s/     h)	#+O/Eg/NGOOOs   //c                     t        | t              r| gS t        | t              sg S g }| D ]N  }t        |t              s|j	                  d      dk(  s)|j	                  dd       }|>|j                  |       P |S )Ntypetext)r   strr   r   r   append)content
text_itemspartr   s       r   _get_text_itemsr       s     '3ygx(	J (dD!dhhv&6&&@88FD)D!!$'	( r   c                     g }| D ]G  }t        |t              s|j                  d      }|(t        |      D cg c]  }d|d	 }}||z  }I |S c c}w )Nr   r   )r   r   )r   r   r   r    )system_instructionsinstruction_text_partsinstructionr   r   
text_partss         r   _transform_system_instructionsr&   0   s}     02* -+t,//),? ;J':R(
26V-(

 (
 	*,- "!(
s   AN)r   z$Iterable[ChatCompletionMessageParam]r   z list[ChatCompletionMessageParam])r   z4Union[str, Iterable[ChatCompletionContentPartParam]]r   z	list[str])r"   z&list[ChatCompletionSystemMessageParam]r   zlist[TextPart])collections.abcr   typingr   sentry_sdk._typesr   r   openai.types.chatr   r   r	   boolr   r   r    r&    r   r   <module>r-      sw    $  * I$@ IT IP4P'PC&"A""r   