o
    ưi                     @   s   U d dl mZmZ er!ddlmZmZ d dlmZmZ d dl	m
Z
 d dlmZ ddlmZ dZee ed	< dZed
 ed< deddfddZdedefddZ						dddZejjeiZg dZdS )    )TYPE_CHECKINGOptional   )PromptManagerPromptTemplate)PromptLiteLLMParams
PromptSpec)CustomPromptManagement)SupportedPromptIntegrations)DotpromptManagerNglobal_prompt_directoryr   global_prompt_manager	directoryreturnc                 C   s   ddl }| |_dS )z
    Set the global prompt directory for dotprompt files.

    Args:
        directory: Path to directory containing .prompt files
    r   N)litellmr   )r   r    r   ^/home/app/Keep/.python/lib/python3.10/site-packages/litellm/integrations/dotprompt/__init__.pyset_global_prompt_directory   s   
r   dotprompt_contentc                 C   s.   ddl m} | }|| \}}| |dS )z
    Get the prompt data from the dotprompt content.

    The UI stores prompts under `dotprompt_content` in the database. This function parses the content and returns the prompt data in the format expected by the prompt manager.
    r   )r   )contentmetadata)prompt_managerr   Z_parse_frontmatterstrip)r   r   Ztemp_managerr   r   r   r   r   '_get_prompt_data_from_dotprompt_content   s   r   litellm_paramsr   prompt_specr   r	   c           	   
   C   s   t | dd}t | dd}t | dd}|rtdt | dd}t | dd}|r.|s.|s.t|}zt||||d}|W S  tyG } z|d}~ww )	z2
    Initialize a prompt from a .prompt file.
    prompt_directoryNprompt_data	prompt_idzgCannot set prompt_directory when working with prompt_initializer. Needs to be a specific dotprompt fileprompt_filer   )r   r   r   r   )getattr
ValueErrorr   r   	Exception)	r   r   r   r   r   r   r   Zdot_prompt_managerer   r   r   prompt_initializer.   s.   r$   )r   r   r   r   r   r   )r   r   r   r   r   r	   )typingr   r   r   r   r   Z"litellm.types.prompts.init_promptsr   r   Z-litellm.integrations.custom_prompt_managementr	   r
   Zdotprompt_managerr   r   str__annotations__r   r   dictr   r$   Z
DOT_PROMPTvalueZprompt_initializer_registry__all__r   r   r   r   <module>   s*    
$