
    b6i                         d dl 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 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ  e j.                  e j0                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)UnprocessableEntityError)HttpValidationError)MusicPrompt.c                       e Zd ZdefdZeeedddedej                  e	   dej                  e
   dej                  ej                  d	      d
ej                  e   dee
   fdZy)RawCompositionPlanClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     w/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/music/composition_plan/raw_client.py__init__z!RawCompositionPlanClient.__init__   
    -    Nmusic_length_mssource_composition_planmodel_idrequest_optionspromptr   r   r    music_v1r!   returnc                
   | j                   j                  j                  dd||t        |t        d      |dddi|t
              }	 d	|j                  cxk  rd
k  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rUt        t        |j                        t        j                  t        t        t        |j                                           |j                         }t#        |j                  t        |j                        |      # t         $ r6 t#        |j                  t        |j                        |j$                        w xY w)a  
        Create a composition plan for music generation. Usage of this endpoint does not cost any credits but is subject to rate limiting depending on your tier.

        Parameters
        ----------
        prompt : str
            A simple text prompt to compose a plan from.

        music_length_ms : typing.Optional[int]
            The length of the composition plan to generate in milliseconds. Must be between 3000ms and 600000ms. Optional - if not provided, the model will choose a length based on the prompt.

        source_composition_plan : typing.Optional[MusicPrompt]
            An optional composition plan to use as a source for the new composition plan.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[MusicPrompt]
            Successful Response
        v1/music/planPOSTwriteobject_
annotation	directionr"   r   r   r    content-typeapplication/jsonmethodjsonheadersr!   omit   ,  type_r*   responsedata  r3   bodystatus_coder3   r>   )r   httpx_clientrequestr   r   OMITr@   typingcastr   r2   r	   r   dictr3   r   r   r   text	r   r"   r   r   r    r!   	_response_data_response_jsons	            r   createzRawCompositionPlanClient.create   sg   D ((55== #2+R3W^, %  2 , > 
	"	ti++1c1") ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AE $A4E ?F)__name__
__module____qualname__r   r   rC   strrD   Optionalintr   Literalr
   r	   rL    r   r   r   r      s    .*; . 15@D@D;?Kp Kp  -	Kp
 "(!=Kp //&.."<=Kp  8Kp 
k	"Kpr   r   c                       e Zd ZdefdZeeedddedej                  e	   dej                  e
   dej                  ej                  d	      d
ej                  e   dee
   fdZy)AsyncRawCompositionPlanClientr   c                    || _         y r   r   r   s     r   r   z&AsyncRawCompositionPlanClient.__init__g   r   r   Nr   r"   r   r   r    r#   r!   r$   c                (  K   | j                   j                  j                  dd||t        |t        d      |dddi|t
               d	{   }	 d
|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rUt        t        |j                        t        j                  t        t        t        |j                                           |j                         }t#        |j                  t        |j                        |      7 # t         $ r6 t#        |j                  t        |j                        |j$                        w xY ww)a  
        Create a composition plan for music generation. Usage of this endpoint does not cost any credits but is subject to rate limiting depending on your tier.

        Parameters
        ----------
        prompt : str
            A simple text prompt to compose a plan from.

        music_length_ms : typing.Optional[int]
            The length of the composition plan to generate in milliseconds. Must be between 3000ms and 600000ms. Optional - if not provided, the model will choose a length based on the prompt.

        source_composition_plan : typing.Optional[MusicPrompt]
            An optional composition plan to use as a source for the new composition plan.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[MusicPrompt]
            Successful Response
        r&   r'   r(   r)   r-   r.   r/   r0   Nr5   r6   r7   r9   r<   r=   r?   )r   rA   rB   r   r   rC   r@   rD   rE   r   r2   r   r   rF   r3   r   r   r   rG   rH   s	            r   rL   z$AsyncRawCompositionPlanClient.createj   sw    D ..;;CC #2+R3W^, %  2 , D 
 
	"	ti++1c1") ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooS
N  	ty'<'<d9K\K\F]dmdrdrss	ts8   A
FEFAE -F.A4E ",F?FF)rM   rN   rO   r   r   rC   rP   rD   rQ   rR   r   rS   r
   r   rL   rT   r   r   rV   rV   f   s    .*< . 15@D@D;?Kp Kp  -	Kp
 "(!=Kp //&.."<=Kp  8Kp 
;	'Kpr   rV   )rD   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.request_optionsr
   core.serializationr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   types.http_validation_errorr   types.music_promptr   rE   AnyrC   r   rV   rT   r   r   <module>rd      s]     ( & H A 2 I 7 I > - v{{6::s#Op OpdOp Opr   