o
    +Âif*  ã                   @  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                   @  óD   e Zd Zeddd„ƒZed dd„ƒZeeeddded	œd!dd„ZdS )"r   ÚreturnÚEmbeddingsWithRawResponsec                 C  ó   t | ƒS ©N)r   ©Úself© r$   úT/var/www/html/corbot_env/lib/python3.10/site-packages/openai/resources/embeddings.pyÚwith_raw_response   ó   zEmbeddings.with_raw_responseÚEmbeddingsWithStreamingResponsec                 C  r    r!   )r(   r"   r$   r$   r%   Úwith_streaming_response    r'   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úaUnion[str, Literal['text-embedding-ada-002', 'text-embedding-3-small', 'text-embedding-3-large']]r+   úint | NotGivenr,   ú%Literal['float', 'base64'] | NotGivenr-   ústr | NotGivenr.   úHeaders | Noner/   úQuery | Noner0   úBody | Noner1   ú'float | httpx.Timeout | None | NotGivenr   c       	      
     s\   ||||ˆ dœ}
t ˆ ƒstƒ r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
        ©r2   r4   r-   r+   r,   Úbase64r,   Úobjr   r   c                   óN   t ˆ ƒr| S | jD ]}tt|jƒ}t|tƒsq	tjt	 
|¡dd� ¡ |_q	| S ©NÚfloat32)Údtype©r   Údatar   ÚobjectÚ	embeddingÚ
isinstanceÚstrÚnpÚ
frombufferr?   Ú	b64decodeÚtolist©r@   rH   rF   ©r,   r$   r%   Úparsera   ó   


ÿþz!Embeddings.create.<locals>.parserú/embeddings©r.   r/   r0   r1   Úpost_parser©ÚbodyÚoptionsÚcast_toN©r@   r   r   r   ©r   r   Ú_postr   r
   ÚEmbeddingCreateParamsr   r   ©r#   r2   r4   r+   r,   r-   r.   r/   r0   r1   ÚparamsrQ   r$   rP   r%   Úcreate$   s*   4û
ûözEmbeddings.create)r   r   )r   r(   ©r2   r3   r4   r5   r+   r6   r,   r7   r-   r8   r.   r9   r/   r:   r0   r;   r1   r<   r   r   ©Ú__name__Ú
__module__Ú__qualname__r   r&   r)   r   r`   r$   r$   r$   r%   r      ó    óc                   @  r   )"r   r   ÚAsyncEmbeddingsWithRawResponsec                 C  r    r!   )rg   r"   r$   r$   r%   r&   �   r'   z!AsyncEmbeddings.with_raw_responseÚ$AsyncEmbeddingsWithStreamingResponsec                 C  r    r!   )rh   r"   r$   r$   r%   r)   …   r'   z'AsyncEmbeddings.with_streaming_responseNr*   r2   r3   r4   r5   r+   r6   r,   r7   r-   r8   r.   r9   r/   r:   r0   r;   r1   r<   r   c       	      
   ƒ  sd   �||||ˆ dœ}
t ˆ ƒstƒ r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   r   c                   rA   rB   rE   rO   rP   r$   r%   rQ   Æ   rR   z&AsyncEmbeddings.create.<locals>.parserrS   rT   rV   NrZ   r[   r^   r$   rP   r%   r`   ‰   s,   €4û
ûözAsyncEmbeddings.create)r   rg   )r   rh   ra   rb   r$   r$   r$   r%   r   €   rf   c                   @  ó   e Zd Zddd„ZdS )	r   Ú
embeddingsr   r   ÚNonec                 C  ó   || _ t |j¡| _d S r!   )Ú_embeddingsr	   Úto_raw_response_wrapperr`   ©r#   rj   r$   r$   r%   Ú__init__æ   ó   
ÿz"EmbeddingsWithRawResponse.__init__N©rj   r   r   rk   ©rc   rd   re   rp   r$   r$   r$   r%   r   å   ó    r   c                   @  ri   )	rg   rj   r   r   rk   c                 C  rl   r!   )rm   r	   Úasync_to_raw_response_wrapperr`   ro   r$   r$   r%   rp   ï   rq   z'AsyncEmbeddingsWithRawResponse.__init__N©rj   r   r   rk   rs   r$   r$   r$   r%   rg   î   rt   rg   c                   @  ri   )	r(   rj   r   r   rk   c                 C  ó   || _ t|jƒ| _d S r!   )rm   r   r`   ro   r$   r$   r%   rp   ø   ó   
ÿz(EmbeddingsWithStreamingResponse.__init__Nrr   rs   r$   r$   r$   r%   r(   ÷   rt   r(   c                   @  ri   )	rh   rj   r   r   rk   c                 C  rw   r!   )rm   r   r`   ro   r$   r$   r%   rp     rx   z-AsyncEmbeddingsWithStreamingResponse.__init__Nrv   rs   r$   r$   r$   r%   rh      rt   rh   )/Ú
__future__r   r?   Útypingr   r   r   r   Útyping_extensionsr   ÚhttpxÚ r	   Útypesr
   Ú_typesr   r   r   r   r   Ú_utilsr   r   Ú_compatr   Ú_extrasr   rK   r   Ú	_resourcer   r   Ú	_responser   r   Ú_base_clientr   Útypes.create_embedding_responser   Ú__all__r   r   r   rg   r(   rh   r$   r$   r$   r%   Ú<module>   s,   ee			