o
    i/                     @  s  d dl mZ d dlmZmZmZ d dlmZmZ d dl	Z	ddl
mZ ddlmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZ dd	lm Z m!Z!m"Z"m#Z#m$Z$ dd
l%m&Z& ddl'm(Z(m)Z) ddl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z: ddl;mZ ddl<mZ ddl=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddgZEG dd de(ZFG dd de)ZGG dd dZHG dd dZIG dd  d ZJG d!d" d"ZKdS )#    )annotations)TYPE_CHECKINGMappingcast)Literalassert_neverN   )_legacy_response)		VideoSizeVideoSecondsvideo_edit_paramsvideo_list_paramsvideo_remix_paramsvideo_create_paramsvideo_extend_paramsvideo_create_character_paramsvideo_download_content_params)BodyOmitQueryHeadersNotGiven	FileTypesomit	not_given)extract_filespath_templatemaybe_transformdeepcopy_minimalasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)StreamedBinaryAPIResponseAsyncStreamedBinaryAPIResponseto_streamed_response_wrapper"async_to_streamed_response_wrapper#to_custom_streamed_response_wrapper)async_to_custom_streamed_response_wrapper)SyncConversationCursorPageAsyncConversationCursorPage)Video)AsyncPaginatormake_request_options)is_given)r
   )r   )VideoModelParam)VideoDeleteResponse)VideoGetCharacterResponse)VideoCreateCharacterResponseVideosAsyncVideosc                
   @  D  e Zd ZedPddZedQddZeeeeddded	dRddZeeeeeddded	dSd"d#Z	ed$dTd&d'Z
ddded(dUd)d*Zeeeddded+dVd2d3Zddded(dWd5d6Zddded(dXd;d<Zeddded=dYdAdBZddded(dZdDdEZddded(d[dHdIZddded(d\dLdMZddded(d]dNdOZdS )^r3   returnVideosWithRawResponsec                 C     t | S a  
        This property can be used as a prefix for any HTTP method call to return
        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
        )r7   self r<   Q/home/kim/smarthome/.venv/lib/python3.10/site-packages/openai/resources/videos.pywith_raw_response1      zVideos.with_raw_responseVideosWithStreamingResponsec                 C  r8   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Videos.with_streaming_responseNinput_referencemodelsecondssizeextra_headersextra_query
extra_bodytimeoutpromptstrrE   )video_create_params.InputReference | OmitrF   VideoModelParam | OmitrG   VideoSeconds | OmitrH   VideoSize | OmitrI   Headers | NonerJ   Query | NonerK   Body | NonerL   'float | httpx.Timeout | None | NotGivenr+   c       	      
   C  sj   t |||||d}
tttttf |
dggd}ddi|pi }| jdt|
tj	|t
||||	dtdS )	  
        Create a new video generation job from a prompt and optional reference assets.

        Args:
          prompt: Text prompt that describes the video to generate.

          input_reference: Optional reference asset upload or reference object that guides generation.

          model: The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults
              to `sora-2`.

          seconds: Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

          size: Output resolution formatted as width x height (allowed values: 720x1280,
              1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

          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
        rM   rE   rF   rG   rH   rE   pathsContent-Typemultipart/form-data/videosrI   rJ   rK   rL   bodyfilesoptionscast_to)r   r   r   r   rN   object_postr   r   VideoCreateParamsr-   r+   r;   rM   rE   rF   rG   rH   rI   rJ   rK   rL   r`   ra   r<   r<   r=   createD   s&   '	
zVideos.create	rE   rF   rG   rH   poll_interval_msrI   rJ   rK   rL   rj   
int | Omitc       
         C  s,   | j ||||||||	|
d	}| j|j|dS )/Create a video and wait for it to be processed.	rF   rM   rE   rG   rH   rI   rJ   rK   rL   rj   rh   pollidr;   rM   rE   rF   rG   rH   rj   rI   rJ   rK   rL   videor<   r<   r=   create_and_poll   s   zVideos.create_and_pollrn   video_idc                C  s   ddi}t |rt||d< 	 | jj||d}| }|jdks%|jdkrBt |s:|jd}|d	ur8t|}nd
}| 	|d
  n|jdksL|jdkrN|S t
rVt|j n|S q)Wait for the vector store file to finish processing.

        Note: this will return even if the file failed to process, you need to check
        file.last_error and file.status to handle these cases
        X-Stainless-Poll-Helpertrue X-Stainless-Custom-Poll-IntervalTrI   in_progressqueuedopenai-poll-after-msN  	completedfailedr.   rN   r>   retrieveparsestatusheadersgetintZ_sleepr   r   r;   ru   rj   r   responsers   Zfrom_headerr<   r<   r=   rp      s,   
zVideos.pollr^   c                C  6   |s	t d|| jtd|dt||||dtdS )d  
        Fetch the latest metadata for a generated video.

        Args:
          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
        7Expected a non-empty value for `video_id` but received /videos/{video_id}ru   r^   rb   rc   
ValueError_getr   r-   r+   r;   ru   rI   rJ   rK   rL   r<   r<   r=   r         
zVideos.retrieveafterlimitorderrI   rJ   rK   rL   r   
str | Omitr   r   Literal['asc', 'desc'] | Omit!SyncConversationCursorPage[Video]c                C  4   | j dtt t||||t|||dtjdtdS ao  
        List recently generated videos for the current project.

        Args:
          after: Identifier for the last item from the previous pagination request

          limit: Number of items to retrieve

          order: Sort order of results by timestamp. Use `asc` for ascending order or `desc` for
              descending order.

          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   rI   rJ   rK   rL   query)pagerb   rF   )_get_api_listr)   r+   r-   r   r   VideoListParamsr;   r   r   r   rI   rJ   rK   rL   r<   r<   r=   list   $    zVideos.listr0   c                C  r   )y  
        Permanently delete a completed or failed video and its stored assets.

        Args:
          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   r   _deleter   r-   r0   r   r<   r<   r=   delete!  r   zVideos.deletenamers   r   r2   c          	   
   C  d   t ||d}tttttf |dggd}ddi|pi }| jdt|tj	|t
||||dtdS )	  
        Create a character from an uploaded video.

        Args:
          name: Display name for this API character.

          video: Video file used to create a character.

          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   rs   rs   rY   r[   r\   /videos/charactersr^   r_   )r   r   r   r   rN   rd   re   r   r   VideoCreateCharacterParamsr-   r2   	r;   r   rs   rI   rJ   rK   rL   r`   ra   r<   r<   r=   create_characterB  s    
zVideos.create_charactervariantrI   rJ   rK   rL   r   3Literal['video', 'thumbnail', 'spritesheet'] | Omit+_legacy_response.HttpxBinaryResponseContentc             
   C  sV   |s	t d|ddi|pi }| jtd|dt||||td|itjdtjdS )	  
        Download the generated video bytes or a derived preview asset.

        Streams the rendered video content for the specified video job.

        Args:
          variant: Which downloadable asset to return. Defaults to the MP4 video.

          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   Acceptapplication/binary/videos/{video_id}/contentr   r   r   r   )	r   r   r   r-   r   r   VideoDownloadContentParamsr	   HttpxBinaryResponseContentr;   ru   r   rI   rJ   rK   rL   r<   r<   r=   download_contents  s   
zVideos.download_contentvideo_edit_params.Videoc          	   
   C  r   )	  
        Create a new video generation job by editing a source video or existing
        generated video.

        Args:
          prompt: Text prompt that describes how to edit the source video.

          video: Reference to the completed video to edit.

          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
        rM   rs   rs   rY   r[   r\   /videos/editsr^   r_   )r   r   r   r   rN   rd   re   r   r   VideoEditParamsr-   r+   	r;   rM   rs   rI   rJ   rK   rL   r`   ra   r<   r<   r=   edit  s    
zVideos.editr   video_extend_params.Videoc          
   
   C  sf   t |||d}tttttf |dggd}	ddi|pi }| jdt|tj	|	t
||||dtdS )	j  
        Create an extension of a completed video.

        Args:
          prompt: Updated text prompt that directs the extension generation.

          seconds: Length of the newly generated extension segment in seconds (allowed values: 4,
              8, 12, 16, 20).

          video: Reference to the completed video to extend.

          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
        rM   rG   rs   rs   rY   r[   r\   /videos/extensionsr^   r_   )r   r   r   r   rN   rd   re   r   r   VideoExtendParamsr-   r+   
r;   rM   rG   rs   rI   rJ   rK   rL   r`   ra   r<   r<   r=   extend  s"    
zVideos.extendcharacter_idr1   c                C  r   )F  
        Fetch a character.

        Args:
          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
        ;Expected a non-empty value for `character_id` but received !/videos/characters/{character_id}r   r^   r   r   r   r   r-   r1   r;   r   rI   rJ   rK   rL   r<   r<   r=   get_character  r   zVideos.get_characterc             	   C  sD   |s	t d|| jtd|dtd|itjt||||dtdS )  
        Create a remix of a completed video using a refreshed prompt.

        Args:
          prompt: Updated text prompt that directs the remix generation.

          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   /videos/{video_id}/remixr   rM   r^   r`   rb   rc   )r   re   r   r   r   VideoRemixParamsr-   r+   r;   ru   rM   rI   rJ   rK   rL   r<   r<   r=   remix'  s   
zVideos.remix)r6   r7   )r6   r@   rM   rN   rE   rO   rF   rP   rG   rQ   rH   rR   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r+   rM   rN   rE   rO   rF   rP   rG   rQ   rH   rR   rj   rk   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r+   ru   rN   rj   rk   r6   r+   ru   rN   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r+   )r   r   r   rk   r   r   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r   ru   rN   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r0   r   rN   rs   r   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r2   ru   rN   r   r   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r   rM   rN   rs   r   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r+   rM   rN   rG   r   rs   r   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r+   r   rN   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r1   ru   rN   rM   rN   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r+   __name__
__module____qualname__r    r>   rB   r   r   rh   rt   rp   r   r   r   r   r   r   r   r   r   r<   r<   r<   r=   r3   0   s    	C&-$:(52:<(c                
   @  r5   )^r4   r6   AsyncVideosWithRawResponsec                 C  r8   r9   )r   r:   r<   r<   r=   r>   N  r?   zAsyncVideos.with_raw_response AsyncVideosWithStreamingResponsec                 C  r8   rA   )r   r:   r<   r<   r=   rB   X  rC   z#AsyncVideos.with_streaming_responseNrD   rM   rN   rE   rO   rF   rP   rG   rQ   rH   rR   rI   rS   rJ   rT   rK   rU   rL   rV   r+   c       	      
     sx   t |||||d}
tttttf |
dggd}ddi|p i }| jdt|
tj	I dH |t
||||	dtd	I dH S )
rW   rX   rE   rY   r[   r\   r]   Nr^   r_   )r   r   r   r   rN   rd   re   r   r   rf   r-   r+   rg   r<   r<   r=   rh   a  s(   '	zAsyncVideos.createri   rj   rk   c       
           s:   | j ||||||||	|
d	I dH }| j|j|dI dH S )rl   rm   Nrn   ro   rr   r<   r<   r=   rt     s    zAsyncVideos.create_and_pollrn   ru   c                  s   ddi}t |rt||d< 	 | jj||dI dH }| }|jdks)|jdkrIt |s>|jd	}|dur<t|}nd
}| 	|d
 I dH  n|jdksS|jdkrU|S t
r]t|j n|S q)rv   rw   rx   ry   Trz   Nr{   r|   r}   r~   r   r   r   r   r<   r<   r=   rp     s.   
zAsyncVideos.pollr^   c                  >   |s
t d|| jtd|dt||||dtdI dH S )r   r   r   r   r^   r   Nr   r   r<   r<   r=   r        
zAsyncVideos.retriever   r   r   r   r   r   9AsyncPaginator[Video, AsyncConversationCursorPage[Video]]c                C  r   r   )r   r*   r+   r-   r   r   r   r   r<   r<   r=   r   
  r   zAsyncVideos.listr0   c                  r   )r   r   r   r   r^   r   Nr   r   r<   r<   r=   r   >  r   zAsyncVideos.deleter   rs   r   r2   c          	   
     r   t ||d}tttttf |dggd}ddi|pi }| jdt|tj	I dH |t
||||dtd	I dH S )
r   r   rs   rY   r[   r\   r   Nr^   r_   )r   r   r   r   rN   rd   re   r   r   r   r-   r2   r   r<   r<   r=   r   _  s"   zAsyncVideos.create_characterr   r   r   r   c             
     sd   |s
t d|ddi|pi }| jtd|dt||||td|itjI dH dtjd	I dH S )
r   r   r   r   r   r   r   Nr   r   )	r   r   r   r-   r   r   r   r	   r   r   r<   r<   r=   r     s"   

	zAsyncVideos.download_contentr   c          	   
     r   )
r   r   rs   rY   r[   r\   r   Nr^   r_   )r   r   r   r   rN   rd   re   r   r   r   r-   r+   r   r<   r<   r=   r     s"   zAsyncVideos.editr   r   c          
   
     st   t |||d}tttttf |dggd}	ddi|pi }| jdt|tj	I dH |	t
||||dtd	I dH S )
r   r   rs   rY   r[   r\   r   Nr^   r_   )r   r   r   r   rN   rd   re   r   r   r   r-   r+   r   r<   r<   r=   r     s$    zAsyncVideos.extendr   r1   c                  r   )r   r   r   r   r^   r   Nr   r   r<   r<   r=   r   %  r   zAsyncVideos.get_characterc             	     sR   |s
t d|| jtd|dtd|itjI dH t||||dtdI dH S )r   r   r   r   rM   Nr^   r   )r   re   r   r   r   r   r-   r+   r   r<   r<   r=   r   F  s   
zAsyncVideos.remix)r6   r   )r6   r   r   r   r   r   )r   r   r   rk   r   r   rI   rS   rJ   rT   rK   rU   rL   rV   r6   r   r   r   r   r   r   r   r   r   r<   r<   r<   r=   r4   M  s    	C&-$:(54:<(c                   @     e Zd ZdddZdS )	r7   videosr3   r6   Nonec                 C     || _ t|j| _t|j| _t|j| _t|j| _t|j| _t|j| _t|j	| _	t|j
| _
t|j| _t|j| _d S N)_videosr	   Zto_raw_response_wrapperrh   r   r   r   r   r   r   r   r   r   r;   r   r<   r<   r=   __init__m  >   
zVideosWithRawResponse.__init__Nr   r3   r6   r   r   r   r   r   r<   r<   r<   r=   r7   l      r7   c                   @  r   )	r   r   r4   r6   r   c                 C  r   r   )r   r	   Zasync_to_raw_response_wrapperrh   r   r   r   r   r   r   r   r   r   r   r<   r<   r=   r     r   z#AsyncVideosWithRawResponse.__init__Nr   r4   r6   r   r   r<   r<   r<   r=   r     r   r   c                   @  r   )	r@   r   r3   r6   r   c                 C     || _ t|j| _t|j| _t|j| _t|j| _t|j| _t|jt	| _t|j
| _
t|j| _t|j| _t|j| _d S r   )r   r%   rh   r   r   r   r   r'   r   r#   r   r   r   r   r   r<   r<   r=   r     @   
z$VideosWithStreamingResponse.__init__Nr   r   r<   r<   r<   r=   r@     r   r@   c                   @  r   )	r   r   r4   r6   r   c                 C  r   r   )r   r&   rh   r   r   r   r   r(   r   r$   r   r   r   r   r   r<   r<   r=   r     r   z)AsyncVideosWithStreamingResponse.__init__Nr   r   r<   r<   r<   r=   r     r   r   )L
__future__r   typingr   r   r   Ztyping_extensionsr   r   Zhttpx r	   typesr
   r   r   r   r   r   r   r   r   _typesr   r   r   r   r   r   r   r   Z_utilsr   r   r   r   r   Z_compatr    Z	_resourcer!   r"   	_responser#   r$   r%   r&   r'   r(   Z
paginationr)   r*   Ztypes.videor+   Z_base_clientr,   r-   Z_utils._utilsr.   Ztypes.video_sizeZtypes.video_secondsZtypes.video_model_paramr/   Ztypes.video_delete_responser0   Z"types.video_get_character_responser1   Z%types.video_create_character_responser2   __all__r3   r4   r7   r   r@   r   r<   r<   r<   r=   <module>   sH   ,(     !    #$$%