
    i                         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ZdedefdZ	 	 	 	 	 	 ddZej,                  j.                  eiZg dZy)    )TYPE_CHECKINGOptional   )PromptManagerPromptTemplate)PromptLiteLLMParams
PromptSpec)CustomPromptManagement)SupportedPromptIntegrations)DotpromptManagerNglobal_prompt_directoryr   global_prompt_manager	directoryreturnc                     ddl }| |_        y)z
    Set the global prompt directory for dotprompt files.

    Args:
        directory: Path to directory containing .prompt files
    r   N)litellmr   )r   r   s     x/Users/manta/Documents/Projects/TheRoad-I1/.venv/lib/python3.12/site-packages/litellm/integrations/dotprompt/__init__.pyset_global_prompt_directoryr      s     &/G#    dotprompt_contentc                 j    ddl m}  |       }|j                  |       \  }}|j                         |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   _parse_frontmatterstrip)r   r   temp_managerr   r   s        r   '_get_prompt_data_from_dotprompt_contentr      s9     . !?L$778IJHg }}H==r   c                 
   t        | dd      }t        | dd      }t        | dd      }|rt        d      t        | dd      }t        | dd      }|r|s|st        |      }	 t        ||||      }|S # t        $ r}|d}~ww xY 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)	litellm_paramsprompt_specr    r!   r"   r#   r   dot_prompt_manageres	            r   prompt_initializerr+   -   s     ~/A4H.->KT:Iu
 	
 .->K  0CTJ[=>OP
--##	
 "! s   !A2 2	B;A==B)r   r   r   r   r   r   )r'   r   r(   r	   r   r
   )typingr   r   r   r   r   "litellm.types.prompts.init_promptsr   r	   -litellm.integrations.custom_prompt_managementr
   r   dotprompt_managerr   r   str__annotations__r   r   dictr   r+   
DOT_PROMPTvalueprompt_initializer_registry__all__ r   r   <module>r8      s    * *=RT J / *. # -37 x0 7	03 	04 	0>s >t > )8DF  **002D 
r   