
    +h#                    4   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	 d dl
Z
ddlmZmZ ddl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" erddl#m$Z$m%Z% ddgZ& G d de      Z' G d de      Z( G d d      Z) G d d      Z*y)    )annotationsN)TYPE_CHECKINGListUnioncast)Literal   )CreateEmbeddingResponseembedding_create_params)	NOT_GIVENBodyQueryHeadersNotGiven)is_givenmaybe_transform)numpy)	has_numpy)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperasync_to_raw_response_wrapper)make_request_options)OpenAIAsyncOpenAI
EmbeddingsAsyncEmbeddingsc                  f     e Zd ZU ded<   d fdZeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ xZS )	r   EmbeddingsWithRawResponsewith_raw_responsec                D    t         |   |       t        |       | _        y N)super__init__r   r    selfclient	__class__s     N/var/www/html/venv/lib/python3.12/site-packages/openai/resources/embeddings.pyr$   zEmbeddings.__init__   s     !:4!@    Nencoding_formatuserextra_headersextra_query
extra_bodytimeoutc                   |||d}	t              st               rd|	d<   dfd}
| j                  dt        |	t        j
                        t        |||||
      t              S )	.  
        Creates an embedding vector representing the input text.

        Args:
          input: Input text to embed, encoded as a string or array of tokens. To embed multiple
              inputs in a single request, pass an array of strings or array of token arrays.
              The input must not exceed the max input tokens for the model (8192 tokens for
              `text-embedding-ada-002`) and cannot be an empty string.
              [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
              for counting tokens.

          model: ID of the model to use. You can use the
              [List models](https://platform.openai.com/docs/api-reference/models/list) API to
              see all of your available models, or see our
              [Model overview](https://platform.openai.com/docs/models/overview) for
              descriptions of them.

          encoding_format: The format to return the embeddings in. Can be either `float` or
              [`base64`](https://pypi.org/project/pybase64/).

          user: A unique identifier representing your end-user, which can help OpenAI to monitor
              and detect abuse.
              [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids).

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        inputmodelr-   r,   base64r,   c                   t              r| S | j                  D ]j  }t        t        |j                        }t        |t              s.t        j                  t        j                  |      d      j                         |_        l | S Nfloat32)dtyper   datar   object	embedding
isinstancestrnp
frombufferr7   	b64decodetolistobjr?   r=   r,   s      r)   parserz!Embeddings.create.<locals>.parserX   t    (
 XX 	FI$7$78!$,&(mm$$T*)'&( # Jr*   /embeddingsr.   r/   r0   r1   post_parserbodyoptionscast_torG   r
   returnr
   r   r   _postr   r   EmbeddingCreateParamsr   r
   r&   r5   r6   r,   r-   r.   r/   r0   r1   paramsrH   s      `       r)   createzEmbeddings.create!   s    ^ .	
 (Y[(0F$%	" zz )@)V)VW(+'%" ,  
 	
r*   )r'   r   rR   Noner5   z1Union[str, List[str], List[int], List[List[int]]]r6   z-Union[str, Literal['text-embedding-ada-002']]r,   z%Literal['float', 'base64'] | NotGivenr-   zstr | NotGivenr.   zHeaders | Noner/   zQuery | Noner0   zBody | Noner1   z'float | httpx.Timeout | None | NotGivenrR   r
   __name__
__module____qualname____annotations__r$   r   rX   __classcell__r(   s   @r)   r   r      s    00A BK( )-$("&;DS
 AS
 =	S

 ?S
 S
 &S
 "S
  S
 9S
 
!S
r*   c                  f     e Zd ZU ded<   d fdZeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ xZS )	r   AsyncEmbeddingsWithRawResponser    c                D    t         |   |       t        |       | _        y r"   )r#   r$   rc   r    r%   s     r)   r$   zAsyncEmbeddings.__init__z   s     !?!Er*   Nr+   c                  K   |||d}	t              st               rd|	d<   d	fd}
| j                  dt        |	t        j
                        t        |||||
      t               d{   S 7 w)
r3   r4   r7   r,   c                   t              r| S | j                  D ]j  }t        t        |j                        }t        |t              s.t        j                  t        j                  |      d      j                         |_        l | S r9   r<   rF   s      r)   rH   z&AsyncEmbeddings.create.<locals>.parser   rI   r*   rJ   rK   rM   NrQ   rS   rV   s      `       r)   rX   zAsyncEmbeddings.create~   s     ^ .	
 (Y[(0F$%	" ZZ )@)V)VW(+'%" ,   
 
 	
 
s   A*A4-A2.A4)r'   r   rR   rY   rZ   r[   ra   s   @r)   r   r   w   s    55F BK( )-$("&;DS
 AS
 =	S

 ?S
 S
 &S
 "S
  S
 9S
 
!S
r*   c                      e Zd ZddZy)r   c                8    t        |j                        | _        y r"   )r   rX   r&   
embeddingss     r)   r$   z"EmbeddingsWithRawResponse.__init__   s    -
r*   N)rj   r   rR   rY   r\   r]   r^   r$    r*   r)   r   r          
r*   r   c                      e Zd ZddZy)rc   c                8    t        |j                        | _        y r"   )r   rX   ri   s     r)   r$   z'AsyncEmbeddingsWithRawResponse.__init__   s    3
r*   N)rj   r   rR   rY   rk   rl   r*   r)   rc   rc      rm   r*   rc   )+
__future__r   r7   typingr   r   r   r   typing_extensionsr   httpxtypesr
   r   _typesr   r   r   r   r   _utilsr   r   _extrasr   rB   r   	_resourcer   r   	_responser   r   _base_clientr   _clientr   r   __all__r   r   r   rc   rl   r*   r)   <module>r}      sx    #  3 3 %  D > > . !  9 N /-*
+Z
 Z
zZ
& Z
z
 

 
r*   