
    ^=iU                       d dl mZ d dlZd dlmZmZmZ d dlmZm	Z	 d dl
Z
ddlmZ ddlmZ ddlmZmZmZmZmZmZmZ dd	lmZmZ dd
lmZ ddlmZ ddlmZm Z  ddlm!Z!m"Z" ddl#m$Z$m%Z%m&Z& er@ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z>m?Z? g dZ@ G d de%      ZA G d de&      ZB G d d      ZC G d d      ZD G d d       ZE G d! d"      ZFeAZGeBZHy)#    )annotationsN)TYPE_CHECKINGAnyMapping)Selfoverride   )_exceptionsQuerystring)OmitTimeoutNotGiven	TransportProxiesTypesRequestOptions	not_given)is_givenget_async_library)cached_property)__version__)StreamAsyncStream)	GroqErrorAPIStatusError)DEFAULT_MAX_RETRIESSyncAPIClientAsyncAPIClient)chataudiofilesmodelsbatches
embeddings)Files
AsyncFiles)ModelsAsyncModels)BatchesAsyncBatches)Chat	AsyncChat)
EmbeddingsAsyncEmbeddings)Audio
AsyncAudio)r   r   r   r   Groq	AsyncGroqClientAsyncClientc                      e Zd ZU ded<   ddeeddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZedd       Zedd       Z	edd	       Z
edd
       Zedd       Zedd       Zedd       Zedd       Zeedd              Zeedd              Zeed  fd              Zddededdddi d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZeZe	 	 	 	 	 	 	 	 d"d       Z xZS )#r1   strapi_keyNFr7   base_urltimeoutmax_retriesdefault_headersdefault_queryhttp_client_strict_response_validationc          
         |t         j                  j                  d      }|t        d      || _        |t         j                  j                  d      }|d}t
        	|   t        |||||||       y)zConstruct a new synchronous Groq client instance.

        This automatically infers the `api_key` argument from the `GROQ_API_KEY` environment variable if it is not provided.
        NGROQ_API_KEYThe api_key client option must be set either by passing api_key to the client or by setting the GROQ_API_KEY environment variableGROQ_BASE_URLhttps://api.groq.comversionr9   r;   r:   r>   custom_headerscustom_queryr?   osenvirongetr   r7   super__init__r   
selfr7   r9   r:   r;   r<   r=   r>   r?   	__class__s
            I/home/rose/Desktop/poly/venv/lib/python3.12/site-packages/groq/_client.pyrN   zGroq.__init__1       6 ?jjnn^4G? T  zz~~o6H-H##*&(C 	 		
    c                    ddl m}  ||       S )Nr	   )r+   )resources.chatr+   )rP   r+   s     rR   r   z	Groq.chatd   s    (DzrT   c                    ddl m}  ||       S )Nr	   )r-   )resources.embeddingsr-   )rP   r-   s     rR   r$   zGroq.embeddingsj   s    4$rT   c                    ddl m}  ||       S )Nr	   )r/   )resources.audior/   )rP   r/   s     rR   r    z
Groq.audiop       *T{rT   c                    ddl m}  ||       S )Nr	   )r'   )resources.modelsr'   )rP   r'   s     rR   r"   zGroq.modelsv   s    ,d|rT   c                    ddl m}  ||       S )Nr	   )r)   )resources.batchesr)   )rP   r)   s     rR   r#   zGroq.batches|   s    .t}rT   c                    ddl m}  ||       S )Nr	   )r%   )resources.filesr%   )rP   r%   s     rR   r!   z
Groq.files   r[   rT   c                    t        |       S N)GroqWithRawResponserP   s    rR   with_raw_responsezGroq.with_raw_response   s    "4((rT   c                    t        |       S rc   )GroqWithStreamedResponsere   s    rR   with_streaming_responsezGroq.with_streaming_response       '--rT   c                    t        d      S Ncomma)array_formatr   re   s    rR   qszGroq.qs        00rT   c                (    | j                   }dd| iS NAuthorizationzBearer r7   rP   r7   s     rR   auth_headerszGroq.auth_headers        ,,77)!455rT   c                <    i t         |   ddi| j                  S )NX-Stainless-Asyncfalse)rM   r<   _custom_headersrP   rQ   s    rR   r<   zGroq.default_headers   s4    
g%

 ""
 	
rT   
r7   r9   r:   r>   r;   r<   set_default_headersr=   set_default_query_extra_kwargsc       
           ||t        d      ||	t        d      | j                  }|i ||}n||}| j                  }|i ||}n|	|	}|xs | j                  } | j                  d|xs | j
                  |xs | j                  t        |t              r| j                  n||t        |      r|n| j                  ||d|
S z~
        Create a new client instance re-using the same options given to the current client with optional overriding.
        zPThe `default_headers` and `set_default_headers` arguments are mutually exclusivezLThe `default_query` and `set_default_query` arguments are mutually exclusive)r7   r9   r:   r>   r;   r<   r=    
ValueErrorr{   _custom_query_clientrQ   r7   r9   
isinstancer   r:   r   r;   rP   r7   r9   r:   r>   r;   r<   r~   r=   r   r   headersparamss                rR   copyz	Groq.copy       " &+>+Jopp$):)Fkll&&&44O4G ,)G##$00-0F*&F!1T\\t~~ 	
+t||.$.w$ADLLw#'/'<$BRBR# 	
 	
 		
rT   c                  |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j
                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   d	k\  rt        j                  |||      S t        |||      S 
Ni  )responsebodyi  i  i  i  i  i  i  status_coder
   BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorr   rP   err_msgr   r   s       rR   _make_status_errorzGroq._make_status_error   0    3&..wPTUU3&227XTXYY3&44WxVZ[[3&,,WxdSS3&,,WxdSS3&77(Y]^^3&--gtTT3&227XTXYYgtDDrT   )r7   
str | Noner9   str | httpx.URL | Noner:   !float | Timeout | None | NotGivenr;   intr<   Mapping[str, str] | Noner=   Mapping[str, object] | Noner>   httpx.Client | Noner?   boolreturnNone)r   r+   )r   r-   )r   r/   )r   r'   )r   r)   )r   r%   )r   rd   )r   rh   r   r   r   zdict[str, str]r   zdict[str, str | Omit])r7   r   r9   r   r:   r   r>   r   r;   int | NotGivenr<   r   r~   r   r=   r   r   r   r   Mapping[str, Any]r   r   r   r6   r   objectr   zhttpx.Responser   r   __name__
__module____qualname____annotations__r   r   rN   r   r   r$   r    r"   r#   r!   rf   ri   propertyr   ro   rv   r<   r   with_optionsr   __classcell__rQ   s   @rR   r1   r1   -   sS   L
 #+/5>.4859 ,0 -2+1
 1
 )	1

 31
 1
 21
 31
 )1
* &*+1
, 
-1
f  
    
  
  
  
  
 ) ) . . 1  1 6  6 
  
 #+/5>+/&/488<599=+--
 -
 )	-

 3-
 )-
 $-
 2-
 6-
 3-
 7-
 )-
 
-
b LEE 	E
 !E 
E ErT   r1   c                      e Zd ZU ded<   ddeeddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZedd       Zedd       Z	edd	       Z
edd
       Zedd       Zedd       Zedd       Zedd       Zeedd              Zeedd              Zeed  fd              Zddededdddi d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZeZe	 	 	 	 	 	 	 	 d"d       Z xZS )#r2   r6   r7   NFr8   c          
         |t         j                  j                  d      }|t        d      || _        |t         j                  j                  d      }|d}t
        	|   t        |||||||       y)zConstruct a new async AsyncGroq client instance.

        This automatically infers the `api_key` argument from the `GROQ_API_KEY` environment variable if it is not provided.
        NrA   rB   rC   rD   rE   rI   rO   s
            rR   rN   zAsyncGroq.__init__   rS   rT   c                    ddl m}  ||       S )Nr	   )r,   )rV   r,   )rP   r,   s     rR   r   zAsyncGroq.chat0  s    -rT   c                    ddl m}  ||       S )Nr	   )r.   )rX   r.   )rP   r.   s     rR   r$   zAsyncGroq.embeddings6  s    9t$$rT   c                    ddl m}  ||       S )Nr	   )r0   )rZ   r0   )rP   r0   s     rR   r    zAsyncGroq.audio<      /$rT   c                    ddl m}  ||       S )Nr	   )r(   )r]   r(   )rP   r(   s     rR   r"   zAsyncGroq.modelsB  s    14  rT   c                    ddl m}  ||       S )Nr	   )r*   )r_   r*   )rP   r*   s     rR   r#   zAsyncGroq.batchesH  s    3D!!rT   c                    ddl m}  ||       S )Nr	   )r&   )ra   r&   )rP   r&   s     rR   r!   zAsyncGroq.filesN  r   rT   c                    t        |       S rc   )AsyncGroqWithRawResponsere   s    rR   rf   zAsyncGroq.with_raw_responseT  rj   rT   c                    t        |       S rc   )AsyncGroqWithStreamedResponsere   s    rR   ri   z!AsyncGroq.with_streaming_responseX  s    ,T22rT   c                    t        d      S rl   r   re   s    rR   ro   zAsyncGroq.qs\  rp   rT   c                (    | j                   }dd| iS rr   rt   ru   s     rR   rv   zAsyncGroq.auth_headersa  rw   rT   c                R    i t         |   ddt                i| j                  S )Nry   zasync:)rM   r<   r   r{   r|   s    rR   r<   zAsyncGroq.default_headersg  s@    
g%
6*;*=)>!?
 ""
 	
rT   r}   c       
           ||t        d      ||	t        d      | j                  }|i ||}n||}| j                  }|i ||}n|	|	}|xs | j                  } | j                  d|xs | j
                  |xs | j                  t        |t              r| j                  n||t        |      r|n| j                  ||d|
S r   r   r   s                rR   r   zAsyncGroq.copyp  r   rT   c                  |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j
                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   dk(  rt        j                  |||      S |j                   d	k\  rt        j                  |||      S t        |||      S r   r   r   s       rR   r   zAsyncGroq._make_status_error  r   rT   )r7   r   r9   r   r:   r   r;   r   r<   r   r=   r   r>   httpx.AsyncClient | Noner?   r   r   r   )r   r,   )r   r.   )r   r0   )r   r(   )r   r*   )r   r&   )r   r   )r   r   r   r   r   )r7   r   r9   r   r:   r   r>   r   r;   r   r<   r   r~   r   r=   r   r   r   r   r   r   r   r   r   r   s   @rR   r2   r2      sS   L
 #+/5>.4859 15 -2+1
 1
 )	1

 31
 1
 21
 31
 .1
* &*+1
, 
-1
f  
 % %
    
 ! !
 " "
    
 . . 3 3 1  1 6  6 
  
 #+/5>04&/488<599=+--
 -
 )	-

 3-
 .-
 $-
 2-
 6-
 3-
 7-
 )-
 
-
b LEE 	E
 !E 
E ErT   r2   c                      e Zd ZU ded<   ddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd	       Zy
)rd   r1   r   c                    || _         y rc   r   rP   clients     rR   rN   zGroqWithRawResponse.__init__  	    rT   c                F    ddl m}  || j                  j                        S )Nr	   )ChatWithRawResponse)rV   r   r   r   )rP   r   s     rR   r   zGroqWithRawResponse.chat  s    7"4<<#4#455rT   c                F    ddl m}  || j                  j                        S )Nr	   )EmbeddingsWithRawResponse)rX   r   r   r$   )rP   r   s     rR   r$   zGroqWithRawResponse.embeddings  s    C()@)@AArT   c                F    ddl m}  || j                  j                        S )Nr	   )AudioWithRawResponse)rZ   r   r   r    )rP   r   s     rR   r    zGroqWithRawResponse.audio      9#DLL$6$677rT   c                F    ddl m}  || j                  j                        S )Nr	   )ModelsWithRawResponse)r]   r   r   r"   )rP   r   s     rR   r"   zGroqWithRawResponse.models  s    ;$T\\%8%899rT   c                F    ddl m}  || j                  j                        S )Nr	   )BatchesWithRawResponse)r_   r   r   r#   )rP   r   s     rR   r#   zGroqWithRawResponse.batches  s    =%dll&:&:;;rT   c                F    ddl m}  || j                  j                        S )Nr	   )FilesWithRawResponse)ra   r   r   r!   )rP   r   s     rR   r!   zGroqWithRawResponse.files  r   rT   Nr   r1   r   r   )r   zchat.ChatWithRawResponse)r   z$embeddings.EmbeddingsWithRawResponse)r   zaudio.AudioWithRawResponse)r   zmodels.ModelsWithRawResponse)r   zbatches.BatchesWithRawResponse)r   zfiles.FilesWithRawResponser   r   r   r   rN   r   r   r$   r    r"   r#   r!   r   rT   rR   rd   rd     s    M 6 6
 B B
 8 8
 : :
 < <
 8 8rT   rd   c                      e Zd ZU ded<   ddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd	       Zy
)r   r2   r   c                    || _         y rc   r   r   s     rR   rN   z!AsyncGroqWithRawResponse.__init__  r   rT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncChatWithRawResponse)rV   r   r   r   )rP   r   s     rR   r   zAsyncGroqWithRawResponse.chat  s    <'(9(9::rT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncEmbeddingsWithRawResponse)rX   r   r   r$   )rP   r   s     rR   r$   z#AsyncGroqWithRawResponse.embeddings  s    H-dll.E.EFFrT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncAudioWithRawResponse)rZ   r   r   r    )rP   r   s     rR   r    zAsyncGroqWithRawResponse.audio      >(););<<rT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncModelsWithRawResponse)r]   r   r   r"   )rP   r   s     rR   r"   zAsyncGroqWithRawResponse.models  s    @)$,,*=*=>>rT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncBatchesWithRawResponse)r_   r   r   r#   )rP   r   s     rR   r#   z AsyncGroqWithRawResponse.batches  s    B*4<<+?+?@@rT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncFilesWithRawResponse)ra   r   r   r!   )rP   r   s     rR   r!   zAsyncGroqWithRawResponse.files  r   rT   Nr   r2   r   r   )r   zchat.AsyncChatWithRawResponse)r   z)embeddings.AsyncEmbeddingsWithRawResponse)r   zaudio.AsyncAudioWithRawResponse)r   z!models.AsyncModelsWithRawResponse)r   z#batches.AsyncBatchesWithRawResponse)r   zfiles.AsyncFilesWithRawResponser   r   rT   rR   r   r     s     ; ;
 G G
 = =
 ? ?
 A A
 = =rT   r   c                      e Zd ZU ded<   ddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd	       Zy
)rh   r1   r   c                    || _         y rc   r   r   s     rR   rN   z!GroqWithStreamedResponse.__init__  r   rT   c                F    ddl m}  || j                  j                        S )Nr	   )ChatWithStreamingResponse)rV   r   r   r   )rP   r   s     rR   r   zGroqWithStreamedResponse.chat!  s    =():):;;rT   c                F    ddl m}  || j                  j                        S )Nr	   )EmbeddingsWithStreamingResponse)rX   r   r   r$   )rP   r   s     rR   r$   z#GroqWithStreamedResponse.embeddings'  s    I.t||/F/FGGrT   c                F    ddl m}  || j                  j                        S )Nr	   )AudioWithStreamingResponse)rZ   r   r   r    )rP   r   s     rR   r    zGroqWithStreamedResponse.audio-      ?)$,,*<*<==rT   c                F    ddl m}  || j                  j                        S )Nr	   )ModelsWithStreamingResponse)r]   r   r   r"   )rP   r   s     rR   r"   zGroqWithStreamedResponse.models3  s    A*4<<+>+>??rT   c                F    ddl m}  || j                  j                        S )Nr	   )BatchesWithStreamingResponse)r_   r   r   r#   )rP   r   s     rR   r#   z GroqWithStreamedResponse.batches9  s    C+DLL,@,@AArT   c                F    ddl m}  || j                  j                        S )Nr	   )FilesWithStreamingResponse)ra   r   r   r!   )rP   r   s     rR   r!   zGroqWithStreamedResponse.files?  r   rT   Nr   )r   zchat.ChatWithStreamingResponse)r   z*embeddings.EmbeddingsWithStreamingResponse)r   z audio.AudioWithStreamingResponse)r   z"models.ModelsWithStreamingResponse)r   z$batches.BatchesWithStreamingResponse)r   z files.FilesWithStreamingResponser   r   rT   rR   rh   rh     s    M < <
 H H
 > >
 @ @
 B B
 > >rT   rh   c                      e Zd ZU ded<   ddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd	       Zy
)r   r2   r   c                    || _         y rc   r   r   s     rR   rN   z&AsyncGroqWithStreamedResponse.__init__I  r   rT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncChatWithStreamingResponse)rV   r  r   r   )rP   r  s     rR   r   z"AsyncGroqWithStreamedResponse.chatL  s    B-dll.?.?@@rT   c                F    ddl m}  || j                  j                        S )Nr	   )$AsyncEmbeddingsWithStreamingResponse)rX   r  r   r$   )rP   r  s     rR   r$   z(AsyncGroqWithStreamedResponse.embeddingsR  s    N3DLL4K4KLLrT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncAudioWithStreamingResponse)rZ   r  r   r    )rP   r  s     rR   r    z#AsyncGroqWithStreamedResponse.audioX      D.t||/A/ABBrT   c                F    ddl m}  || j                  j                        S )Nr	   ) AsyncModelsWithStreamingResponse)r]   r  r   r"   )rP   r  s     rR   r"   z$AsyncGroqWithStreamedResponse.models^  s    F/0C0CDDrT   c                F    ddl m}  || j                  j                        S )Nr	   )!AsyncBatchesWithStreamingResponse)r_   r  r   r#   )rP   r  s     rR   r#   z%AsyncGroqWithStreamedResponse.batchesd  s    H01E1EFFrT   c                F    ddl m}  || j                  j                        S )Nr	   )AsyncFilesWithStreamingResponse)ra   r  r   r!   )rP   r  s     rR   r!   z#AsyncGroqWithStreamedResponse.filesj  r	  rT   Nr   )r   z#chat.AsyncChatWithStreamingResponse)r   z/embeddings.AsyncEmbeddingsWithStreamingResponse)r   z%audio.AsyncAudioWithStreamingResponse)r   z'models.AsyncModelsWithStreamingResponse)r   z)batches.AsyncBatchesWithStreamingResponse)r   z%files.AsyncFilesWithStreamingResponser   r   rT   rR   r   r   F  s     A A
 M M
 C C
 E E
 G G
 C CrT   r   )I
__future__r   rJ   typingr   r   r   typing_extensionsr   r   httpx r
   _qsr   _typesr   r   r   r   r   r   r   _utilsr   r   _compatr   _versionr   
_streamingr   r   r   r   _base_clientr   r   r   	resourcesr   r    r!   r"   r#   r$   ra   r%   r&   r]   r'   r(   r_   r)   r*   resources.chat.chatr+   r,   rX   r-   r.   resources.audio.audior/   r0   __all__r1   r2   rd   r   rh   r   r3   r4   r   rT   rR   <module>r      s    # 	 . . ,      0 $ ! D 2  JJ2584A8
rIE= IEXIE IEX(8 (8V(= (=V(> (>V(C (CV 
rT   