
    j              	       T    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y)
    )BinaryIOUnionN   )
StreamInfo)promptfile_streamstream_inforeturnc                   ||j                         dk(  rd}|j                  }|s)t        j                  d|j                  xs dz         \  }}|sd}| j                         }	 t        j                  | j                               j                  d      }	 | j                  |       d| d| }
dd	|d
dd|
idgdg}|j                  j                  j                  ||      }|j                  d   j                   j"                  S # t        $ r}	Y d }	~	| j                  |       y d }	~	ww xY w# | j                  |       w xY w)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                c/root/aria/tools/markitdown-venv/lib/python3.12/site-packages/markitdown/converters/_llm_caption.pyllm_captionr1      sW    ~2-; ''L#..x;;P;P;VTV/WXa1  G"''(8(8(:;BB7K 	! |nH\N;H
 0'x"	
H  {{&&--EH-MHA&&...5  ! 	!s$   $2D
 
	D.D1 )D..D1 1E)	typingr   r   r   r   _stream_infor   strr1        r0   <module>r7      s>    "   % NR+/+/(2+/
49+/r6   