
    OYhf*                    `   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e      Z) G d de       Z* G d d      Z+ G d d      Z, G d d      Z- G d d      Z.y)    )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                  p    e Zd Zedd       Zedd       Zeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)	r   c                    t        |       S N)EmbeddingsWithRawResponseselfs    Z/var/www/feuerwehr-webapp/venv/lib/python3.12/site-packages/openai/resources/embeddings.pywith_raw_responsezEmbeddings.with_raw_response   s    (..    c                    t        |       S r    )EmbeddingsWithStreamingResponser"   s    r$   with_streaming_responsez"Embeddings.with_streaming_response    s    .t44r&   N
dimensionsencoding_formatuserextra_headersextra_query
extra_bodytimeoutc       	            ||||d}
t              st               rd|
d<   dfd}| j                  dt        |
t        j
                        t        ||||	|      t              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
        inputmodelr-   r+   r,   base64r,   c                   t              r| S | j                  D ]j  }t        t        |j                        }t        |t              s.t        j                  t        j                  |      d      j                         |_        l | S Nfloat32)dtyper   datar   object	embedding
isinstancestrnp
frombufferr7   	b64decodetolistobjr?   r=   r,   s      r$   parserz!Embeddings.create.<locals>.parsera   t    (
 XX 	FI$7$78!$,&(mm$$T*)'&( # Jr&   /embeddingsr.   r/   r0   r1   post_parserbodyoptionscast_torG   r   returnr   r   r   _postr   r   EmbeddingCreateParamsr   r   r#   r5   r6   r+   r,   r-   r.   r/   r0   r1   paramsrH   s       `       r$   createzEmbeddings.create$   s    h $.
 (Y[(0F$%	" zz )@)V)VW(+'%" ,  
 	
r&   )rR   r!   )rR   r(   r5   z=Union[str, List[str], Iterable[int], Iterable[Iterable[int]]]r6   zaUnion[str, Literal['text-embedding-ada-002', 'text-embedding-3-small', 'text-embedding-3-large']]r+   zint | NotGivenr,   z%Literal['float', 'base64'] | NotGivenr-   zstr | NotGivenr.   zHeaders | Noner/   zQuery | Noner0   zBody | Noner1   z'float | httpx.Timeout | None | NotGivenrR   r   __name__
__module____qualname__r   r%   r)   r   rX    r&   r$   r   r      s    / / 5 5 &/AJ( )-$("&;DY
 MY
 q	Y

 #Y
 ?Y
 Y
 &Y
 "Y
  Y
 9Y
 
!Y
r&   c                  p    e Zd Zedd       Zedd       Zeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)	r   c                    t        |       S r    )AsyncEmbeddingsWithRawResponser"   s    r$   r%   z!AsyncEmbeddings.with_raw_response   s    -d33r&   c                    t        |       S r    )$AsyncEmbeddingsWithStreamingResponser"   s    r$   r)   z'AsyncEmbeddings.with_streaming_response   s    3D99r&   Nr*   c       	           K   ||||d}
t              st               rd|
d<   d	fd}| j                  dt        |
t        j
                        t        ||||	|      t               d{   S 7 w)
r3   r4   r7   r,   c                   t              r| S | j                  D ]j  }t        t        |j                        }t        |t              s.t        j                  t        j                  |      d      j                         |_        l | S r9   r<   rF   s      r$   rH   z&AsyncEmbeddings.create.<locals>.parser   rI   r&   rJ   rK   rM   NrQ   rS   rV   s       `       r$   rX   zAsyncEmbeddings.create   s     h $.
 (Y[(0F$%	" ZZ )@)V)VW(+'%" ,   
 
 	
 
s   A+A5.A3/A5)rR   ra   )rR   rc   rY   rZ   r^   r&   r$   r   r      s    4 4 : : &/AJ( )-$("&;DY
 MY
 q	Y

 #Y
 ?Y
 Y
 &Y
 "Y
  Y
 9Y
 
!Y
r&   c                      e Zd ZddZy)r!   c                Z    || _         t        j                  |j                        | _        y r    )_embeddingsr
   to_raw_response_wrapperrX   r#   
embeddingss     r$   __init__z"EmbeddingsWithRawResponse.__init__   s%    %&>>
r&   Nrk   r   rR   Noner[   r\   r]   rl   r^   r&   r$   r!   r!          
r&   r!   c                      e Zd ZddZy)ra   c                Z    || _         t        j                  |j                        | _        y r    )rh   r
   async_to_raw_response_wrapperrX   rj   s     r$   rl   z'AsyncEmbeddingsWithRawResponse.__init__   s%    %&DD
r&   Nrk   r   rR   rn   ro   r^   r&   r$   ra   ra      rp   r&   ra   c                      e Zd ZddZy)r(   c                F    || _         t        |j                        | _        y r    )rh   r   rX   rj   s     r$   rl   z(EmbeddingsWithStreamingResponse.__init__   s    %2
r&   Nrm   ro   r^   r&   r$   r(   r(      rp   r&   r(   c                      e Zd ZddZy)rc   c                F    || _         t        |j                        | _        y r    )rh   r   rX   rj   s     r$   rl   z-AsyncEmbeddingsWithStreamingResponse.__init__  s    %8
r&   Nrt   ro   r^   r&   r$   rc   rc      rp   r&   rc   )/
__future__r   r7   typingr   r   r   r   typing_extensionsr   httpx r
   typesr   _typesr   r   r   r   r   _utilsr   r   _compatr   _extrasr   rB   r   	_resourcer   r   	_responser   r   _base_clientr   types.create_embedding_responser   __all__r   r   r!   ra   r(   rc   r^   r&   r$   <module>r      s    #  . . %   + > > . % , 9 X F*
+b
 b
Jb
& b
J
 

 

 

 
r&   