o
    Cji#                     @  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rjd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                      B   e Zd ZU ded< d fddZeed	d	d	ed
dddZ  ZS ) r   EmbeddingsWithRawResponsewith_raw_responseclientr   returnNonec                      t  | t| | _d S N)super__init__r   r   selfr    	__class__ r/var/www/html/Resume-Parser/resume-parser-inhouse/venv/lib/python3.10/site-packages/openai/resources/embeddings.pyr&         zEmbeddings.__init__Nencoding_formatuserextra_headersextra_query
extra_bodytimeoutinput1Union[str, List[str], List[int], List[List[int]]]model-Union[str, Literal['text-embedding-ada-002']]r/   %Literal['float', 'base64'] | NotGivenr0   str | NotGivenr1   Headers | Noner2   Query | Noner3   Body | Noner4   'float | httpx.Timeout | None | NotGivenr	   c             
     sZ   ||| 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`) 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
        r5   r7   r0   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
frombufferrA   	b64decodetolistrB   rJ   rH   r/   r+   r,   parserX      


z!Embeddings.create.<locals>.parser/embeddingsr1   r2   r3   r4   post_parserbodyoptionscast_toNrB   r	   r!   r	   r   r   _postr   r
   EmbeddingCreateParamsr   r	   r(   r5   r7   r/   r0   r1   r2   r3   r4   paramsrS   r+   rR   r,   create!   s(   /
zEmbeddings.create)r    r   r!   r"   r5   r6   r7   r8   r/   r9   r0   r:   r1   r;   r2   r<   r3   r=   r4   r>   r!   r	   __name__
__module____qualname____annotations__r&   r   rb   __classcell__r+   r+   r)   r,   r         
 	c                      r   ) r   AsyncEmbeddingsWithRawResponser   r    r   r!   r"   c                   r#   r$   )r%   r&   rk   r   r'   r)   r+   r,   r&   z   r-   zAsyncEmbeddings.__init__Nr.   r5   r6   r7   r8   r/   r9   r0   r:   r1   r;   r2   r<   r3   r=   r4   r>   r	   c             
     sb   ||| 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@   rA   r/   rB   r	   r!   c                   rC   rD   rG   rQ   rR   r+   r,   rS      rT   z&AsyncEmbeddings.create.<locals>.parserrU   rV   rX   Nr\   r]   r`   r+   rR   r,   rb   ~   s*   /
zAsyncEmbeddings.create)r    r   r!   r"   rc   rd   r+   r+   r)   r,   r   w   rj   c                   @     e Zd ZdddZdS )	r   
embeddingsr   r!   r"   c                 C     t |j| _d S r$   )r   rb   r(   rm   r+   r+   r,   r&         
z"EmbeddingsWithRawResponse.__init__N)rm   r   r!   r"   re   rf   rg   r&   r+   r+   r+   r,   r          r   c                   @  rl   )	rk   rm   r   r!   r"   c                 C  rn   r$   )r   rb   ro   r+   r+   r,   r&      rp   z'AsyncEmbeddingsWithRawResponse.__init__N)rm   r   r!   r"   rq   r+   r+   r+   r,   rk      rr   rk   )+
__future__r   rA   typingr   r   r   r   typing_extensionsr   httpxtypesr	   r
   _typesr   r   r   r   r   _utilsr   r   _extrasr   rM   r   	_resourcer   r   	_responser   r   _base_clientr   _clientr   r   __all__r   r   r   rk   r+   r+   r+   r,   <module>   s(   ]]