
    g3fi                         d Z ddlmZmZmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ  G d d	ee	         Zy
)-Image prompt template for a multimodal model.    )AnyLiteralcast)Field)ImagePromptValueImageURLPromptValue)BasePromptTemplate)DEFAULT_FORMATTER_MAPPINGPromptTemplateFormat)run_in_executorc                        e Zd ZU dZ ee      Zeed<   	 dZe	ed<   	 de
ddf fd	Zedefd
       Zedee   fd       Zde
defdZde
defdZde
defdZde
defdZ	 ddedefdZ xZS )ImagePromptTemplater   )default_factorytemplatezf-stringtemplate_formatkwargsreturnNc                     d|vrg |d<   t        |d         h dz  }|rd| }t        |      t        |   di | y)zCreate an image prompt template.

        Raises:
            ValueError: If the input variables contain `'url'`, `'path'`, or
                `'detail'`.
        input_variables>   urlpathdetailz`input_variables for the image template cannot contain any of 'url', 'path', or 'detail'. Found: N )set
ValueErrorsuper__init__)selfr   overlapmsg	__class__s       Z/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/prompts/image.pyr   zImagePromptTemplate.__init__   sa     F*(*F$%f./03LL")% 
 S/!"6"    c                      y)zReturn the prompt type key.zimage-promptr   )r    s    r$   _prompt_typez ImagePromptTemplate._prompt_type-   s     r%   c                 
    g dS )zuGet the namespace of the LangChain object.

        Returns:
            `["langchain", "prompts", "image"]`
        )	langchainpromptsimager   )clss    r$   get_lc_namespacez$ImagePromptTemplate.get_lc_namespace2   s
     10r%   c                 :    t         | j                  di |      S )zFormat the prompt with the inputs.

        Args:
            **kwargs: Any arguments to be passed to the prompt template.

        Returns:
            A formatted string.
        	image_urlr   )r   formatr    r   s     r$   format_promptz!ImagePromptTemplate.format_prompt;   s      +$++*?*?@@r%   c                 V   K   t         | j                  di | d{         S 7 	w)Async format the prompt with the inputs.

        Args:
            **kwargs: Any arguments to be passed to the prompt template.

        Returns:
            A formatted string.
        Nr/   r   )r   aformatr2   s     r$   aformat_promptz"ImagePromptTemplate.aformat_promptF   s'       0Fv0F*FGG*Fs   )'
)c                 "   i }| j                   j                         D ]7  \  }}t        |t              rt	        | j
                     |fi |||<   3|||<   9 |j                  d      xs |j                  d      }|j                  d      s|j                  d      rd}t        |      |j                  d      xs |j                  d      }|sd}t        |      t        |t              sd}t        |      d|i}|rt        d|      |d<   |S )a  Format the prompt with the inputs.

        Args:
            **kwargs: Any arguments to be passed to the prompt template.

        Returns:
            A formatted string.

        Raises:
            ValueError: If the url is not provided.
            ValueError: If the url is not a string.
            ValueError: If `'path'` is provided in the template or kwargs.

        Example:
            ```python
            prompt.format(variable1="foo")
            ```
        r   r   znLoading images from 'path' has been removed as of 0.3.15 for security reasons. Please specify images by 'url'.r   zMust provide url.zurl must be a string.zLiteral['auto', 'low', 'high'])	r   items
isinstancestrr   r   getr   r   )	r    r   	formattedkvr   r"   r   outputs	            r$   r1   zImagePromptTemplate.formatQ   s   , 	MM'') 	!DAq!S!89M9MN  	!  !	!	! jj79==#7::fv!6;  S/!H%@x)@%CS/!#s#)CS/!!3<#$DfMF8r%   c                 L   K   t        d| j                  fi | d{   S 7 w)r5   N)r   r1   r2   s     r$   r6   zImagePromptTemplate.aformat   s$      %T4;;A&AAAAs   $"$htmlc                     t         )zReturn a pretty representation of the prompt.

        Args:
            html: Whether to return an html formatted string.

        Returns:
            A pretty representation of the prompt.
        )NotImplementedError)r    rB   s     r$   pretty_reprzImagePromptTemplate.pretty_repr   s
     "!r%   )F)__name__
__module____qualname____doc__r   dictr   __annotations__r   r   r   r   propertyr;   r'   classmethodlistr-   r
   r3   r7   r	   r1   r6   boolrE   __classcell__)r#   s   @r$   r   r      s    740Hd0",6O)66# # #( c   1c 1 1	Ac 	Ak 	A	HS 	H[ 	H00 
0d	Bc 	Bh 	B "" 
"r%   r   N)rI   typingr   r   r   pydanticr   langchain_core.prompt_valuesr   r	   r
   langchain_core.prompts.baser   langchain_core.prompts.stringr   r   langchain_core.runnablesr   r   r   r%   r$   <module>rW      s8    3 % %  P P : 5J",X6 J"r%   