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 ddl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mZ ddlmZm Z  ddl!m"Z"m#Z# ddl$m%Z% ddl&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,G dd dZ-G dd dZ.dS )    )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)CreateEmbeddingResponse
EmbeddingsAsyncEmbeddingsc                   @  sb   e Zd ZeddddZeddddZeeeddded	d
dddddddddd
ddZdS )r   EmbeddingsWithRawResponsereturnc                 C  s   t | S N)r   self r#   T/var/www/ai-form-bot/venv/lib/python3.9/site-packages/openai/resources/embeddings.pywith_raw_response   s    zEmbeddings.with_raw_responseEmbeddingsWithStreamingResponsec                 C  s   t | S r    )r&   r!   r#   r#   r$   with_streaming_response    s    z"Embeddings.with_streaming_responseN
dimensionsencoding_formatuserextra_headersextra_query
extra_bodytimeout=Union[str, List[str], Iterable[int], Iterable[Iterable[int]]]aUnion[str, Literal['text-embedding-ada-002', 'text-embedding-3-small', 'text-embedding-3-large']]int | NotGiven%Literal['float', 'base64'] | NotGivenstr | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   
inputmodelr)   r*   r+   r,   r-   r.   r/   r   c       	      
     sb   |||| 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`), 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.

          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.

          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
        r:   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r@   rE   rC   r*   r#   r$   parsera   s    


z!Embeddings.create.<locals>.parser/embeddingsr,   r-   r.   r/   Zpost_parserbodyoptionsZcast_tor   r   _postr   r
   ZEmbeddingCreateParamsr   r   r"   r:   r;   r)   r*   r+   r,   r-   r.   r/   paramsrM   r#   rL   r$   create$   s*    4
zEmbeddings.create__name__
__module____qualname__r   r%   r'   r   rW   r#   r#   r#   r$   r      s   c                   @  sb   e Zd ZeddddZeddddZeeeddded	d
dddddddddd
ddZdS )r   AsyncEmbeddingsWithRawResponser   c                 C  s   t | S r    )r\   r!   r#   r#   r$   r%      s    z!AsyncEmbeddings.with_raw_response$AsyncEmbeddingsWithStreamingResponsec                 C  s   t | S r    )r]   r!   r#   r#   r$   r'      s    z'AsyncEmbeddings.with_streaming_responseNr(   r0   r1   r2   r3   r4   r5   r6   r7   r8   r   r9   c       	      
     sh   |||| 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   r?   c                   sN   t  r| S | jD ]6}tt|j}t|ts.qtjt	
|dd |_q| S rA   rB   rK   rL   r#   r$   rM      s    


z&AsyncEmbeddings.create.<locals>.parserrN   rO   rP   NrS   rU   r#   rL   r$   rW      s*    4
zAsyncEmbeddings.createrX   r#   r#   r#   r$   r      s   c                   @  s   e Zd ZdddddZdS )r   r   None
embeddingsr   c                 C  s   || _ t|j| _d S r    )_embeddingsr	   Zto_raw_response_wrapperrW   r"   r`   r#   r#   r$   __init__   s    z"EmbeddingsWithRawResponse.__init__NrY   rZ   r[   rc   r#   r#   r#   r$   r      s   r   c                   @  s   e Zd ZdddddZdS )r\   r   r^   r_   c                 C  s   || _ t|j| _d S r    )ra   r	   Zasync_to_raw_response_wrapperrW   rb   r#   r#   r$   rc      s    z'AsyncEmbeddingsWithRawResponse.__init__Nrd   r#   r#   r#   r$   r\      s   r\   c                   @  s   e Zd ZdddddZdS )r&   r   r^   r_   c                 C  s   || _ t|j| _d S r    )ra   r   rW   rb   r#   r#   r$   rc      s    z(EmbeddingsWithStreamingResponse.__init__Nrd   r#   r#   r#   r$   r&      s   r&   c                   @  s   e Zd ZdddddZdS )r]   r   r^   r_   c                 C  s   || _ t|j| _d S r    )ra   r   rW   rb   r#   r#   r$   rc     s    z-AsyncEmbeddingsWithStreamingResponse.__init__Nrd   r#   r#   r#   r$   r]      s   r]   )/
__future__r   r>   typingr   r   r   r   typing_extensionsr   Zhttpx r	   typesr
   _typesr   r   r   r   r   Z_utilsr   r   _compatr   _extrasr   rH   r   Z	_resourcer   r   	_responser   r   Z_base_clientr   Ztypes.create_embedding_responser   __all__r   r   r   r\   r&   r]   r#   r#   r#   r$   <module>   s*   ee			