
    ^h                     @    S SK Jr  S SKrS SKJr   " S S\5      rS rg)    )UnionN)BaseLLMExceptionc                   V   ^  \ rS rSrS\S\S\\\R                  4   4U 4S jjr
SrU =r$ )OllamaError   status_codemessageheadersc                 "   > [         TU ]  XUS9  g )N)r   r	   r
   )super__init__)selfr   r	   r
   	__class__s       Z/home/james-whalen/.local/lib/python3.13/site-packages/litellm/llms/ollama/common_utils.pyr   OllamaError.__init__	   s     	[7S     )__name__
__module____qualname____firstlineno__intstrr   dicthttpxHeadersr   __static_attributes____classcell__)r   s   @r   r   r      s8    TT),T7<T5===P7QT Tr   r   c                 4   SSK nSSKn SSKJn  U nU R                  S5      (       a  U R                  S5      S   n  UR                  UR                  UR                  U 5      5      5      nUR                  S;   a  U $  UR                  5       nUR                  S	5      R                  US
5        UR                  S5        UR                  UR                  5       5      R!                  S5      $ ! [         a    [	        S5      ef = f! [         a    Us $ f = f)z
Convert image to base64 encoded image if not already in base64 format

If image is already in base64 format AND is a jpeg/png, return it

If image is not JPEG/PNG, convert it to JPEG base64 format
r   N)Imagez>ollama image conversion failed please run `pip install Pillow`zdata:,)JPEGPNGRGBr#   zutf-8)base64ioPILr    	Exception
startswithsplitopenBytesIO	b64decodeformatconvertsaveseek	b64encodegetvaluedecode)imager&   r'   r    orig
image_data
jpeg_images          r   _convert_imager:      s    
 D  C $ZZ

6+;+;E+B CD
/L 0 Ju"":v6OOAJ//1299'BB#  
L
 	

  s   C/ A D /DDD)typingr   r   )litellm.llms.base_llm.chat.transformationr   r   r:   r   r   r   <module>r=      s#      FT" TCr   