Ë
    uPêj¼  ã                   ó”   — d Z ddlmZmZmZmZ ddlmZmZ ddl	Z	ddl
mZ ddlmZ ddlmZ ddlmZmZmZmZ dd	lmZ  G d
„ d«      Zy)zS
Handler for transforming interactions API requests to litellm.responses requests.
é    )ÚAsyncIteratorÚCallableÚ	CoroutineÚIterator)ÚAnyÚFinalN)Ú-LiteLLMResponsesInteractionsStreamingIterator)Ú"LiteLLMResponsesInteractionsConfig)Ú!BaseResponsesAPIStreamingIterator)ÚInteractionInputÚ$InteractionsAPIOptionalRequestParamsÚInteractionsAPIResponseÚ InteractionsAPIStreamingResponse)ÚResponsesAPIResponsec                   ó°   — e Zd ZdZ	 	 	 ddededz  dededz  dededz  d	ee	e
   z  eeeeee
   z  f   z  fd
„Zdeeef   dededz  ded	eee
   z  f
d„Zy)Ú#LiteLLMResponsesInteractionsHandlerzOHandler for bridging Interactions API to Responses API via litellm.responses().NÚmodelÚinputÚoptional_paramsÚcustom_llm_providerÚ	_is_asyncÚstreamÚreturnc                 ó2  — t        j                  d|||||dœ|¤Ž}|r | j                  d||||dœ|¤ŽS t        t        «      d   }	 |	di |¤Ž}
t        |
t        «      r!t        ||
||||j                  di «      ¬«      S |
}t        j                  ||¬«      S )a  
        Handle Interactions API request by calling litellm.responses().

        Args:
            model: The model to use
            input: The input content
            optional_params: Optional parameters for the request
            custom_llm_provider: Override LLM provider
            _is_async: Whether this is an async call
            stream: Whether to stream the response
            **kwargs: Additional parameters

        Returns:
            InteractionsAPIResponse or streaming iterator
        )r   r   r   r   r   )Úresponses_requestr   r   r   Ú	responsesÚlitellm_metadata©r   Úlitellm_custom_stream_wrapperÚrequest_inputr   r   r   ©Úresponses_responser   © )
r
   Ú3transform_interactions_request_to_responses_requestÚasync_interactions_api_handlerÚvarsÚlitellmÚ
isinstancer   r	   ÚgetÚ5transform_responses_response_to_interactions_response)Úselfr   r   r   r   r   r   Úkwargsr   Úresponses_fnr"   Úresponses_api_responses               ú‚/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/interactions/litellm_responses_transformation/handler.pyÚinteractions_api_handlerz<LiteLLMResponsesInteractionsHandler.interactions_api_handler   só   € ô> /×bÑbð ØØØ /Ø$7Øñð ñð 	ñ Ø6�4×6Ñ6ð Ø"3ØØØ /ñ	ð
 ñð ô hlÔlsÓgtØñh
ˆñ %1ñ %
Øñ%
Ðô
 Ð(Ô*KÔLÜ@ØØ.@Ø#Ø /Ø$7Ø!'§¡Ð,>ÀÓ!Côð ð );Ðô 2×gÑgØ5Øô
ð 	
ó    r   c              ‹   ó  K  — t        t        «      d   } |di |¤Žƒ d{  –—† }t        |t        «      r0t	        |||||j                  d«      |j                  di «      ¬«      S |}t        j                  ||¬«      S 7 Œ]­w)z,Async handler for interactions API requests.Ú
aresponsesNr   r   r   r!   r#   )r&   r'   r(   r   r	   r)   r
   r*   )	r+   r   r   r   r   r,   Úaresponses_fnr"   r.   s	            r/   r%   zBLiteLLMResponsesInteractionsHandler.async_interactions_api_handlerl   s    è ø€ ô ”‹M˜,Ñ'ð 	ñ +8ñ +
Øñ+
÷ %
Ðô
 Ð(Ô*KÔLÜ@ØØ.@Ø#Ø /Ø$5×$9Ñ$9Ð:OÓ$PØ!'§¡Ð,>ÀÓ!Côð ð );Ðô 2×gÑgØ5Øô
ð 	
ð'%
ús   ‚B  A>¡AB )NFN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   r   Úboolr   r   r   r   Úobjectr   r0   Údictr   r%   r#   r1   r/   r   r      së   „ ÙYð +/ØØ"ñN
àðN
ð   $Ñ&ðN
ð >ð	N
ð
 ! 4™ZðN
ð ðN
ð �t‘ðN
ð 	 Ø
Ð3Ñ
4ñ	5à
�F˜FÐ$;¸mÐLlÑ>mÑ$mÐmÑ
nñ	oóN
ð`$
à  S ™>ð$
ð ð$
ð   $Ñ&ð	$
ð
 >ð$
ð 
! =Ð1QÑ#RÑ	Rô$
r1   r   )r8   Úcollections.abcr   r   r   r   Útypingr   r   r'   ÚHlitellm.interactions.litellm_responses_transformation.streaming_iteratorr	   ÚDlitellm.interactions.litellm_responses_transformation.transformationr
   Ú$litellm.responses.streaming_iteratorr   Úlitellm.types.interactionsr   r   r   r   Úlitellm.types.llms.openair   r   r#   r1   r/   ú<module>rD      sD   ðñ÷ IÓ Hß ã õõõ S÷ó õ ;÷w
ò w
r1   