o
    ưi                     @   sh   d dl mZmZmZ d dlmZ d dlmZmZm	Z	 defddZ
deee ee	 f defd	d
ZdS )    )ListUnioncast)convert_content_list_to_str)AllMessageValuesAllPromptValuesOpenAITextCompletionUserMessagevaluec                 C   sD   t | trtdd | D rdS t | tr tdd | D r dS dS )Nc                 s       | ]}t |tV  qd S N
isinstanceint.0item r   [/home/app/Keep/.python/lib/python3.10/site-packages/litellm/llms/openai/completion/utils.py	<genexpr>       z.is_tokens_or_list_of_tokens.<locals>.<genexpr>Tc                 s   s,    | ]}t |totd d |D V  qdS )c                 s   r
   r   r   )r   ir   r   r   r      r   z8is_tokens_or_list_of_tokens.<locals>.<genexpr>.<genexpr>Nr   listallr   r   r   r   r      s
    
Fr   )r	   r   r   r   is_tokens_or_list_of_tokens   s   r   messagesreturnc                 C   s   t | dkr0| d d}|rt|trt|rtt|}|S d}ttt| d }||7 }|S g }| D ]}zttt|}|	| W q4 t
yR } z|d }~ww |}|S )N   r   content )lengetr   r   r   r   r   r   r   append	Exception)r   Zmessage_contentZopenai_promptr   Zprompt_str_listmer   r   r   _transform_prompt   s2   

r&   N)typingr   r   r   Z8litellm.litellm_core_utils.prompt_templates.common_utilsr   Zlitellm.types.llms.openair   r   r   r   r&   r   r   r   r   <module>   s    