o
    hB                     @  sh  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mZmZ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) ddl*m+Z+ ddl,m-Z- g dZ.G dd de(Z/G dd de)Z0G dd dZ1G dd dZ2G dd dZ3G dd dZ4e/Z5e0Z6dS )    )annotationsN)AnyUnionMapping)Selfoverride   )_exceptionsQuerystring)	NOT_GIVENOmitTimeoutNotGiven	TransportProxiesTypesRequestOptions)is_givenget_async_library)__version__)filesmodelsbatches
embeddings)StreamAsyncStream)	GroqErrorAPIStatusError)DEFAULT_MAX_RETRIESSyncAPIClientAsyncAPIClient)chat)audio)r   r   r   r   Groq	AsyncGroqClientAsyncClientc                         e Zd ZU ded< ded< ded< ded< d	ed
< ded< ded< ded< ded< ddeeddddddD fd'd(ZeedEd*d+Z	eedFd-d.Z
eedG fd0d1Zddededdddi d2
dHd:d;ZeZedIdBdCZ  ZS )Jr#   z	chat.Chatr!   zembeddings.Embeddingsr   zaudio.Audior"   zmodels.Modelsr   zbatches.Batchesr   zfiles.Filesr   GroqWithRawResponsewith_raw_responseGroqWithStreamedResponsewith_streaming_responsestrapi_keyNFr-   base_urltimeoutmax_retriesdefault_headersdefault_queryhttp_client_strict_response_validation
str | Noner/   str | httpx.URL | Noner0   %Union[float, Timeout, None, NotGiven]r1   intr2   Mapping[str, str] | Noner3   Mapping[str, object] | Noner4   httpx.Client | Noner5   boolreturnNonec          	   
        |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 t	| | _t
| | _
t| | _t| | _t| | _t| | _t| | _t| | _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versionr/   r1   r0   r4   custom_headerscustom_queryr5   )osenvirongetr   r-   super__init__r   r!   Chatr   
Embeddingsr"   Audior   Modelsr   Batchesr   Filesr(   r)   r*   r+   	selfr-   r/   r0   r1   r2   r3   r4   r5   	__class__ `/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/groq/_client.pyrM   6   :   
zGroq.__init__r   c                 C  
   t ddS Ncomma)array_formatr
   rU   rX   rX   rY   qsr      
zGroq.qsdict[str, str]c                 C     | j }dd| iS NAuthorizationzBearer r-   rU   r-   rX   rX   rY   auth_headersw      zGroq.auth_headersdict[str, str | Omit]c                   s   i t  jddi| jS )NX-Stainless-Asyncfalse)rL   r2   _custom_headersr_   rV   rX   rY   r2   }   s   zGroq.default_headers
r-   r/   r0   r4   r1   r2   set_default_headersr3   set_default_query_extra_kwargs!float | Timeout | None | NotGivenint | NotGivenro   rp   rq   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)r-   r/   r0   r4   r1   r2   r3   rX   
ValueErrorrm   _custom_query_clientrW   r-   r/   
isinstancer   r0   r   r1   rU   r-   r/   r0   r4   r1   r2   ro   r3   rp   rq   headersparamsrX   rX   rY   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   rU   r   r   r   rX   rX   rY   _make_status_error   "   







zGroq._make_status_error)r-   r6   r/   r7   r0   r8   r1   r9   r2   r:   r3   r;   r4   r<   r5   r=   r>   r?   r>   r   r>   rb   r>   rj   )r-   r6   r/   r7   r0   rr   r4   r<   r1   rs   r2   r:   ro   r:   r3   r;   rp   r;   rq   rt   r>   r   r   r,   r   r   r   r   r>   r   __name__
__module____qualname____annotations__r   r   rM   propertyr   r`   rh   r2   r   with_optionsr   __classcell__rX   rX   rV   rY   r#   )   T   
 	<
1r#   c                      r'   )Jr$   zchat.AsyncChatr!   zembeddings.AsyncEmbeddingsr   zaudio.AsyncAudior"   zmodels.AsyncModelsr   zbatches.AsyncBatchesr   zfiles.AsyncFilesr   AsyncGroqWithRawResponser)   AsyncGroqWithStreamedResponser+   r,   r-   NFr.   r6   r/   r7   r0   r8   r1   r9   r2   r:   r3   r;   r4   httpx.AsyncClient | Noner5   r=   r>   r?   c          	   
     r@   )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   rJ   rK   r   r-   rL   rM   r   r!   	AsyncChatr   AsyncEmbeddingsr"   
AsyncAudior   AsyncModelsr   AsyncBatchesr   
AsyncFilesr   r)   r   r+   rT   rV   rX   rY   rM      rZ   zAsyncGroq.__init__r   c                 C  r[   r\   r
   r_   rX   rX   rY   r`   $  ra   zAsyncGroq.qsrb   c                 C  rc   rd   rf   rg   rX   rX   rY   rh   )  ri   zAsyncGroq.auth_headersrj   c                   s"   i t  jddt  i| jS )Nrk   zasync:)rL   r2   r   rm   r_   rV   rX   rY   r2   /  s   zAsyncGroq.default_headersrn   rr   rs   ro   rp   rq   rt   r   c       
      
   C  ru   rv   rw   r|   rX   rX   rY   r   8  r   zAsyncGroq.copyr   r   r   r   r   r   c                C  r   r   r   r   rX   rX   rY   r   k  r   zAsyncGroq._make_status_error)r-   r6   r/   r7   r0   r8   r1   r9   r2   r:   r3   r;   r4   r   r5   r=   r>   r?   r   r   r   )r-   r6   r/   r7   r0   rr   r4   r   r1   rs   r2   r:   ro   r:   r3   r;   rp   r;   rq   rt   r>   r   r   r   rX   rX   rV   rY   r$      r   r$   c                   @     e Zd ZdddZdS )	r(   clientr#   r>   r?   c                 C  X   t |j | _ t|j| _t|j| _t|j| _t	|j| _t
|j
| _
d S N)r!   ChatWithRawResponser   EmbeddingsWithRawResponser"   AudioWithRawResponser   ModelsWithRawResponser   BatchesWithRawResponser   FilesWithRawResponserU   r   rX   rX   rY   rM        zGroqWithRawResponse.__init__Nr   r#   r>   r?   r   r   r   rM   rX   rX   rX   rY   r(         r(   c                   @  r   )	r   r   r$   r>   r?   c                 C  r   r   )r!   AsyncChatWithRawResponser   AsyncEmbeddingsWithRawResponser"   AsyncAudioWithRawResponser   AsyncModelsWithRawResponser   AsyncBatchesWithRawResponser   AsyncFilesWithRawResponser   rX   rX   rY   rM     r   z!AsyncGroqWithRawResponse.__init__Nr   r$   r>   r?   r   rX   rX   rX   rY   r     r   r   c                   @  r   )	r*   r   r#   r>   r?   c                 C  r   r   )r!   ChatWithStreamingResponser   EmbeddingsWithStreamingResponser"   AudioWithStreamingResponser   ModelsWithStreamingResponser   BatchesWithStreamingResponser   FilesWithStreamingResponser   rX   rX   rY   rM     r   z!GroqWithStreamedResponse.__init__Nr   r   rX   rX   rX   rY   r*     r   r*   c                   @  r   )	r   r   r$   r>   r?   c                 C  r   r   )r!   AsyncChatWithStreamingResponser   $AsyncEmbeddingsWithStreamingResponser"   AsyncAudioWithStreamingResponser    AsyncModelsWithStreamingResponser   !AsyncBatchesWithStreamingResponser   AsyncFilesWithStreamingResponser   rX   rX   rY   rM     r   z&AsyncGroqWithStreamedResponse.__init__Nr   r   rX   rX   rX   rY   r     r   r   )7
__future__r   rI   typingr   r   r   typing_extensionsr   r   httpx r	   _qsr   _typesr   r   r   r   r   r   r   _utilsr   r   _versionr   	resourcesr   r   r   r   
_streamingr   r   r   r   _base_clientr   r   r    resources.chatr!   resources.audior"   __all__r#   r$   r(   r   r*   r   r%   r&   rX   rX   rX   rY   <module>   s6   $	 3 3



