
    D_i                         S r SSKJrJrJr  SSKJr  SSKJrJ	r	J
r
  SSKJr  SSKJrJr  SSKJr   " S S	\\	   5      rg
)-Image prompt template for a multimodal model.    )AnyLiteralcast)Field)ImagePromptValueImageURLPromptValue)BasePromptTemplate)DEFAULT_FORMATTER_MAPPINGPromptTemplateFormat)run_in_executorc                      ^  \ rS rSr% Sr\" \S9r\\S'    Sr	\
\S'    S\SS	4U 4S
 jjr\S\4S j5       r\S\\   4S j5       rS\S\4S jrS\S\4S jrS\S\4S jrS\S\4S jr SS\S\4S jjrSrU =r$ )ImagePromptTemplate   r   )default_factorytemplatezf-stringtemplate_formatkwargsreturnNc                    > SU;  a  / US'   [        US   5      1 Sk-  nU(       a  SU 3n[        U5      e[        TU ]  " S0 UD6  g)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       V/home/james-whalen/.local/lib/python3.13/site-packages/langchain_core/prompts/image.pyr    ImagePromptTemplate.__init__   sa     F*(*F$%f./03LL")% 
 S/!"6"    c                     g)zReturn the prompt type key.zimage-promptr   )r!   s    r%   _prompt_type ImagePromptTemplate._prompt_type-   s     r'   c                 
    / SQ$ )z]Get the namespace of the LangChain object.

Returns:
    `["langchain", "prompts", "image"]`
)	langchainpromptsimager   )clss    r%   get_lc_namespace$ImagePromptTemplate.get_lc_namespace2   s
     10r'   c                 4    [        U R                  " S0 UD6S9$ )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_prompt!ImagePromptTemplate.format_prompt;   s      $++*?*?@@r'   c                 P   #    [        U R                  " S0 UD6I Sh  vN S9$  N7f)Async format the prompt with the inputs.

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

Returns:
    A formatted string.
Nr3   r   )r   aformatr6   s     r%   aformat_prompt"ImagePromptTemplate.aformat_promptF   s$       0Fv0F*FGG*Fs   &$&c                 t   0 nU R                   R                  5        H<  u  p4[        U[        5      (       a  [        U R
                     " U40 UD6X#'   M8  XBU'   M>     UR                  S5      =(       d    UR                  S5      nUR                  S5      (       d  UR                  S5      (       a  Sn[        U5      eUR                  S5      =(       d    UR                  S5      nU(       d  Sn[        U5      e[        U[        5      (       d  Sn[        U5      eSU0nU(       a  [        SU5      US'   U$ )at  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%   r5   ImagePromptTemplate.formatQ   s   , 	MM'')DA!S!!89M9MN  	  !! * jj79==#7::fv!6!6;  S/!H%@x)@%CS/!#s##)CS/!!3<#$DfMF8r'   c                 L   #    [        SU R                  40 UD6I Sh  vN $  N7f)r:   N)r   r5   r6   s     r%   r;   ImagePromptTemplate.aformat   s#      %T4;;A&AAAAs   $"$htmlc                     [         e)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!   rJ   s     r%   pretty_reprImagePromptTemplate.pretty_repr   s
     "!r'   r   )F)__name__
__module____qualname____firstlineno____doc__r   dictr   __annotations__r   r   r   r    propertyrA   r)   classmethodlistr0   r
   r7   r<   r	   r5   r;   boolrM   __static_attributes____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)rS   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>rb      s8    3 % %  P P : 5J",X6 J"r'   