o
    iU                     @  s  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rd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 de%ZAG dd de&ZBG dd dZCG dd dZDG dd  d ZEG d!d" d"ZFeAZGeBZHdS )#    )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dK fddZedLddZedMddZ	edNd d!Z
edOd#d$ZedPd&d'ZedQd)d*ZedRd,d-ZedSd/d0ZeedTd2d3ZeedUd5d6ZeedV fd8d9Zddededdddi d:
dWdAdBZeZedXdIdJZ  ZS )Yr0   strapi_keyNFr6   base_urltimeoutmax_retriesdefault_headersdefault_queryhttp_client_strict_response_validation
str | Noner8   str | httpx.URL | Noner9   !float | Timeout | None | NotGivenr:   intr;   Mapping[str, str] | Noner<   Mapping[str, object] | Noner=   httpx.Client | Noner>   boolreturnNonec          	   
     j   |du r
t jd}|du rtd|| _|du rt jd}|du r%d}t jt|||||||d dS )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versionr8   r:   r9   r=   custom_headerscustom_queryr>   osenvirongetr   r6   super__init__r   	selfr6   r8   r9   r:   r;   r<   r=   r>   	__class__ R/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/groq/_client.pyrW   1   *   
zGroq.__init__r*   c                 C     ddl m} || S )Nr   )r*   )resources.chatr*   )rY   r*   r\   r\   r]   r   d      z	Groq.chatr,   c                 C  r_   )Nr   )r,   )resources.embeddingsr,   )rY   r,   r\   r\   r]   r#   j   ra   zGroq.embeddingsr.   c                 C  r_   )Nr   )r.   )resources.audior.   )rY   r.   r\   r\   r]   r   p   ra   z
Groq.audior&   c                 C  r_   )Nr   )r&   )resources.modelsr&   )rY   r&   r\   r\   r]   r!   v   ra   zGroq.modelsr(   c                 C  r_   )Nr   )r(   )resources.batchesr(   )rY   r(   r\   r\   r]   r"   |   ra   zGroq.batchesr$   c                 C  r_   )Nr   )r$   )resources.filesr$   )rY   r$   r\   r\   r]   r       ra   z
Groq.filesGroqWithRawResponsec                 C     t | S N)rg   rY   r\   r\   r]   with_raw_response      zGroq.with_raw_responseGroqWithStreamedResponsec                 C  rh   ri   )rm   rj   r\   r\   r]   with_streaming_response   rl   zGroq.with_streaming_responser   c                 C  
   t ddS Ncomma)array_formatr
   rj   r\   r\   r]   qs      
zGroq.qsdict[str, str]c                 C     | j }dd| iS NAuthorizationzBearer r6   rY   r6   r\   r\   r]   auth_headers      zGroq.auth_headersdict[str, str | Omit]c                   s   i t  jddi| jS )NX-Stainless-Asyncfalse)rV   r;   _custom_headersrj   rZ   r\   r]   r;      s   zGroq.default_headers
r6   r8   r9   r=   r:   r;   set_default_headersr<   set_default_query_extra_kwargsint | NotGivenr   r   r   Mapping[str, Any]r   c       
      
   C     |dur|durt d|dur|	durt d| j}|dur&i ||}n|dur,|}| j}|dur:i ||}n|	dur@|	}|pD| j}| jd|pL| j|pP| jt|trX| 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.
        NzPThe `default_headers` and `set_default_headers` arguments are mutually exclusivezLThe `default_query` and `set_default_query` arguments are mutually exclusive)r6   r8   r9   r=   r:   r;   r<   r\   
ValueErrorr   _custom_query_clientr[   r6   r8   
isinstancer   r9   r   r:   rY   r6   r8   r9   r=   r:   r;   r   r<   r   r   headersparamsr\   r\   r]   copy   4   
z	Groq.copyerr_msgbodyobjectresponsehttpx.Responser   c                C     |j dkrtj|||dS |j dkrtj|||dS |j dkr'tj|||dS |j dkr4tj|||dS |j dkrAtj|||dS |j dkrNtj|||dS |j dkr[tj|||dS |j d	krhtj	|||dS t
|||dS 
Ni  )r   r   i  i  i  i  i  i  i  status_coder	   BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorr   rY   r   r   r   r\   r\   r]   _make_status_error   "   







zGroq._make_status_error)r6   r?   r8   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   rE   r>   rF   rG   rH   )rG   r*   )rG   r,   )rG   r.   )rG   r&   )rG   r(   )rG   r$   )rG   rg   )rG   rm   rG   r   rG   ru   rG   r}   )r6   r?   r8   r@   r9   rA   r=   rE   r:   r   r;   rC   r   rC   r<   rD   r   rD   r   r   rG   r   r   r5   r   r   r   r   rG   r   __name__
__module____qualname____annotations__r   r   rW   r   r   r#   r   r!   r"   r    rk   rn   propertyr   rs   r{   r;   r   with_optionsr   __classcell__r\   r\   rZ   r]   r0   -   d   
 	3
1r0   c                      r4   )Yr1   r5   r6   NFr7   r?   r8   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   httpx.AsyncClient | Noner>   rF   rG   rH   c          	   
     rI   )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.
        NrJ   rK   rL   rM   rN   rR   rX   rZ   r\   r]   rW      r^   zAsyncGroq.__init__r+   c                 C  r_   )Nr   )r+   )r`   r+   )rY   r+   r\   r\   r]   r   0  ra   zAsyncGroq.chatr-   c                 C  r_   )Nr   )r-   )rb   r-   )rY   r-   r\   r\   r]   r#   6  ra   zAsyncGroq.embeddingsr/   c                 C  r_   )Nr   )r/   )rc   r/   )rY   r/   r\   r\   r]   r   <  ra   zAsyncGroq.audior'   c                 C  r_   )Nr   )r'   )rd   r'   )rY   r'   r\   r\   r]   r!   B  ra   zAsyncGroq.modelsr)   c                 C  r_   )Nr   )r)   )re   r)   )rY   r)   r\   r\   r]   r"   H  ra   zAsyncGroq.batchesr%   c                 C  r_   )Nr   )r%   )rf   r%   )rY   r%   r\   r\   r]   r    N  ra   zAsyncGroq.filesAsyncGroqWithRawResponsec                 C  rh   ri   )r   rj   r\   r\   r]   rk   T  rl   zAsyncGroq.with_raw_responseAsyncGroqWithStreamedResponsec                 C  rh   ri   )r   rj   r\   r\   r]   rn   X  rl   z!AsyncGroq.with_streaming_responser   c                 C  ro   rp   r
   rj   r\   r\   r]   rs   \  rt   zAsyncGroq.qsru   c                 C  rv   rw   ry   rz   r\   r\   r]   r{   a  r|   zAsyncGroq.auth_headersr}   c                   s"   i t  jddt  i| jS )Nr~   zasync:)rV   r;   r   r   rj   rZ   r\   r]   r;   g  s   zAsyncGroq.default_headersr   r   r   r   r   r   r   c       
      
   C  r   r   r   r   r\   r\   r]   r   p  r   zAsyncGroq.copyr   r   r   r   r   r   c                C  r   r   r   r   r\   r\   r]   r     r   zAsyncGroq._make_status_error)r6   r?   r8   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   r   r>   rF   rG   rH   )rG   r+   )rG   r-   )rG   r/   )rG   r'   )rG   r)   )rG   r%   )rG   r   )rG   r   r   r   r   )r6   r?   r8   r@   r9   rA   r=   r   r:   r   r;   rC   r   rC   r<   rD   r   rD   r   r   rG   r   r   r   r\   r\   rZ   r]   r1      r   r1   c                   @  t   e Zd ZU ded< dddZedd	d
ZedddZedddZedddZ	ed ddZ
ed!ddZdS )"rg   r0   r   clientrG   rH   c                 C  
   || _ d S ri   r   rY   r   r\   r\   r]   rW        
zGroqWithRawResponse.__init__chat.ChatWithRawResponsec                 C     ddl m} || jjS )Nr   )ChatWithRawResponse)r`   r   r   r   )rY   r   r\   r\   r]   r        zGroqWithRawResponse.chat$embeddings.EmbeddingsWithRawResponsec                 C  r   )Nr   )EmbeddingsWithRawResponse)rb   r   r   r#   )rY   r   r\   r\   r]   r#     r   zGroqWithRawResponse.embeddingsaudio.AudioWithRawResponsec                 C  r   )Nr   )AudioWithRawResponse)rc   r   r   r   )rY   r   r\   r\   r]   r     r   zGroqWithRawResponse.audiomodels.ModelsWithRawResponsec                 C  r   )Nr   )ModelsWithRawResponse)rd   r   r   r!   )rY   r   r\   r\   r]   r!     r   zGroqWithRawResponse.modelsbatches.BatchesWithRawResponsec                 C  r   )Nr   )BatchesWithRawResponse)re   r   r   r"   )rY   r   r\   r\   r]   r"     r   zGroqWithRawResponse.batchesfiles.FilesWithRawResponsec                 C  r   )Nr   )FilesWithRawResponse)rf   r   r   r    )rY   r   r\   r\   r]   r      r   zGroqWithRawResponse.filesNr   r0   rG   rH   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   r   r   r   r   rW   r   r   r#   r   r!   r"   r    r\   r\   r\   r]   rg        
 
rg   c                   @  r   )"r   r1   r   r   rG   rH   c                 C  r   ri   r   r   r\   r\   r]   rW     r   z!AsyncGroqWithRawResponse.__init__chat.AsyncChatWithRawResponsec                 C  r   )Nr   )AsyncChatWithRawResponse)r`   r   r   r   )rY   r   r\   r\   r]   r     r   zAsyncGroqWithRawResponse.chat)embeddings.AsyncEmbeddingsWithRawResponsec                 C  r   )Nr   )AsyncEmbeddingsWithRawResponse)rb   r   r   r#   )rY   r   r\   r\   r]   r#     r   z#AsyncGroqWithRawResponse.embeddingsaudio.AsyncAudioWithRawResponsec                 C  r   )Nr   )AsyncAudioWithRawResponse)rc   r   r   r   )rY   r   r\   r\   r]   r     r   zAsyncGroqWithRawResponse.audio!models.AsyncModelsWithRawResponsec                 C  r   )Nr   )AsyncModelsWithRawResponse)rd   r   r   r!   )rY   r   r\   r\   r]   r!     r   zAsyncGroqWithRawResponse.models#batches.AsyncBatchesWithRawResponsec                 C  r   )Nr   )AsyncBatchesWithRawResponse)re   r   r   r"   )rY   r   r\   r\   r]   r"     r   z AsyncGroqWithRawResponse.batchesfiles.AsyncFilesWithRawResponsec                 C  r   )Nr   )AsyncFilesWithRawResponse)rf   r   r   r    )rY   r   r\   r\   r]   r      r   zAsyncGroqWithRawResponse.filesNr   r1   rG   rH   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   r   r\   r\   r\   r]   r     r   r   c                   @  r   )"rm   r0   r   r   rG   rH   c                 C  r   ri   r   r   r\   r\   r]   rW     r   z!GroqWithStreamedResponse.__init__chat.ChatWithStreamingResponsec                 C  r   )Nr   )ChatWithStreamingResponse)r`   r   r   r   )rY   r   r\   r\   r]   r   !  r   zGroqWithStreamedResponse.chat*embeddings.EmbeddingsWithStreamingResponsec                 C  r   )Nr   )EmbeddingsWithStreamingResponse)rb   r   r   r#   )rY   r   r\   r\   r]   r#   '  r   z#GroqWithStreamedResponse.embeddings audio.AudioWithStreamingResponsec                 C  r   )Nr   )AudioWithStreamingResponse)rc   r   r   r   )rY   r   r\   r\   r]   r   -  r   zGroqWithStreamedResponse.audio"models.ModelsWithStreamingResponsec                 C  r   )Nr   )ModelsWithStreamingResponse)rd   r   r   r!   )rY   r   r\   r\   r]   r!   3  r   zGroqWithStreamedResponse.models$batches.BatchesWithStreamingResponsec                 C  r   )Nr   )BatchesWithStreamingResponse)re   r   r   r"   )rY   r   r\   r\   r]   r"   9  r   z GroqWithStreamedResponse.batches files.FilesWithStreamingResponsec                 C  r   )Nr   )FilesWithStreamingResponse)rf   r   r   r    )rY   r   r\   r\   r]   r    ?  r   zGroqWithStreamedResponse.filesNr   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   r   r\   r\   r\   r]   rm     r   rm   c                   @  r   )"r   r1   r   r   rG   rH   c                 C  r   ri   r   r   r\   r\   r]   rW   I  r   z&AsyncGroqWithStreamedResponse.__init__#chat.AsyncChatWithStreamingResponsec                 C  r   )Nr   )AsyncChatWithStreamingResponse)r`   r   r   r   )rY   r   r\   r\   r]   r   L  r   z"AsyncGroqWithStreamedResponse.chat/embeddings.AsyncEmbeddingsWithStreamingResponsec                 C  r   )Nr   )$AsyncEmbeddingsWithStreamingResponse)rb   r   r   r#   )rY   r   r\   r\   r]   r#   R  r   z(AsyncGroqWithStreamedResponse.embeddings%audio.AsyncAudioWithStreamingResponsec                 C  r   )Nr   )AsyncAudioWithStreamingResponse)rc   r   r   r   )rY   r   r\   r\   r]   r   X  r   z#AsyncGroqWithStreamedResponse.audio'models.AsyncModelsWithStreamingResponsec                 C  r   )Nr   ) AsyncModelsWithStreamingResponse)rd   r   r   r!   )rY   r   r\   r\   r]   r!   ^  r   z$AsyncGroqWithStreamedResponse.models)batches.AsyncBatchesWithStreamingResponsec                 C  r   )Nr   )!AsyncBatchesWithStreamingResponse)re   r   r   r"   )rY   r   r\   r\   r]   r"   d  r   z%AsyncGroqWithStreamedResponse.batches%files.AsyncFilesWithStreamingResponsec                 C  r   )Nr   )AsyncFilesWithStreamingResponse)rf   r   r   r    )rY   r   r\   r\   r]   r    j  r   z#AsyncGroqWithStreamedResponse.filesNr   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   )rG   r   r   r\   r\   r\   r]   r   F  r   r   )I
__future__r   rS   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#   rf   r$   r%   rd   r&   r'   re   r(   r)   resources.chat.chatr*   r+   rb   r,   r-   resources.audio.audior.   r/   __all__r0   r1   rg   r   rm   r   r2   r3   r\   r\   r\   r]   <module>   sB   $	  M M++++