o
    ?0mhU                     @  s  d dl mZ d dlZd dlmZ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/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9m:Z: ddl;m<Z<m=Z= ddl>m?Z?m@Z@ g dZAG dd de&ZBG dd de'ZCG dd dZDG dd dZEG dd  d ZFG d!d" d"ZGeBZHeCZIdS )#    )annotationsN)TYPE_CHECKINGAnyUnionMapping)Selfoverride   )_exceptionsQuerystring)	NOT_GIVENOmitTimeoutNotGiven	TransportProxiesTypesRequestOptions)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dL fd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,d-ZedTd/d0ZeedUd2d3ZeedVd5d6ZeedW fd8d9Zddededdddi d:
dXdBdCZeZedYdJdKZ  ZS )Zr1   strapi_keyNFr7   base_urltimeoutmax_retriesdefault_headersdefault_queryhttp_client_strict_response_validation
str | Noner9   str | httpx.URL | Noner:   %Union[float, Timeout, None, NotGiven]r;   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versionr9   r;   r:   r>   custom_headerscustom_queryr?   osenvirongetr   r7   super__init__r   	selfr7   r9   r:   r;   r<   r=   r>   r?   	__class__ Z/var/www/html/tas-one-backend/ai_backend/venv/lib/python3.10/site-packages/groq/_client.pyrX   1   *   
zGroq.__init__r+   c                 C     ddl m} || S )Nr	   )r+   )resources.chatr+   )rZ   r+   r]   r]   r^   r   d      z	Groq.chatr-   c                 C  r`   )Nr	   )r-   )resources.embeddingsr-   )rZ   r-   r]   r]   r^   r$   j   rb   zGroq.embeddingsr/   c                 C  r`   )Nr	   )r/   )resources.audior/   )rZ   r/   r]   r]   r^   r    p   rb   z
Groq.audior'   c                 C  r`   )Nr	   )r'   )resources.modelsr'   )rZ   r'   r]   r]   r^   r"   v   rb   zGroq.modelsr)   c                 C  r`   )Nr	   )r)   )resources.batchesr)   )rZ   r)   r]   r]   r^   r#   |   rb   zGroq.batchesr%   c                 C  r`   )Nr	   )r%   )resources.filesr%   )rZ   r%   r]   r]   r^   r!      rb   z
Groq.filesGroqWithRawResponsec                 C     t | S N)rh   rZ   r]   r]   r^   with_raw_response      zGroq.with_raw_responseGroqWithStreamedResponsec                 C  ri   rj   )rn   rk   r]   r]   r^   with_streaming_response   rm   zGroq.with_streaming_responser   c                 C  
   t ddS Ncomma)array_formatr   rk   r]   r]   r^   qs      
zGroq.qsdict[str, str]c                 C     | j }dd| iS NAuthorizationzBearer r7   rZ   r7   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)rW   r<   _custom_headersrk   r[   r]   r^   r<      s   zGroq.default_headers
r7   r9   r:   r>   r;   r<   set_default_headersr=   set_default_query_extra_kwargs!float | Timeout | None | NotGiven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)r7   r9   r:   r>   r;   r<   r=   r]   
ValueErrorr   _custom_query_clientr\   r7   r9   
isinstancer   r:   r   r;   rZ   r7   r9   r:   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   rZ   r   r   r   r]   r]   r^   _make_status_error   "   







zGroq._make_status_error)r7   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   rE   r>   rF   r?   rG   rH   rI   )rH   r+   )rH   r-   )rH   r/   )rH   r'   )rH   r)   )rH   r%   )rH   rh   )rH   rn   rH   r   rH   rv   rH   r~   )r7   r@   r9   rA   r:   r   r>   rF   r;   r   r<   rD   r   rD   r=   rE   r   rE   r   r   rH   r   r   r6   r   r   r   r   rH   r   __name__
__module____qualname____annotations__r   r   rX   r   r   r$   r    r"   r#   r!   rl   ro   propertyr   rt   r|   r<   r   with_optionsr   __classcell__r]   r]   r[   r^   r1   -   d   
 	3
1r1   c                      r5   )Zr2   r6   r7   NFr8   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   rE   r>   httpx.AsyncClient | Noner?   rG   rH   rI   c          	   
     rJ   )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.
        NrK   rL   rM   rN   rO   rS   rY   r[   r]   r^   rX      r_   zAsyncGroq.__init__r,   c                 C  r`   )Nr	   )r,   )ra   r,   )rZ   r,   r]   r]   r^   r   0  rb   zAsyncGroq.chatr.   c                 C  r`   )Nr	   )r.   )rc   r.   )rZ   r.   r]   r]   r^   r$   6  rb   zAsyncGroq.embeddingsr0   c                 C  r`   )Nr	   )r0   )rd   r0   )rZ   r0   r]   r]   r^   r    <  rb   zAsyncGroq.audior(   c                 C  r`   )Nr	   )r(   )re   r(   )rZ   r(   r]   r]   r^   r"   B  rb   zAsyncGroq.modelsr*   c                 C  r`   )Nr	   )r*   )rf   r*   )rZ   r*   r]   r]   r^   r#   H  rb   zAsyncGroq.batchesr&   c                 C  r`   )Nr	   )r&   )rg   r&   )rZ   r&   r]   r]   r^   r!   N  rb   zAsyncGroq.filesAsyncGroqWithRawResponsec                 C  ri   rj   )r   rk   r]   r]   r^   rl   T  rm   zAsyncGroq.with_raw_responseAsyncGroqWithStreamedResponsec                 C  ri   rj   )r   rk   r]   r]   r^   ro   X  rm   z!AsyncGroq.with_streaming_responser   c                 C  rp   rq   r   rk   r]   r]   r^   rt   \  ru   zAsyncGroq.qsrv   c                 C  rw   rx   rz   r{   r]   r]   r^   r|   a  r}   zAsyncGroq.auth_headersr~   c                   s"   i t  jddt  i| jS )Nr   zasync:)rW   r<   r   r   rk   r[   r]   r^   r<   g  s   zAsyncGroq.default_headersr   r   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)r7   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   rE   r>   r   r?   rG   rH   rI   )rH   r,   )rH   r.   )rH   r0   )rH   r(   )rH   r*   )rH   r&   )rH   r   )rH   r   r   r   r   )r7   r@   r9   rA   r:   r   r>   r   r;   r   r<   rD   r   rD   r=   rE   r   rE   r   r   rH   r   r   r   r]   r]   r[   r^   r2      r   r2   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 )"rh   r1   r   clientrH   rI   c                 C  
   || _ d S rj   r   rZ   r   r]   r]   r^   rX        
zGroqWithRawResponse.__init__chat.ChatWithRawResponsec                 C     ddl m} || jjS )Nr	   )ChatWithRawResponse)ra   r   r   r   )rZ   r   r]   r]   r^   r        zGroqWithRawResponse.chat$embeddings.EmbeddingsWithRawResponsec                 C  r   )Nr	   )EmbeddingsWithRawResponse)rc   r   r   r$   )rZ   r   r]   r]   r^   r$     r   zGroqWithRawResponse.embeddingsaudio.AudioWithRawResponsec                 C  r   )Nr	   )AudioWithRawResponse)rd   r   r   r    )rZ   r   r]   r]   r^   r      r   zGroqWithRawResponse.audiomodels.ModelsWithRawResponsec                 C  r   )Nr	   )ModelsWithRawResponse)re   r   r   r"   )rZ   r   r]   r]   r^   r"     r   zGroqWithRawResponse.modelsbatches.BatchesWithRawResponsec                 C  r   )Nr	   )BatchesWithRawResponse)rf   r   r   r#   )rZ   r   r]   r]   r^   r#     r   zGroqWithRawResponse.batchesfiles.FilesWithRawResponsec                 C  r   )Nr	   )FilesWithRawResponse)rg   r   r   r!   )rZ   r   r]   r]   r^   r!     r   zGroqWithRawResponse.filesNr   r1   rH   rI   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   r   r   r   r   rX   r   r   r$   r    r"   r#   r!   r]   r]   r]   r^   rh        
 
rh   c                   @  r   )"r   r2   r   r   rH   rI   c                 C  r   rj   r   r   r]   r]   r^   rX     r   z!AsyncGroqWithRawResponse.__init__chat.AsyncChatWithRawResponsec                 C  r   )Nr	   )AsyncChatWithRawResponse)ra   r   r   r   )rZ   r   r]   r]   r^   r     r   zAsyncGroqWithRawResponse.chat)embeddings.AsyncEmbeddingsWithRawResponsec                 C  r   )Nr	   )AsyncEmbeddingsWithRawResponse)rc   r   r   r$   )rZ   r   r]   r]   r^   r$     r   z#AsyncGroqWithRawResponse.embeddingsaudio.AsyncAudioWithRawResponsec                 C  r   )Nr	   )AsyncAudioWithRawResponse)rd   r   r   r    )rZ   r   r]   r]   r^   r      r   zAsyncGroqWithRawResponse.audio!models.AsyncModelsWithRawResponsec                 C  r   )Nr	   )AsyncModelsWithRawResponse)re   r   r   r"   )rZ   r   r]   r]   r^   r"     r   zAsyncGroqWithRawResponse.models#batches.AsyncBatchesWithRawResponsec                 C  r   )Nr	   )AsyncBatchesWithRawResponse)rf   r   r   r#   )rZ   r   r]   r]   r^   r#     r   z AsyncGroqWithRawResponse.batchesfiles.AsyncFilesWithRawResponsec                 C  r   )Nr	   )AsyncFilesWithRawResponse)rg   r   r   r!   )rZ   r   r]   r]   r^   r!     r   zAsyncGroqWithRawResponse.filesNr   r2   rH   rI   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   r   r]   r]   r]   r^   r     r   r   c                   @  r   )"rn   r1   r   r   rH   rI   c                 C  r   rj   r   r   r]   r]   r^   rX     r   z!GroqWithStreamedResponse.__init__chat.ChatWithStreamingResponsec                 C  r   )Nr	   )ChatWithStreamingResponse)ra   r   r   r   )rZ   r   r]   r]   r^   r   !  r   zGroqWithStreamedResponse.chat*embeddings.EmbeddingsWithStreamingResponsec                 C  r   )Nr	   )EmbeddingsWithStreamingResponse)rc   r   r   r$   )rZ   r   r]   r]   r^   r$   '  r   z#GroqWithStreamedResponse.embeddings audio.AudioWithStreamingResponsec                 C  r   )Nr	   )AudioWithStreamingResponse)rd   r   r   r    )rZ   r   r]   r]   r^   r    -  r   zGroqWithStreamedResponse.audio"models.ModelsWithStreamingResponsec                 C  r   )Nr	   )ModelsWithStreamingResponse)re   r   r   r"   )rZ   r   r]   r]   r^   r"   3  r   zGroqWithStreamedResponse.models$batches.BatchesWithStreamingResponsec                 C  r   )Nr	   )BatchesWithStreamingResponse)rf   r   r   r#   )rZ   r   r]   r]   r^   r#   9  r   z GroqWithStreamedResponse.batches files.FilesWithStreamingResponsec                 C  r   )Nr	   )FilesWithStreamingResponse)rg   r   r   r!   )rZ   r   r]   r]   r^   r!   ?  r   zGroqWithStreamedResponse.filesNr   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   r   r]   r]   r]   r^   rn     r   rn   c                   @  r   )"r   r2   r   r   rH   rI   c                 C  r   rj   r   r   r]   r]   r^   rX   I  r   z&AsyncGroqWithStreamedResponse.__init__#chat.AsyncChatWithStreamingResponsec                 C  r   )Nr	   )AsyncChatWithStreamingResponse)ra   r   r   r   )rZ   r   r]   r]   r^   r   L  r   z"AsyncGroqWithStreamedResponse.chat/embeddings.AsyncEmbeddingsWithStreamingResponsec                 C  r   )Nr	   )$AsyncEmbeddingsWithStreamingResponse)rc   r   r   r$   )rZ   r   r]   r]   r^   r$   R  r   z(AsyncGroqWithStreamedResponse.embeddings%audio.AsyncAudioWithStreamingResponsec                 C  r   )Nr	   )AsyncAudioWithStreamingResponse)rd   r   r   r    )rZ   r   r]   r]   r^   r    X  r   z#AsyncGroqWithStreamedResponse.audio'models.AsyncModelsWithStreamingResponsec                 C  r   )Nr	   ) AsyncModelsWithStreamingResponse)re   r   r   r"   )rZ   r   r]   r]   r^   r"   ^  r   z$AsyncGroqWithStreamedResponse.models)batches.AsyncBatchesWithStreamingResponsec                 C  r   )Nr	   )!AsyncBatchesWithStreamingResponse)rf   r   r   r#   )rZ   r   r]   r]   r^   r#   d  r   z%AsyncGroqWithStreamedResponse.batches%files.AsyncFilesWithStreamingResponsec                 C  r   )Nr	   )AsyncFilesWithStreamingResponse)rg   r   r   r!   )rZ   r   r]   r]   r^   r!   j  r   z#AsyncGroqWithStreamedResponse.filesNr   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   )rH   r   r   r]   r]   r]   r^   r   F  r   r   )J
__future__r   rT   typingr   r   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$   rg   r%   r&   re   r'   r(   rf   r)   r*   resources.chat.chatr+   r,   rc   r-   r.   resources.audio.audior/   r0   __all__r1   r2   rh   r   rn   r   r3   r4   r]   r]   r]   r^   <module>   sB   $	  M M++++