HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/openai/resources/__pycache__/embeddings.cpython-310.pyc
o

���g/�@sPddlmZddlZddlZddlmZmZmZmZddl	m
Z
ddlZddlm
Z
ddlmZddlmZmZmZmZmZdd	lmZmZdd
lmZddlmZmZddlm Z m!Z!dd
l"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddgZ+Gdd�de �Z,Gdd�de!�Z-Gdd�d�Z.Gdd�d�Z/Gdd�d�Z0Gdd�d�Z1dS)�)�annotationsN)�List�Union�Iterable�cast)�Literal�)�_legacy_response)�embedding_create_params)�	NOT_GIVEN�Body�Query�Headers�NotGiven)�is_given�maybe_transform)�cached_property)�numpy�	has_numpy)�SyncAPIResource�AsyncAPIResource)�to_streamed_response_wrapper�"async_to_streamed_response_wrapper)�make_request_options)�EmbeddingModel)�CreateEmbeddingResponse�
Embeddings�AsyncEmbeddingsc@�DeZdZeddd��Zed dd��Zeeeddded	�d!dd�ZdS)"r�return�EmbeddingsWithRawResponsecC�t|�S�a
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r ��self�r%�F/usr/local/lib/python3.10/dist-packages/openai/resources/embeddings.py�with_raw_response�zEmbeddings.with_raw_response�EmbeddingsWithStreamingResponsecCr!�z�
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )r)r#r%r%r&�with_streaming_response&�z"Embeddings.with_streaming_responseN��
dimensions�encoding_format�user�
extra_headers�extra_query�
extra_body�timeout�input�=Union[str, List[str], Iterable[int], Iterable[Iterable[int]]]�model�Union[str, EmbeddingModel]r.�int | NotGivenr/�%Literal['float', 'base64'] | NotGivenr0�str | NotGivenr1�Headers | Noner2�Query | Noner3�Body | Noner4�'float | httpx.Timeout | None | NotGivenrc	
sV||||�d�}
t��sd|
d<d
�fdd�}|jd	t|
tj�t||||	|d
�td�S)�c
        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`), cannot be an empty string, and any array must be 2048
              dimensions or less.
              [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
              for counting tokens. Some models may also impose a limit on total number of
              tokens summed across inputs.

          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) for descriptions of
              them.

          dimensions: The number of dimensions the resulting output embeddings should have. Only
              supported in `text-embedding-3` and later models.

          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
        �r5r7r0r.r/�base64r/�objrrc�nt��r|S|jD]+}tt|j�}t|t�sq	t�s't�dt	�
|����|_q	tj
t	�
|�dd���|_q	|S�N�f�float32)�dtype�r�datar�object�	embedding�
isinstance�strr�arrayrB�	b64decode�tolist�np�
frombuffer�rCrLrJ�r/r%r&�parserm�


��z!Embeddings.create.<locals>.parser�/embeddings�r1r2r3r4�post_parser��body�options�cast_toN�rCrrr�r�_postrr
�EmbeddingCreateParamsrr�r$r5r7r.r/r0r1r2r3r4�paramsrVr%rUr&�create/s*5�
��zEmbeddings.create)rr )rr)�r5r6r7r8r.r9r/r:r0r;r1r<r2r=r3r>r4r?rr��__name__�
__module__�__qualname__rr'r+rrer%r%r%r&r�	
�c@r)"rr�AsyncEmbeddingsWithRawResponsecCr!r")rlr#r%r%r&r'�r(z!AsyncEmbeddings.with_raw_response�$AsyncEmbeddingsWithStreamingResponsecCr!r*)rmr#r%r%r&r+�r,z'AsyncEmbeddings.with_streaming_responseNr-r5r6r7r8r.r9r/r:r0r;r1r<r2r=r3r>r4r?rc	
�s^�||||�d�}
t��sd|
d<d
�fdd�}|jd	t|
tj�t||||	|d
�td�IdHS)r@rArBr/rCrrcrDrErIrTrUr%r&rV�rWz&AsyncEmbeddings.create.<locals>.parserrXrYr[Nr_r`rcr%rUr&re�s,�5�
��zAsyncEmbeddings.create)rrl)rrmrfrgr%r%r%r&r�rkc@�eZdZddd�ZdS)	r �
embeddingsrr�NonecC�||_t�|j�|_dS�N)�_embeddingsr	�to_raw_response_wrapperre�r$ror%r%r&�__init__�
�z"EmbeddingsWithRawResponse.__init__N�rorrrp�rhrirjrvr%r%r%r&r �r c@rn)	rlrorrrpcCrqrr)rsr	�async_to_raw_response_wrapperrerur%r%r&rvrwz'AsyncEmbeddingsWithRawResponse.__init__N�rorrrpryr%r%r%r&rl
rzrlc@rn)	r)rorrrpcC�||_t|j�|_dSrr)rsrrerur%r%r&rv�
�z(EmbeddingsWithStreamingResponse.__init__Nrxryr%r%r%r&r)rzr)c@rn)	rmrorrrpcCr}rr)rsrrerur%r%r&rvr~z-AsyncEmbeddingsWithStreamingResponse.__init__Nr|ryr%r%r%r&rmrzrm)2�
__future__rrOrB�typingrrrr�typing_extensionsr�httpx�r	�typesr
�_typesrrr
rr�_utilsrr�_compatr�_extrasrrRr�	_resourcerr�	_responserr�_base_clientr�types.embedding_modelr�types.create_embedding_responser�__all__rrr rlr)rmr%r%r%r&�<module>s0ss