o
    \h-                     @  sH  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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Z0d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)EmbeddingModel)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 a  
        This property can be used as a prefix for any HTTP method call to return the
        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%   ^/home/air/segue/gemini/backup/venv/lib/python3.10/site-packages/openai/resources/embeddings.pywith_raw_response      zEmbeddings.with_raw_responseEmbeddingsWithStreamingResponsec                 C  r!   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 | 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
        r5   r7   r0   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
frombufferrB   	b64decodetolistrC   rK   rI   r/   r%   r&   parserk      


z!Embeddings.create.<locals>.parser/embeddingsr1   r2   r3   r4   post_parserbodyoptionscast_toNrC   r   r   r   r   r   _postr   r
   EmbeddingCreateParamsr   r   r$   r5   r7   r.   r/   r0   r1   r2   r3   r4   paramsrT   r%   rS   r&   create.   s*   4
zEmbeddings.create)r   r    )r   r)   r5   r6   r7   r8   r.   r9   r/   r:   r0   r;   r1   r<   r2   r=   r3   r>   r4   r?   r   r   __name__
__module____qualname__r   r'   r+   r   rc   r%   r%   r%   r&   r          	c                   @  r   )"r   r   AsyncEmbeddingsWithRawResponsec                 C  r!   r"   )rj   r#   r%   r%   r&   r'      r(   z!AsyncEmbeddings.with_raw_response$AsyncEmbeddingsWithStreamingResponsec                 C  r!   r*   )rk   r#   r%   r%   r&   r+      r,   z'AsyncEmbeddings.with_streaming_responseNr-   r5   r6   r7   r8   r.   r9   r/   r:   r0   r;   r1   r<   r2   r=   r3   r>   r4   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@   rA   rB   r/   rC   r   r   c                   rD   rE   rH   rR   rS   r%   r&   rT      rU   z&AsyncEmbeddings.create.<locals>.parserrV   rW   rY   Nr]   r^   ra   r%   rS   r&   rc      s,   4
zAsyncEmbeddings.create)r   rj   )r   rk   rd   re   r%   r%   r%   r&   r      ri   c                   @     e Zd ZdddZdS )	r    
embeddingsr   r   Nonec                 C     || _ t|j| _d S N)_embeddingsr	   to_raw_response_wrapperrc   r$   rm   r%   r%   r&   __init__      
z"EmbeddingsWithRawResponse.__init__Nrm   r   r   rn   rf   rg   rh   rt   r%   r%   r%   r&   r           r    c                   @  rl   )	rj   rm   r   r   rn   c                 C  ro   rp   )rq   r	   async_to_raw_response_wrapperrc   rs   r%   r%   r&   rt     ru   z'AsyncEmbeddingsWithRawResponse.__init__Nrm   r   r   rn   rw   r%   r%   r%   r&   rj     rx   rj   c                   @  rl   )	r)   rm   r   r   rn   c                 C     || _ t|j| _d S rp   )rq   r   rc   rs   r%   r%   r&   rt        
z(EmbeddingsWithStreamingResponse.__init__Nrv   rw   r%   r%   r%   r&   r)     rx   r)   c                   @  rl   )	rk   rm   r   r   rn   c                 C  r{   rp   )rq   r   rc   rs   r%   r%   r&   rt     r|   z-AsyncEmbeddingsWithStreamingResponse.__init__Nrz   rw   r%   r%   r%   r&   rk     rx   rk   )1
__future__r   rB   typingr   r   r   r   typing_extensionsr   httpx r	   typesr
   _typesr   r   r   r   r   _utilsr   r   _compatr   _extrasr   rN   r   	_resourcer   r   	_responser   r   _base_clientr   types.embedding_modelr   types.create_embedding_responser   __all__r   r   r    rj   r)   rk   r%   r%   r%   r&   <module>   s.   pp			