a
    !f#                     @  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	 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rddl#m$Z$m%Z% ddgZ&G dd deZ'G dd deZ(G dd dZ)G dd dZ*dS )    )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                      s\   e Zd ZU ded< ddd fddZeeddded	d
ddddddddd	ddZ  ZS )r   EmbeddingsWithRawResponsewith_raw_responser   Noneclientreturnc                   s   t  | t| | _d S N)super__init__r   r   selfr!   	__class__ \/var/www/html/python-backend/venv/lib/python3.9/site-packages/openai/resources/embeddings.pyr%      s    zEmbeddings.__init__Nencoding_formatuserextra_headersextra_query
extra_bodytimeout1Union[str, List[str], List[int], List[List[int]]]-Union[str, Literal['text-embedding-ada-002']]%Literal['float', 'base64'] | NotGivenstr | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr	   	inputmodelr-   r.   r/   r0   r1   r2   r"   c             
     s`   ||| d}	t  s$t r$d|	d< ddd fdd}
| jdt|	tjt|||||
d	td
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
        r<   r=   r.   r-   base64r-   r	   objr"   c                   sN   t  r| S | jD ]6}tt|j}t|ts.qtjt	
|dd |_q| S NZfloat32)Zdtyper   datar   object	embedding
isinstancestrnpZ
frombufferr@   	b64decodetolistrB   rG   rE   r-   r*   r+   parserX   s    


z!Embeddings.create.<locals>.parser/embeddingsr/   r0   r1   r2   Zpost_parserbodyoptionsZcast_tor   r   _postr   r
   ZEmbeddingCreateParamsr   r	   r'   r<   r=   r-   r.   r/   r0   r1   r2   paramsrO   r*   rN   r+   create!   s(    /
zEmbeddings.create__name__
__module____qualname____annotations__r%   r   rY   __classcell__r*   r*   r(   r+   r      s   
	c                      s\   e Zd ZU ded< ddd fddZeeddded	d
ddddddddd	ddZ  ZS )r   AsyncEmbeddingsWithRawResponser   r   r   r    c                   s   t  | t| | _d S r#   )r$   r%   r`   r   r&   r(   r*   r+   r%   z   s    zAsyncEmbeddings.__init__Nr,   r3   r4   r5   r6   r7   r8   r9   r:   r	   r;   c             
     sf   ||| d}	t  s$t r$d|	d< ddd fdd}
| jdt|	tjt|||||
d	td
I dH S )r>   r?   r@   r-   r	   rA   c                   sN   t  r| S | jD ]6}tt|j}t|ts.qtjt	
|dd |_q| S rC   rD   rM   rN   r*   r+   rO      s    


z&AsyncEmbeddings.create.<locals>.parserrP   rQ   rR   NrU   rW   r*   rN   r+   rY   ~   s(    /
zAsyncEmbeddings.createrZ   r*   r*   r(   r+   r   w   s   
	c                   @  s   e Zd ZdddddZdS )r   r   r   
embeddingsr"   c                 C  s   t |j| _d S r#   )r   rY   r'   rb   r*   r*   r+   r%      s    z"EmbeddingsWithRawResponse.__init__Nr[   r\   r]   r%   r*   r*   r*   r+   r      s   r   c                   @  s   e Zd ZdddddZdS )r`   r   r   ra   c                 C  s   t |j| _d S r#   )r   rY   rc   r*   r*   r+   r%      s    z'AsyncEmbeddingsWithRawResponse.__init__Nrd   r*   r*   r*   r+   r`      s   r`   )+
__future__r   r@   typingr   r   r   r   Ztyping_extensionsr   Zhttpxtypesr	   r
   _typesr   r   r   r   r   _utilsr   r   _extrasr   rJ   r   Z	_resourcer   r   	_responser   r   Z_base_clientr   Z_clientr   r   __all__r   r   r   r`   r*   r*   r*   r+   <module>   s&   ]]