Ë
    tPêjO  ã                   ó  — d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZmZ ddlmZmZmZmZmZmZ erdd	lmZ 	 dd
dez  ez  ez  ez  ez  ez  ez  ez  ez  ez  deeef   dz  defd„Z G d„ de«      Zy)zŸ
If the LLM Obs has any specific attributes to log request or response, we can add them here.

Relevant Issue: https://github.com/BerriAI/litellm/issues/13764
é    N)ÚTYPE_CHECKINGÚAnyÚFinal)Ú	BaseModel)Úoverride)ÚBaseLLMObsOTELAttributesÚsafe_set_attribute)ÚHttpxBinaryResponseContentÚResponsesAPIResponse)ÚEmbeddingResponseÚImageResponseÚModelResponseÚRerankResponseÚTextCompletionResponseÚTranscriptionResponse)ÚSpanÚresponse_objÚkwargsÚreturnc                 ó6  — | €y|xs i }|j                  dd«      }|dk(  st        | t        «      ryt        | t        «      ryt        | t        «      r| j                  «       S | r5t        | t        «      st        | t        «      rt        j                  | «      S y)aã  
    Extract output content from response objects based on their type.

    This utility function handles the type-specific logic for converting
    various response objects into appropriate output formats for Langfuse logging.

    Args:
        response_obj: The response object returned by the function
        kwargs: Optional keyword arguments containing call_type and other metadata

    Returns:
        The formatted output content suitable for Langfuse logging, or None
    NÚ Ú	call_typeÚ	embeddingzembedding-outputzspeech-output)
ÚgetÚ
isinstancer   r
   r   Úmodel_dump_jsonÚdictÚlistÚjsonÚdumps)r   r   r   s      ú{/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/integrations/langfuse/langfuse_otel_attributes.pyÚget_output_content_by_typer"      sŽ   € ð6 ÐØàŠ\�r€FØ—z‘z +¨tÓ4€Ið �KÒ¤:¨lÔ<MÔ#NØ!ô �,Ô :Ô;Øä�,¤	Ô*Ø×+Ñ+Ó-Ð-áœ L´$Ô7¼:ÀlÔTXÔ;YÜ�z‰z˜,Ó'Ð'àó    c                   óV   — e Zd Zeedddeeef   fd„«       «       Zeedd„«       «       Z	y)ÚLangfuseLLMObsOTELAttributesÚspanr   r   c                 óò   — d|j                  d«      i}|j                  di «      }|j                  d«      }|j                  d«      }|�||d<   |�||d<   |}t        | dt        j                  |«      «       y )NÚmessagesÚoptional_paramsÚ	functionsÚtoolszlangfuse.observation.input)r   r	   r   r    )r&   r   Úpromptr)   r*   r+   Úinputs          r!   Úset_messagesz)LangfuseLLMObsOTELAttributes.set_messagesR   s‚   € ð $ V§Z¡Z°
Ó%;Ð<ˆØ!'§¡Ð,=¸rÓ!BˆØ*×.Ñ.¨{Ó;ˆ	Ø&×*Ñ*¨7Ó3ˆØÐ Ø"+ˆF�;ÑØÐØ#ˆF�7‰OàˆÜ˜4Ð!=¼t¿z¹zÈ%Ó?PÕQr#   c                 ó0   — t        | dt        |«      «       y )Nzlangfuse.observation.output)r	   r"   )r&   r   s     r!   Úset_response_output_messagesz9LangfuseLLMObsOTELAttributes.set_response_output_messagesa   s   € ô 	ØØ)Ü& |Ó4õ	
r#   N)r&   r   )
Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r   Ústrr   r.   r0   © r#   r!   r%   r%   Q   sR   „ ØØðR˜6ð R¨4°°S°©>ò Ró ó ðRð Øò
ó ó ñ
r#   r%   )N)Ú__doc__r   Útypingr   r   r   Úpydanticr   Útyping_extensionsr   ÚElitellm.integrations.opentelemetry_utils.base_otel_llm_obs_attributesr   r	   Úlitellm.types.llms.openair
   r   Úlitellm.types.utilsr   r   r   r   r   r   Úopentelemetry.tracer   r   r   r5   r"   r%   r6   r#   r!   ú<module>r?      sÙ   ðñó ß ,Ñ ,å Ý &÷÷ W÷÷ ñ Ý(ð %)ñ/ØØ
ñàñð ñð ñ	ð
 ñð ñð ñð !ñ!ð ñ	ð ñ
ð/ð ��c�‰N˜TÑ!ð/ð 	ó/ôd
Ð#;õ 
r#   