
    %j              	       \    d dl mZmZ d dlZd dlZddlmZ dddedededef         fd	ZdS )
    )BinaryIOUnionN   )
StreamInfo)promptfile_streamstream_inforeturnc                   ||                                 dk    rd}|j        }|s!t          j        d|j        pdz             \  }}|sd}|                                 }	 t          j        |                                           	                    d          }n-# t          $ r }	Y d }	~	|                     |           d S d }	~	ww xY w	 |                     |           n# |                     |           w xY wd| d| }
dd	|d
dd|
idgdg}|j        j                            ||          }|j        d         j        j        S )N z(Write a detailed caption for this image._dummyzapplication/octet-streamzutf-8zdata:z;base64,usertext)typer   	image_urlurl)r   r   )rolecontent)modelmessagesr   )stripmimetype	mimetypes
guess_type	extensiontellbase64	b64encodereaddecode	Exceptionseekchatcompletionscreatechoicesmessager   )r   r	   clientr   r   content_type_cur_posbase64_imageedata_urir   responses                j/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/markitdown/converters/_llm_caption.pyllm_captionr1      s    ~2--; 'L Y#.x;;P;VTV/WXXa 21   G"'(8(8(:(:;;BB7KK   ttt!!!!! 	 	!!!!!!!! <|;;\;;H
 00'x" 	
 	
H  {&--EH-MMHA&..s*    9B C 
C$C ?CC C5)	typingr   r   r   r   _stream_infor   strr1        r0   <module>r7      s    " " " " " " " "      % % % % % % NR+/ +/ +/+/(2+/
49+/ +/ +/ +/ +/ +/r6   