
    "iS                        S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
Jr  S SKJrJrJrJrJrJrJrJrJrJrJrJr  S SKrS SKJr  S SKJr  \R<                  S:  a	  S S	KJrJ r   OS S	K!JrJ r   S S
K"J#r#   \#RH                  " S5      r%S SK'r'S SK(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrD  \" S5      rE " S S5      rFSrG " S S\F5      rH " S S\F5      rIS\\\\4\4         S\ \4   4S jrJS\\\\\K\4   \64         S\ \6   4S jrLS!S\\\\\K\4   \@\4         S\ \@   4S jjrMS\\\K\	4      S\\S4   4S jrNS\\K   S\K4S  jrOg! \#RL                   a    Sr% Nf = f)"    N)sha256)PathLike)Path)AnyCallableDictListLiteralMappingOptionalSequenceTypeTypeVarUnionoverload)JsonSchemaValue)convert_function_to_tool)   	   )AsyncIteratorIterator)metadataollamaz0.0.0)ChatRequestChatResponseCopyRequestCreateRequestDeleteRequestEmbeddingsRequestEmbeddingsResponseEmbedRequestEmbedResponseGenerateRequestGenerateResponseImageListResponseMessageOptionsProcessResponseProgressResponsePullRequestPushRequestResponseErrorShowRequestShowResponseStatusResponseToolWebFetchRequestWebFetchResponseWebSearchRequestWebSearchResponseTc                   Z    \ rS rSr SSSSS.S\\   S\S\S\\\\4      S	S4
S
 jjjr	Sr
g)
BaseClientN   NT)follow_redirectstimeoutheadershostr:   r;   r<   returnc                8   0 U=(       d    0 ESSS[          S[        R                  " 5        S[        R                  " 5       R	                  5        S[        R
                  " 5        3S.ER                  5        VVs0 s H  u  pxUc  M
  UR	                  5       U_M     nnn[        R                  " SS5      n	UR                  S	5      (       d  U	(       a  S
U	 3US	'   U" S[        U=(       d    [        R                  " S5      5      UUUS.UD6U l        gs  snnf )z
Creates a httpx client. Default parameters are the same as those defined in httpx
except for the following:
- `follow_redirects`: True
- `timeout`: None
`kwargs` are passed to the httpx client.
zapplication/jsonzollama-python/z ( z	) Python/)zContent-TypeAcceptz
User-AgentNOLLAMA_API_KEYauthorizationBearer OLLAMA_HOST)base_urlr:   r;   r<    )__version__platformmachinesystemlowerpython_versionitemsosgetenvget_parse_host_client)
selfclientr=   r:   r;   r<   kwargskvapi_keys
             P/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/ollama/_client.py__init__BaseClient.__init__O   s*   (=b*$&{m2h6F6F6H5I8??K\KbKbKdJeenow  pG  pG  pI  oJ  K	
 		$! 
 aggil  	 ii($/G;;''G#*7)!4go 4;299]#;<'	
 	DL	s   <	D	D)rS   N)__name__
__module____qualname____firstlineno__r   strboolr   r   r[   __static_attributes__rG       rZ   r8   r8   N   se     &
 "+/& 3-&
 & & gc3h'(& & &re   r8   zxFailed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/downloadc            %         ^  \ rS rSrSPS\\   SS4U 4S jjjrS r\SS.S	\	\
   S
\S   S\
4S jj5       r\SS.S	\	\
   S
\S   S\\
   4S jj5       r\SS.S	\	\
   S
\S\\
\\
   4   4S jj5       rSS.S	\	\
   S
\S\\
\\
   4   4S jjr\   SQSSSSSSSSSSSSS.S\S\S\S\S\S\\\      S
\S   S\\   S\\   S\\   S\S\\\S   \4      S\\\\\\4         S\\\\\4   \4      S \\\\4      S\4 S! jjj5       r\   SQSSSSSSSSSSSSS.S\S\S\S\S\S\\\      S
\S   S\\   S\\   S\\   S\S\\\S   \4      S\\\\\\4         S\\\\\4   \4      S \\\\4      S\\   4 S" jjj5       r   SRSSSSSSSSSSSSS.S\S\\   S\\   S\\   S\\   S\\\      S
\S\\   S\\   S\\   S\\   S\\\S   \4      S\\\\\\4         S\\\\\4   \4      S \\\\4      S\\\\   4   4 S# jjjr\  SSSSSSSSSSS$.S\S%\\\\\\4   \4         S&\\\\\\4   \\4         S
\S   S\\\\S'   4      S\\   S\\   S\\\S   \4      S\\\\\4   \4      S \\\\4      S\4S( jjj5       r\  SSSSSSSSSSS$.S\S%\\\\\\4   \4         S&\\\\\\4   \\4         S
\S   S\\\\S'   4      S\\   S\\   S\\\S   \4      S\\\\\4   \4      S \\\\4      S\\   4S) jjj5       r  SSSSSSSSSSS$.S\S%\\\\\\4   \4         S&\\\\\\4   \\4         S
\S\\\\S'   4      S\\   S\\   S\\\S   \4      S\\\\\4   \4      S \\\\4      S\\\\   4   4S* jjjr      STS\S+\\\\   4   S,\\   S\\\\\4   \4      S \\\\4      S-\\   S\ 4S. jjr!    SUS\S\\   S\\\\\4   \4      S \\\\4      S\"4
S/ jjr#\SSS0.S\S1\S
\S   S\$4S2 jj5       r%\SSS0.S\S1\S
\S   S\\$   4S3 jj5       r%SSS0.S\S1\S
\S\\$\\$   4   4S4 jjr%\SSS0.S\S1\S
\S   S\$4S5 jj5       r&\SSS0.S\S1\S
\S   S\\$   4S6 jj5       r&SSS0.S\S1\S
\S\\$\\$   4   4S7 jjr&\         SVSS.S\S8\\   S9\\   S:\\'\\4      S;\\'\\4      S\\   S<\\\\(\   4      S\\   S=\\\\\4   \4      S%\\\\\\4   \4         S
\S   S\$4S> jjj5       r)\         SVSS.S\S8\\   S9\\   S:\\'\\4      S;\\'\\4      S\\   S<\\\\(\   4      S\\   S=\\\\\4   \4      S%\\\\\\4   \4         S
\S   S\\$   4S? jjj5       r)         SVSS.S\S8\\   S9\\   S:\\'\\4      S;\\'\\4      S\\   S<\\\\(\   4      S\\   S=\\\\\4   \4      S%\\\\\\4   \4         S
\S\\$\\$   4   4S@ jjjr)SA\\\*4   S\4SB jr+S\,4SC jr-S\S\.4SD jr/SE\SF\S\.4SG jr0S\S\14SH jr2S\34SI jr4SWSJ\SK\S\54SL jjr6SM\S\74SN jr8SOr9U =r:$ )XClient{   Nr=   r>   c                 F   > [         TU ]  " [        R                  U40 UD6  g r]   )superr[   httpxrg   rT   r=   rV   	__class__s      rZ   r[   Client.__init__|   s    	GU\\4262re   c                 H    U R                   R                  " U0 UD6nUR                  5         U$ ! [        R                   a:  n[        UR                  R                  UR                  R                  5      S eS nAf[        R                   a    [        [        5      S ef = fr]   rS   requestraise_for_statusrk   HTTPStatusErrorr-   responsetextstatus_codeConnectErrorConnectionErrorCONNECTION_ERROR_MESSAGErT   argsrV   res        rZ   _request_rawClient._request_raw   s    @
,,


/
/ah   M!**//1::+A+ABL @454?@s   -0 B!5A99(B!Fstreamclsr   c                    g r]   rG   rT   r   r   r{   rV   s        rZ   _requestClient._request   s     re   Tc                    g r]   rG   r   s        rZ   r   r      s     re   c                    g r]   rG   r   s        rZ   r   r      s     "re   c          	         ^ ^^^ U(       a  UUUU 4S jnU" 5       $ T" S0 T R                   " T0 TD6R                  5       D6$ )Nc               3   &  >#    TR                   R                  " T0 TD6 n  U R                  5         U R                  5        HF  n[        R                  " U5      nUR                  S5      =n(       a  [        U5      eT" S0 UD6v   MH     S S S 5        g ! [        R                   aT  nUR
                  R                  5         [        UR
                  R                  UR
                  R                  5      S eS nAff = f! , (       d  f       g = f7fNerrorrG   )rS   r   rr   rk   rs   rt   readr-   ru   rv   
iter_linesjsonloadsrQ   	r|   r}   lineparterrr{   r   rV   rT   s	        rZ   innerClient._request.<locals>.inner   s     \\  $1&1QS 
 llnd::d#Dhhw''s'!#&&++	 % 21 && SJJOO

1G1GHdRS 21s@   DD BAD 	DC=)AC88C==D  
D
DrG   r~   r   rT   r   r   r{   rV   r   s   `` `` rZ   r   r      sB       Wn;""D3F388:;;re    rK   templatecontextr   thinklogprobstop_logprobsrawformatimagesoptions
keep_alivemodelpromptsuffixrK   r   r   r   r   r   r   r   r   r   r   r   r   c                    g r]   rG   rT   r   r   r   rK   r   r   r   r   r   r   r   r   r   r   r   s                   rZ   generateClient.generate   s    & re   c                    g r]   rG   r   s                   rZ   r   r      s    & $'re   c                    U R                  [        SS[        UUUUUUUUU	U
UUU(       a  [        [	        U5      5      OSUUS9R                  SS9US9$ )a  
Create a response using the requested model.

Raises `RequestError` if a model is not provided.

Raises `ResponseError` if the request could not be fulfilled.

Returns `GenerateResponse` if `stream` is `False`, otherwise returns a `GenerateResponse` generator.
POST/api/generateNr   r   r   rK   r   r   r   r   r   r   r   r   r   r   r   Texclude_noner   r   r   r$   r#   list_copy_images
model_dumpr   s                   rZ   r   r      sw    : ==!-3tL()  	

%+   re   toolsr   r   r   r   r   r   r   messagesr   lowmediumhighc                    g r]   rG   rT   r   r   r   r   r   r   r   r   r   r   s              rZ   chatClient.chat  s     re   c                    g r]   rG   r   s              rZ   r   r   .  s      #re   c                    U R                  [        SS[        U[        [	        U5      5      [        [        U5      5      UUUUUU	U
S9
R                  SS9US9$ )a  
Create a chat response using the requested model.

Args:
  tools:
    A JSON schema as a dict, an Ollama Tool or a Python Function.
    Python functions need to follow Google style docstrings to be converted to an Ollama Tool.
    For more information, see: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
  stream: Whether to stream the response.
  format: The format of the response.

Example:
  def add_two_numbers(a: int, b: int) -> int:
    '''
    Add two numbers together.

    Args:
      a: First number to add
      b: Second number to add

    Returns:
      int: The sum of a and b
    '''
    return a + b

  client.chat(model='llama3.2', tools=[add_two_numbers], messages=[...])

Raises `RequestError` if a model is not provided.

Raises `ResponseError` if the request could not be fulfilled.

Returns `ChatResponse` if `stream` is `False`, otherwise returns a `ChatResponse` generator.
r   	/api/chat
r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   r   r   _copy_messages_copy_toolsr   r   s              rZ   r   r   >  so    ^ ==nX./;u%&! 	

%!   re   inputtruncate
dimensionsc                 `    U R                  [        SS[        UUUUUUS9R                  SS9S9$ Nr   z
/api/embed)r   r   r   r   r   r   Tr   r   r   r"   r!   r   rT   r   r   r   r   r   r   s          rZ   embedClient.embed  sK     == 	

%   re   c                 \    U R                  [        SS[        UUUUS9R                  SS9S9$ )!
Deprecated in favor of `embed`.
r   /api/embeddingsr   r   r   r   Tr   r   r   r    r   r   rT   r   r   r   r   s        rZ   
embeddingsClient.embeddings  sE     ==	
 	

%  
 
re   insecurer   r   c                    g r]   rG   rT   r   r   r   s       rZ   pullClient.pull       re   c                    g r]   rG   r   s       rZ   r   r          $'re   c                \    U R                  [        SS[        UUUS9R                  SS9US9$ )
Raises `ResponseError` if the request could not be fulfilled.

Returns `ProgressResponse` if `stream` is `False`, otherwise returns a `ProgressResponse` generator.
r   	/api/pullr   r   r   Tr   r   r   r*   r+   r   r   s       rZ   r   r     E     == 	

%  
 
re   c                    g r]   rG   r   s       rZ   pushClient.push  r   re   c                    g r]   rG   r   s       rZ   r   r     r   re   c                \    U R                  [        SS[        UUUS9R                  SS9US9$ )r   r   	/api/pushr   Tr   r   r   r*   r,   r   r   s       rZ   r   r     r   re   quantizefrom_filesadapterslicense
parametersc                    g r]   rG   rT   r   r   r   r   r   r   r   rK   r   r   r   s               rZ   createClient.create  s     re   c                    g r]   rG   r   s               rZ   r   r     s     $'re   c                l    U R                  [        SS[        UUUUUUUUUU	U
S9R                  SS9US9$ )r   r   /api/creater   r   r   r   r   r   r   r   rK   r   r   Tr   r   r   r*   r   r   r   s               rZ   r   r   #  s]    ( == 	

%#   re   pathc                 \   [        5       n[        US5       n UR                  S5      nU(       d  OUR                  U5        M,  S S S 5        SUR	                  5        3n[        US5       nU R                  SSU 3US9  S S S 5        U$ ! , (       d  f       NL= f! , (       d  f       U$ = f)Nrb   sha256:r   /api/blobs/content)r   openr   update	hexdigestr~   )rT   r  	sha256sumr|   chunkdigests         rZ   create_blobClient.create_blobK  s    I	dD	Qy!
	  
 y**,-.F	dD	Q
+fX 6B 
 M 
	 
	 Ms   .B,B
B
B+c                 0    U R                  [        SS5      $ NGETz	/api/tagsr   r&   rT   s    rZ   r   Client.list[  s    == re   c                     U R                  SS[        US9R                  SS9S9n[        UR                  S:X  a  SS
9$ S	S
9$ NDELETEz/api/deleter   Tr   r      successr   statusr~   r   r   r0   rv   rT   r   r|   s      rZ   deleteClient.deleteb  s^    

% 	 	A --3.Y 4; re   sourcedestinationc           	          U R                  SS[        UUS9R                  SS9S9n[        UR                  S:X  a  SS
9$ S	S
9$ Nr   z	/api/copy)r$  r%  Tr   r   r  r  r   r  r~   r   r   r0   rv   rT   r$  r%  r|   s       rZ   copyClient.copyn  sc     	

% 	 	A --3.Y 4; re   c           	      V    U R                  [        SS[        US9R                  SS9S9$ Nr   z	/api/showr  Tr   r   r   r/   r.   r   rT   r   s     rZ   showClient.show{  s8    ==

%   re   c                 0    U R                  [        SS5      $ Nr  z/api/psr   r)   r  s    rZ   ps	Client.ps  s    == re   querymax_resultsc           
          U R                   R                  R                  SS5      R                  S5      (       d  [	        S5      eU R                  [        SS[        UUS9R                  SS	9S
9$ )a  
Performs a web search

Args:
  query: The query to search for
  max_results: The maximum number of results to return (default: 3)

Returns:
  WebSearchResponse with the search results
Raises:
  ValueError: If OLLAMA_API_KEY environment variable is not set
rC   r   rD   zAAuthorization header with Bearer token is required for web searchr   !https://ollama.com/api/web_searchr7  r8  Tr   r   )	rS   r<   rQ   
startswith
ValueErrorr   r5   r4   r   rT   r7  r8  s      rZ   
web_searchClient.web_search  ss     <<##OR8CCINNZ[[==) 	

%   re   urlc           	          U R                   R                  R                  SS5      R                  S5      (       d  [	        S5      eU R                  [        SS[        US9R                  SS	9S
9$ )
Fetches the content of a web page for the provided URL.

Args:
  url: The URL to fetch

Returns:
  WebFetchResponse with the fetched result
rC   r   rD   z@Authorization header with Bearer token is required for web fetchr    https://ollama.com/api/web_fetchrA  Tr   r   )	rS   r<   rQ   r<  r=  r   r3   r2   r   rT   rA  s     rZ   	web_fetchClient.web_fetch  sn     <<##OR8CCINNYZZ==(

%   re   rG   r]   r   r   r   r   NNr   Nr   r   NNNNr   NNN	NNNNNNNNNr   );r^   r_   r`   ra   r   rb   r[   r~   r   r   r6   r
   r   r   rc   r   r   intr   bytesr%   r   r   r(   floatr$   r   r'   r1   r   r   r   r"   r   r    r   r*   r   r   r   r	   r   r   r  r&   r   r0   r"  r*  r/   r0  r)   r5  r5   r?  r3   rG  rd   __classcell__rm   s   @rZ   rg   rg   {   s   38C= 3d 3 3@ 
 #		a EN	 	  
 !		a DM	 {  
 	"	a" 	" Q^" " 	<	a< 	< Q^<6  	 '+" #"&DH;?;?.2#  	   hsm$ EN D> tn 3- 
 U7:.?@A XeC$5678  eGCH-w678!" ucz*+#$ % (  	' '+  #"&DH;?;?.2#'' ' 	' ' ' hsm$' DM' D>' tn' 3-' 
' U7:.?@A' XeC$5678'  eGCH-w678!'" ucz*+#'$  !%' ',   	3 !"'+ #"&DH;?;?.2#33 SM3 SM	3 SM3 sm3 hsm$3 3 D>3 tn3 3-3 
$3 U7:.?@A3 XeC$56783  eGCH-w678!3" ucz*+#3$ x(899:%3j  FJ
 KO"EI#"&DH;?.2 xgc3h&7&@ ABC
 HU738#4dH#DEFG EN E$(? @@AB tn 3- U7:.?@A eGCH-w678 ucz*+    FJ#
 KO EI#"&DH;?.2## xgc3h&7&@ ABC#
 HU738#4dH#DEFG# DM# E$(? @@AB# tn# 3-# U7:.?@A# eGCH-w678# ucz*+# # #" FJ@
 KOEI#"&DH;?.2@@ xgc3h&7&@ ABC@
 HU738#4dH#DEFG@ @ E$(? @@AB@ tn@ 3-@ U7:.?@A@ eGCH-w678@ ucz*+@ \8L112@H ')#;?.2 $ hsm#$ tn	
 eGCH-w678 ucz*+  2  ;?.2 SM eGCH-w678	
 ucz*+ , 
 " 	
 EN   
  '' 	'
 DM'  !' '  	
  x(899:0 
 " 	
 EN   
  '' 	'
 DM'  !' '  	
  x(899:0  #&*)-"/3 >BFJ # sm C=	
 DcN# tCH~& sm eCcN+, SM wsCx0'9:; xgc3h&7&@ ABC EN     #&*)-"/3 >BFJ' !'' sm' C=	'
 DcN#' tCH~&' sm' eCcN+,' SM' wsCx0'9:;' xgc3h&7&@ ABC' DM'  !' '& #&*)-"/3 >BFJ& && sm& C=	&
 DcN#& tCH~&& sm& eCcN+,& SM& wsCx0'9:;& xgc3h&7&@ ABC& & x(899:&PeCI. 3  L 
# 
. 
 3 >   / c  <M 43 #3  re   rg   c            %         ^  \ rS rSrSPS\\   SS4U 4S jjjrS r\SS.S	\	\
   S
\S   S\
4S jj5       r\SS.S	\	\
   S
\S   S\\
   4S jj5       r\SS.S	\	\
   S
\S\\
\\
   4   4S jj5       rSS.S	\	\
   S
\S\\
\\
   4   4S jjrSQS\S\S\4S jjrS\S\4S jr\   SRSSSSSSSSSSSSS.S\S\S\S\S\S\\\      S
\S   S\\\\S   4      S\\   S \\   S!\S"\\\S#   \4      S$\\\\\\4         S%\\\\\4   \4      S&\\\\4      S\4 S' jjj5       r\   SRSSSSSSSSSSSSS.S\S\S\S\S\S\\\      S
\S   S\\\\S   4      S\\   S \\   S!\S"\\\S#   \4      S$\\\\\\4         S%\\\\\4   \4      S&\\\\4      S\\   4 S( jjj5       r   SSSSSSSSSSSSSSS.S\S\\   S\\   S\\   S\\   S\\\      S
\S\\\\S   4      S\\   S \\   S!\\   S"\\\S#   \4      S$\\\\\\4         S%\\\\\4   \4      S&\\\\4      S\\\\   4   4 S) jjjr\  STSSSSSSSSS*.S\S+\\\\\\4   \4         S,\\\\\\4   \ \!4         S
\S   S\\\\S   4      S\\   S \\   S"\\\S#   \4      S%\\\\\4   \4      S&\\\\4      S\"4S- jjj5       r#\  STSSSSSSSSS*.S\S+\\\\\\4   \4         S,\\\\\\4   \ \!4         S
\S   S\\\\S   4      S\\   S \\   S"\\\S#   \4      S%\\\\\4   \4      S&\\\\4      S\\"   4S. jjj5       r#  STSSSSSSSSS*.S\S+\\\\\\4   \4         S,\\\\\\4   \ \!4         S
\S\\\\S   4      S\\   S \\   S"\\\S#   \4      S%\\\\\4   \4      S&\\\\4      S\\"\\"   4   4S/ jjjr#      SUS\S0\\\\   4   S1\\   S%\\\\\4   \4      S&\\\\4      S2\\   S\$4S3 jjr%    SVS\S\\   S%\\\\\4   \4      S&\\\\4      S\&4
S4 jjr'\SSS5.S\S6\S
\S   S\(4S7 jj5       r)\SSS5.S\S6\S
\S   S\\(   4S8 jj5       r)SSS5.S\S6\S
\S\\(\\(   4   4S9 jjr)\SSS5.S\S6\S
\S   S\(4S: jj5       r*\SSS5.S\S6\S
\S   S\\(   4S; jj5       r*SSS5.S\S6\S
\S\\(\\(   4   4S< jjr*\         SWSS.S\S=\\   S>\\   S?\\+\\4      S@\\+\\4      S\\   SA\\\\,\   4      S\\   SB\\\\\4   \4      S+\\\\\\4   \4         S
\S   S\(4SC jjj5       r-\         SWSS.S\S=\\   S>\\   S?\\+\\4      S@\\+\\4      S\\   SA\\\\,\   4      S\\   SB\\\\\4   \4      S+\\\\\\4   \4         S
\S   S\\(   4SD jjj5       r-         SWSS.S\S=\\   S>\\   S?\\+\\4      S@\\+\\4      S\\   SA\\\\,\   4      S\\   SB\\\\\4   \4      S+\\\\\\4   \4         S
\S\\(\\(   4   4SE jjjr-SF\\\.4   S\4SG jr/S\04SH jr1S\S\24SI jr3SJ\SK\S\24SL jr4S\S\54SM jr6S\74SN jr8SOr9U =r:$ )XAsyncClienti  Nr=   r>   c                 F   > [         TU ]  " [        R                  U40 UD6  g r]   )rj   r[   rk   rV  rl   s      rZ   r[   AsyncClient.__init__  s    	GU&&77re   c                 d  #     U R                   R                  " U0 UD6I S h  vN nUR                  5         U$  N! [        R                   a:  n[        UR                  R                  UR                  R                  5      S eS nAf[        R                   a    [        [        5      S ef = f7fr]   rp   rz   s        rZ   r~   AsyncClient._request_raw  s     @$$d5f5
5ah 6    M!**//1::+A+ABL @454?@s1   B0< :< B0< B-5B(B--B0Fr   r   r   c                   #    g 7fr]   rG   r   s        rZ   r   AsyncClient._request  s
         Tc                   #    g 7fr]   rG   r   s        rZ   r   r\    
      r]  c                   #    g 7fr]   rG   r   s        rZ   r   r\    s
      $'r]  c          	         ^ ^^^#    U(       a  UUUU 4S jnU" 5       $ T" S0 T R                   " T0 TD6I S h  vN R                  5       D6$  N7f)Nc                   >#    TR                   R                  " T0 TD6 IS h  vN n  U R                  5         U R                  5         S h  vN n[        R                  " U5      nUR                  S5      =n(       a  [        U5      eT" S0 UD67v   MO   Nt! [        R                   a]  nUR
                  R                  5       I S h  vN    [        UR
                  R                  UR
                  R                  5      S eS nAff = f N
 S S S 5      IS h  vN    g ! , IS h  vN  (       d  f       g = f7fr   )rS   r   rr   rk   rs   rt   areadr-   ru   rv   aiter_linesr   r   rQ   r   s	        rZ   r   #AsyncClient._request.<locals>.inner  s     <<&&7771S 
 MMO D::d#Dhhw''s'!#&&++ 8 && S**""$$$

1G1GHdRSO 877777s   !D>BD>D$BD$
DDDAD$D>D/DC:DDD$DD$D>D D>$D;*D-+D;7D>rG   r   r   s   `` `` rZ   r   r\    sK        WnC))4:6::@@BCC:s   1AAAr7  r8  c           
      t   #    U R                  [        SS[        UUS9R                  SS9S9I Sh  vN $  N7f)z
Performs a web search

Args:
  query: The query to search for
  max_results: The maximum number of results to return (default: 3)

Returns:
  WebSearchResponse with the search results
r   r:  r;  Tr   r   N)r   r5   r4   r   r>  s      rZ   r?  AsyncClient.web_search  sL      ) 	

%     s   /868rA  c           	      r   #    U R                  [        SS[        US9R                  SS9S9I Sh  vN $  N7f)rC  r   rD  rE  Tr   r   N)r   r3   r2   r   rF  s     rZ   rG  AsyncClient.web_fetch  sG      (

%        .757r   r   r   r   r   rK   r   r   r   r   r   r   r   r   r   r   r   r   c                   #    g 7fr]   rG   r   s                   rZ   r   AsyncClient.generate)  s
     & r]  c                   #    g 7fr]   rG   r   s                   rZ   r   rl  >  s
     & ),r]  c                   #    U R                  [        SS[        UUUUUUUUU	U
UUU(       a  [        [	        U5      5      OSUUS9R                  SS9US9I Sh  vN $  N7f)a  
Create a response using the requested model.

Raises `RequestError` if a model is not provided.

Raises `ResponseError` if the request could not be fulfilled.

Returns `GenerateResponse` if `stream` is `False`, otherwise returns an asynchronous `GenerateResponse` generator.
r   r   Nr   Tr   r   r   r   s                   rZ   r   rl  S  s     8 !-3tL()  	

%+     s   AA!AA!r   r   r   c                   #    g 7fr]   rG   r   s              rZ   r   AsyncClient.chat  s
      r]  c                   #    g 7fr]   rG   r   s              rZ   r   rp    s
      %(r]  c                   #    U R                  [        SS[        U[        [	        U5      5      [        [        U5      5      UUUUUU	U
S9
R                  SS9US9I Sh  vN $  N7f)a  
Create a chat response using the requested model.

Args:
  tools:
    A JSON schema as a dict, an Ollama Tool or a Python Function.
    Python functions need to follow Google style docstrings to be converted to an Ollama Tool.
    For more information, see: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
  stream: Whether to stream the response.
  format: The format of the response.

Example:
  def add_two_numbers(a: int, b: int) -> int:
    '''
    Add two numbers together.

    Args:
      a: First number to add
      b: Second number to add

    Returns:
      int: The sum of a and b
    '''
    return a + b

  await client.chat(model='llama3.2', tools=[add_two_numbers], messages=[...])

Raises `RequestError` if a model is not provided.

Raises `ResponseError` if the request could not be fulfilled.

Returns `ChatResponse` if `stream` is `False`, otherwise returns an asynchronous `ChatResponse` generator.
r   r   r   Tr   r   Nr   r   s              rZ   r   rp    s|     ` nX./;u%&! 	

%!     s   AA%A#A%r   r   r   c                 |   #    U R                  [        SS[        UUUUUUS9R                  SS9S9I S h  vN $  N7fr   r   r   s          rZ   r   AsyncClient.embed  sX       	

%     s   3<:<c                 x   #    U R                  [        SS[        UUUUS9R                  SS9S9I Sh  vN $  N7f)r   r   r   r   Tr   r   Nr   r   s        rZ   r   AsyncClient.embeddings  sR      	
 	

%  
 
 
 
   1:8:r   r   c                   #    g 7fr]   rG   r   s       rZ   r   AsyncClient.pull  r_  r]  c                   #    g 7fr]   rG   r   s       rZ   r   ry     
      ),r]  c                x   #    U R                  [        SS[        UUUS9R                  SS9US9I Sh  vN $  N7f)r   r   r   r   Tr   r   Nr   r   s       rZ   r   ry  )  R       	

%  
 
 
 
rw  c                   #    g 7fr]   rG   r   s       rZ   r   AsyncClient.pushA  r_  r]  c                   #    g 7fr]   rG   r   s       rZ   r   r  J  r{  r]  c                x   #    U R                  [        SS[        UUUS9R                  SS9US9I Sh  vN $  N7f)r   r   r   r   Tr   r   Nr   r   s       rZ   r   r  S  r}  rw  r   r   r   r   r   r   c                   #    g 7fr]   rG   r   s               rZ   r   AsyncClient.createk  s
      r]  c                   #    g 7fr]   rG   r   s               rZ   r   r  |  s
      ),r]  c                   #    U R                  [        SS[        UUUUUUUUUU	U
S9R                  SS9US9I Sh  vN $  N7f)r   r   r   r   Tr   r   Nr  r   s               rZ   r   r    sj     *  	

%#     s   9AA Ar  c                   ^#    [        5       n[        R                  " TS5      I S h  vN  IS h  vN n UR                  S5      I S h  vN nU(       d  OUR	                  U5        M4  S S S 5      IS h  vN   SUR                  5        3nU4S jnU R                  SSU 3U" 5       S9I S h  vN   U$  N N No NF! , IS h  vN  (       d  f       N[= f N(7f)Nr  r  r  c                   >#    [         R                  " TS5      I S h  vN  IS h  vN n  U R                  S5      I S h  vN nU(       d  OU7v   M(  S S S 5      IS h  vN   g  NG N@ N( N! , IS h  vN  (       d  f       g = f7f)Nr  r  )anyio	open_filer   )r|   r  r  s     rZ   upload_bytes-AsyncClient.create_blob.<locals>.upload_bytes  s_     tT2222ay))%+	  322) 3222sf   BA&BA(BA.A*A.B A,!B(B*A.,B.B4A75BBr   r  r  )r   r  r  r   r  r  r~   )rT   r  r  r|   r  r  r  s    `     rZ   r  AsyncClient.create_blob  s     I__T40000AffY''
	  10 y**,-.F 

Fk&$:LN

SSSM' 1' 1000" Tsr   %CB7CB9CB?B;B?+C6B=79C0C1C9C;B?=C?CCCCc                 L   #    U R                  [        SS5      I S h  vN $  N7fr  r  r  s    rZ   r   AsyncClient.list  s)           $"$c                    #    U R                  SS[        US9R                  SS9S9I S h  vN n[        UR                  S:X  a  SS
9$ S	S
9$  N!7fr  r   r!  s      rZ   r"  AsyncClient.delete  sk     

%    	A --3.Y 4; 	s   )AA"Ar$  r%  c           	         #    U R                  SS[        UUS9R                  SS9S9I S h  vN n[        UR                  S:X  a  SS
9$ S	S
9$  N!7fr'  r(  r)  s       rZ   r*  AsyncClient.copy  sp      	

%    	A --3.Y 4; 	s   *AA"Ac           	      r   #    U R                  [        SS[        US9R                  SS9S9I S h  vN $  N7fr-  r.  r/  s     rZ   r0  AsyncClient.show  sE     

%     rj  c                 L   #    U R                  [        SS5      I S h  vN $  N7fr3  r4  r  s    rZ   r5  AsyncClient.ps  s)        r  rG   r]   rO  rI  rJ  rK  rL  rM  rN  );r^   r_   r`   ra   r   rb   r[   r~   r   r   r6   r
   r   r   rc   r   rP  r5   r?  r3   rG  r   r   rQ  r%   r   r   r(   rR  r$   r   r'   r1   r   r   r   r"   r   r    r   r*   r   r   r   r	   r   r   r  r&   r   r0   r"  r*  r/   r0  r)   r5  rd   rS  rT  s   @rZ   rV  rV    s   88C= 8d 8 8@ 
 #		a EN	 	  
 !		a DM	 Q  
 	'	a' 	' Qa  !' ' 	D	aD 	D Qa  !D6C c BS * )9 &  	 '+"EI#"&DH;?;?.2#  	   hsm$ EN E$(? @@AB tn 3- 
 U7:.?@A XeC$5678  eGCH-w678!" ucz*+#$ % (  	, '+ EI#"&DH;?;?.2#,, , 	, , , hsm$, DM, E$(? @@AB, tn, 3-, 
, U7:.?@A, XeC$5678,  eGCH-w678!," ucz*+#,$ %&%, ,,   	2 !"'+EI#"&DH;?;?.2#22 SM2 SM	2 SM2 sm2 hsm$2 2 E$(? @@AB2 tn2 3-2 
$2 U7:.?@A2 XeC$56782  eGCH-w678!2" ucz*+#2$ }-=>>?%2h  FJ
 KO"EI#"&DH;?.2 xgc3h&7&@ ABC
 HU738#4dH#DEFG EN E$(? @@AB tn 3- U7:.?@A eGCH-w678 ucz*+    FJ(
 KO EI#"&DH;?.2(( xgc3h&7&@ ABC(
 HU738#4dH#DEFG( DM( E$(? @@AB( tn( 3-( U7:.?@A( eGCH-w678( ucz*+( \"( (" FJA
 KOEI#"&DH;?.2AA xgc3h&7&@ ABCA
 HU738#4dH#DEFGA A E$(? @@ABA tnA 3-A U7:.?@AA eGCH-w678A ucz*+A \=667AJ ')#;?.2 $ hsm#$ tn	
 eGCH-w678 ucz*+  2  ;?.2 SM eGCH-w678	
 ucz*+ , 
 " 	
 EN   
  ,, 	,
 DM, %&, ,  	
  }-=>>?0 
 " 	
 EN   
  ,, 	,
 DM, %&, ,  	
  }-=>>?0  #&*)-"/3 >BFJ # sm C=	
 DcN# tCH~& sm eCcN+, SM wsCx0'9:; xgc3h&7&@ ABC EN     #&*)-"/3 >BFJ, !,, sm, C=	,
 DcN#, tCH~&, sm, eCcN+,, SM, wsCx0'9:;, xgc3h&7&@ ABC, DM, %&, ,& #&*)-"/3 >BFJ' '' sm' C=	'
 DcN#' tCH~&' sm' eCcN+,' SM' wsCx0'9:;' xgc3h&7&@ ABC' ' }-=>>?'RE#t)$4  ., 
 
 
s   c l   re   rV  r   r>   c              #   t   #    U =(       d    /  H%  n[        U[        5      (       a  UO[        US9v   M'     g 7f)N)value)
isinstancer%   )r   images     rZ   r   r     s.     ||eeU++%U1CC s   68r   c              #   
  #    U =(       d    /  Hj  n[         R                  " [        U5      R                  5        VVs0 s H*  u  p#U(       d  M  X"S:X  a  [	        [        U5      5      OU_M,     snn5      v   Ml     g s  snnf 7f)Nr   )r'   model_validatedictrN   r   r   )r   messagerW   rX   s       rZ   r   r     sh     Rg

 
 DHMDWDWDY_DYDA]^7q=$|A
a7DY_   _s   ;BA= A=.Br   c              #      #    U =(       d    /  H6  n[        U5      (       a  [        U5      O[        R                  " U5      v   M8     g 7fr]   )callabler   r1   r  )r   unprocessed_tools     rZ   r   r     s=     +2+8@AQ8R8R
"#3
4X\XkXkl|X}} &s   AA	sc                     [        U [        [        45      (       a%   [        U 5      =nR                  5       (       a  U$  g g ! [         a     g f = fr]   )r  rb   r   exists	Exception)r  ps     rZ   _as_pathr    sU    C;
Aw,!			 	  
! 
  
		
s   !A 
AAr=   c                    U =(       d    SSpU R                  S5      u  p#nU(       d  SU pBOUS:X  a  SnOUS:X  a  Sn[        R                  R                  U SU 35      nUR                  =(       d    Sn UR
                  =(       d    Un [        [        R                  " U 5      [        R                  5      (       a  S	U  S
3n UR                  R                  S5      =n(       a  U SU  SU SU 3$ U SU  SU 3$ ! [         a     NEf = f)ap  
>>> _parse_host(None)
'http://127.0.0.1:11434'
>>> _parse_host('')
'http://127.0.0.1:11434'
>>> _parse_host('1.2.3.4')
'http://1.2.3.4:11434'
>>> _parse_host(':56789')
'http://127.0.0.1:56789'
>>> _parse_host('1.2.3.4:56789')
'http://1.2.3.4:56789'
>>> _parse_host('http://1.2.3.4')
'http://1.2.3.4:80'
>>> _parse_host('https://1.2.3.4')
'https://1.2.3.4:443'
>>> _parse_host('https://1.2.3.4:56789')
'https://1.2.3.4:56789'
>>> _parse_host('example.com')
'http://example.com:11434'
>>> _parse_host('example.com:56789')
'http://example.com:56789'
>>> _parse_host('http://example.com')
'http://example.com:80'
>>> _parse_host('https://example.com')
'https://example.com:443'
>>> _parse_host('https://example.com:56789')
'https://example.com:56789'
>>> _parse_host('example.com/')
'http://example.com:11434'
>>> _parse_host('example.com:56789/')
'http://example.com:56789'
>>> _parse_host('example.com/path')
'http://example.com:11434/path'
>>> _parse_host('example.com:56789/path')
'http://example.com:56789/path'
>>> _parse_host('https://example.com:56789/path')
'https://example.com:56789/path'
>>> _parse_host('example.com:56789/path/')
'http://example.com:56789/path'
>>> _parse_host('[0001:002:003:0004::1]')
'http://[0001:002:003:0004::1]:11434'
>>> _parse_host('[0001:002:003:0004::1]:56789')
'http://[0001:002:003:0004::1]:56789'
>>> _parse_host('http://[0001:002:003:0004::1]')
'http://[0001:002:003:0004::1]:80'
>>> _parse_host('https://[0001:002:003:0004::1]')
'https://[0001:002:003:0004::1]:443'
>>> _parse_host('https://[0001:002:003:0004::1]:56789')
'https://[0001:002:003:0004::1]:56789'
>>> _parse_host('[0001:002:003:0004::1]/')
'http://[0001:002:003:0004::1]:11434'
>>> _parse_host('[0001:002:003:0004::1]:56789/')
'http://[0001:002:003:0004::1]:56789'
>>> _parse_host('[0001:002:003:0004::1]/path')
'http://[0001:002:003:0004::1]:11434/path'
>>> _parse_host('[0001:002:003:0004::1]:56789/path')
'http://[0001:002:003:0004::1]:56789/path'
>>> _parse_host('https://[0001:002:003:0004::1]:56789/path')
'https://[0001:002:003:0004::1]:56789/path'
>>> _parse_host('[0001:002:003:0004::1]:56789/path/')
'http://[0001:002:003:0004::1]:56789/path'
r   i,  z://httpP   httpsi  z	127.0.0.1[]/:)	partitionurllibparseurlsplithostnameportr  	ipaddress
ip_addressIPv6Addressr=  r  strip)r=   r  scheme_hostportsplitr  s          rZ   rR   rR     s   @ zr5u-&X	tHDD
,,

6(#hZ 8
9%		&;$		t$)&&t,i.C.CDDa[d ZZc""T"XSavQtf--83tfAdV	$$ 
 s   9C> >
D
Dr]   )Pr  r   rO   rI   sysurllib.parser  hashlibr   r   pathlibr   typingr   r   r   r	   r
   r   r   r   r   r   r   r   r  pydantic.json_schemar   ollama._utilsr   version_infor   r   collections.abc	importlibr   versionrH   PackageNotFoundErrorrk   ollama._typesr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r8   ry   rg   rV  r   rb   r   r   r  rR   rG   re   rZ   <module>r     s     	  
         0 2f,,5   *+        > CL' 'T V Z D* DD(5+<"=> D8E? D
XhuWS#X5F5O/P&QR W_`gWh ~xwsCx/@$/P)Q RS ~_ghl_m ~
sH}-. 5t3D W%hsm W% W%g' $$ +s   ?E0 0FF