
     `i                       d dl mZ d dlmZ d dlmZ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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" ddl#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l0m1Z1 ddgZ2 G d de          Z3 G d de          Z4 G d d          Z5 G d d          Z6 G d d          Z7 G d d          Z8dS )     )annotations)List)LiteraloverloadN   )_legacy_response)completion_create_params)BodyOmitQueryHeadersNotGivenSequenceNotStromit	not_given)is_givenrequired_argsmaybe_transformstrip_not_givenasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)DEFAULT_TIMEOUT)StreamAsyncStream)make_request_options)
Completion)
ModelParam)MetadataParam)AnthropicBetaParamCompletionsAsyncCompletionsc                     e Zd Zed0d            Zed1d            Zeeeeeeeedddedd2d$            Z	eeeeeeeddded%
d3d(            Z	eeeeeeeddded%
d4d+            Z	 e
g d,g d-          eeeeeeedddedd5d/            Z	dS )6r$   returnCompletionsWithRawResponsec                     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/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
        )r(   selfs    s/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/anthropic/resources/completions.pywith_raw_responsezCompletions.with_raw_response   s     *$///     CompletionsWithStreamingResponsec                     t          |           S z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
        )r0   r+   s    r-   with_streaming_responsez#Completions.with_streaming_response'   s     0555r/   Nmetadatastop_sequencesstreamtemperaturetop_ktop_pbetasextra_headersextra_query
extra_bodytimeoutmax_tokens_to_sampleintmodelr!   promptstrr5   MetadataParam | Omitr6   SequenceNotStr[str] | Omitr7   Literal[False] | Omitr8   float | Omitr9   
int | Omitr:   r;   List[AnthropicBetaParam] | Omitr<   Headers | Noner=   Query | Noner>   Body | Noner?   'float | httpx.Timeout | None | NotGivenr    c                   dS a  [Legacy] Create a Text Completion.

        The Text Completions API is a legacy API.

        We recommend using the
        [Messages API](https://docs.claude.com/en/api/messages) going forward.

        Future models and features will not be compatible with Text Completions. See our
        [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)
        for guidance in migrating from Text Completions to Messages.

        Args:
          max_tokens_to_sample: The maximum number of tokens to generate before stopping.

              Note that our models may stop _before_ reaching this maximum. This parameter
              only specifies the absolute maximum number of tokens to generate.

          model: The model that will complete your prompt.

See
              [models](https://docs.anthropic.com/en/docs/models-overview) for additional
              details and options.

          prompt: The prompt that you want Claude to complete.

              For proper response generation you will need to format your prompt using
              alternating `

Human:` and `

Assistant:` conversational turns. For example:

              ```
              "

Human: {userQuestion}

Assistant:"
              ```

              See [prompt validation](https://docs.claude.com/en/api/prompt-validation) and
              our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting)
              for more details.

          metadata: An object describing metadata about the request.

          stop_sequences: Sequences that will cause the model to stop generating.

              Our models stop on `"

Human:"`, and may include additional built-in stop
              sequences in the future. By providing the stop_sequences parameter, you may
              include additional strings that will cause the model to stop generating.

          stream: Whether to incrementally stream the response using server-sent events.

              See [streaming](https://docs.claude.com/en/api/streaming) for details.

          temperature: Amount of randomness injected into the response.

              Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
              for analytical / multiple choice, and closer to `1.0` for creative and
              generative tasks.

              Note that even with `temperature` of `0.0`, the results will not be fully
              deterministic.

          top_k: Only sample from the top K options for each subsequent token.

              Used to remove "long tail" low probability responses.
              [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).

              Recommended for advanced use cases only. You usually only need to use
              `temperature`.

          top_p: Use nucleus sampling.

              In nucleus sampling, we compute the cumulative distribution over all the options
              for each subsequent token in decreasing probability order and cut it off once it
              reaches a particular probability specified by `top_p`. You should either alter
              `temperature` or `top_p`, but not both.

              Recommended for advanced use cases only. You usually only need to use
              `temperature`.

          betas: Optional header to specify the beta version(s) you want to use.

          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
        N r,   r@   rB   rC   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   s                  r-   createzCompletions.create0   
    P 	r/   
r5   r6   r8   r9   r:   r;   r<   r=   r>   r?   Literal[True]Stream[Completion]c                   dS a  [Legacy] Create a Text Completion.

        The Text Completions API is a legacy API.

        We recommend using the
        [Messages API](https://docs.claude.com/en/api/messages) going forward.

        Future models and features will not be compatible with Text Completions. See our
        [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)
        for guidance in migrating from Text Completions to Messages.

        Args:
          max_tokens_to_sample: The maximum number of tokens to generate before stopping.

              Note that our models may stop _before_ reaching this maximum. This parameter
              only specifies the absolute maximum number of tokens to generate.

          model: The model that will complete your prompt.

See
              [models](https://docs.anthropic.com/en/docs/models-overview) for additional
              details and options.

          prompt: The prompt that you want Claude to complete.

              For proper response generation you will need to format your prompt using
              alternating `

Human:` and `

Assistant:` conversational turns. For example:

              ```
              "

Human: {userQuestion}

Assistant:"
              ```

              See [prompt validation](https://docs.claude.com/en/api/prompt-validation) and
              our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting)
              for more details.

          stream: Whether to incrementally stream the response using server-sent events.

              See [streaming](https://docs.claude.com/en/api/streaming) for details.

          metadata: An object describing metadata about the request.

          stop_sequences: Sequences that will cause the model to stop generating.

              Our models stop on `"

Human:"`, and may include additional built-in stop
              sequences in the future. By providing the stop_sequences parameter, you may
              include additional strings that will cause the model to stop generating.

          temperature: Amount of randomness injected into the response.

              Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
              for analytical / multiple choice, and closer to `1.0` for creative and
              generative tasks.

              Note that even with `temperature` of `0.0`, the results will not be fully
              deterministic.

          top_k: Only sample from the top K options for each subsequent token.

              Used to remove "long tail" low probability responses.
              [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).

              Recommended for advanced use cases only. You usually only need to use
              `temperature`.

          top_p: Use nucleus sampling.

              In nucleus sampling, we compute the cumulative distribution over all the options
              for each subsequent token in decreasing probability order and cut it off once it
              reaches a particular probability specified by `top_p`. You should either alter
              `temperature` or `top_p`, but not both.

              Recommended for advanced use cases only. You usually only need to use
              `temperature`.

          betas: Optional header to specify the beta version(s) you want to use.

          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
        NrQ   r,   r@   rB   rC   r7   r5   r6   r8   r9   r:   r;   r<   r=   r>   r?   s                  r-   rS   zCompletions.create   rT   r/   boolCompletion | Stream[Completion]c                   dS rY   rQ   rZ   s                  r-   rS   zCompletions.create  rT   r/   r@   rB   rC   r@   rB   rC   r7   %Literal[False] | Literal[True] | Omitc                  t          |          s| j        j        t          k    rd}i t	          dt          |
          rd                    d |
D                       nt          i          |pi }|                     dt          |||||||||	d	|rt          j
        nt          j                  t          ||||          t          |pdt          t                   	          S )
NX  anthropic-beta,c              3  4   K   | ]}t          |          V  d S NrD   .0es     r-   	<genexpr>z%Completions.create.<locals>.<genexpr>  (      9P9PQ#a&&9P9P9P9P9P9Pr/   /v1/complete	r@   rB   rC   r5   r6   r7   r8   r9   r:   r<   r=   r>   r?   Fbodyoptionscast_tor7   
stream_cls)r   _clientr?   r   r   joinr   _postr   r	   CompletionCreateParamsStreaming"CompletionCreateParamsNonStreamingr   r    r   rR   s                  r-   rS   zCompletions.createn  s!   *    	T\%9_%L%LG
/T\]bTcTc1r9P9P%9P9P9P1P1P1Pirstt
"
 zz ,@"$ (&4$#.""
 
 Q(HH-P   )+Q[el   ?Uj)/  
 
 	
r/   )r'   r(   )r'   r0   r@   rA   rB   r!   rC   rD   r5   rE   r6   rF   r7   rG   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   r    )r@   rA   rB   r!   rC   rD   r7   rV   r5   rE   r6   rF   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   rW   )r@   rA   rB   r!   rC   rD   r7   r[   r5   rE   r6   rF   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   r\   )r@   rA   rB   r!   rC   rD   r5   rE   r6   rF   r7   r`   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   r\   __name__
__module____qualname__r   r.   r3   r   r   r   rS   r   rQ   r/   r-   r$   r$      s       0 0 0 _0 6 6 6 _6  *.59(,$( "15 )-$("&;D%g g g g g XgR  *.59$( "15 )-$("&;D%g g g g g XgR  *.59$( "15 )-$("&;D%g g g g g XgR ]>>>@u@u@uvv *.598<$( "15 )-$("&;D%2
 2
 2
 2
 2
 wv2
 2
 2
r/   c                     e Zd Zed0d            Zed1d            Zeeeeeeeedddedd2d$            Z	eeeeeeeddded%
d3d(            Z	eeeeeeeddded%
d4d+            Z	 e
g d,g d-          eeeeeeedddedd5d/            Z	dS )6r%   r'   AsyncCompletionsWithRawResponsec                     t          |           S r*   )r   r+   s    r-   r.   z"AsyncCompletions.with_raw_response  s     /t444r/   %AsyncCompletionsWithStreamingResponsec                     t          |           S r2   )r   r+   s    r-   r3   z(AsyncCompletions.with_streaming_response  s     5T:::r/   Nr4   r@   rA   rB   r!   rC   rD   r5   rE   r6   rF   r7   rG   r8   rH   r9   rI   r:   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r    c               
   K   dS rP   rQ   rR   s                  r-   rS   zAsyncCompletions.create        P 	r/   rU   rV   AsyncStream[Completion]c               
   K   dS rY   rQ   rZ   s                  r-   rS   zAsyncCompletions.create"  r   r/   r[   $Completion | AsyncStream[Completion]c               
   K   dS rY   rQ   rZ   s                  r-   rS   zAsyncCompletions.create  r   r/   r^   r_   r`   c                 K   t          |          s| j        j        t          k    rd}i t	          dt          |
          rd                    d |
D                       nt          i          |pi }|                     dt          |||||||||	d	|rt          j
        nt          j                   d {V t          ||||          t          |pdt          t                   	           d {V S )
Nrb   rc   rd   c              3  4   K   | ]}t          |          V  d S rf   rg   rh   s     r-   rk   z*AsyncCompletions.create.<locals>.<genexpr>  rl   r/   rm   rn   ro   Frp   )r   ru   r?   r   r   rv   r   rw   r   r	   rx   ry   r   r    r   rR   s                  r-   rS   zAsyncCompletions.create  sa     *    	T\%9_%L%LG
/T\]bTcTc1r9P9P%9P9P9P1P1P1Pirstt
"
 ZZ,,@"$ (&4$#.""
 
 Q(HH-P         )+Q[el   ?U":./   
 
 
 
 
 
 
 
 	
r/   )r'   r   )r'   r   rz   )r@   rA   rB   r!   rC   rD   r7   rV   r5   rE   r6   rF   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   r   )r@   rA   rB   r!   rC   rD   r7   r[   r5   rE   r6   rF   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   r   )r@   rA   rB   r!   rC   rD   r5   rE   r6   rF   r7   r`   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r'   r   r{   rQ   r/   r-   r%   r%     s       5 5 5 _5 ; ; ; _;  *.59(,$( "15 )-$("&;D%g g g g g XgR  *.59$( "15 )-$("&;D%g g g g g XgR  *.59$( "15 )-$("&;D%g g g g g XgR ]>>>@u@u@uvv *.598<$( "15 )-$("&;D%2
 2
 2
 2
 2
 wv2
 2
 2
r/   c                      e Zd ZddZdS )r(   completionsr$   r'   Nonec                P    || _         t          j        |j                  | _        d S rf   )_completionsr   to_raw_response_wrapperrS   r,   r   s     r-   __init__z#CompletionsWithRawResponse.__init__-  s(    '&>
 
r/   Nr   r$   r'   r   r|   r}   r~   r   rQ   r/   r-   r(   r(   ,  (        
 
 
 
 
 
r/   r(   c                      e Zd ZddZdS )r   r   r%   r'   r   c                P    || _         t          j        |j                  | _        d S rf   )r   r   async_to_raw_response_wrapperrS   r   s     r-   r   z(AsyncCompletionsWithRawResponse.__init__6  s(    '&D
 
r/   Nr   r%   r'   r   r   rQ   r/   r-   r   r   5  r   r/   r   c                      e Zd ZddZdS )r0   r   r$   r'   r   c                F    || _         t          |j                  | _        d S rf   )r   r   rS   r   s     r-   r   z)CompletionsWithStreamingResponse.__init__?  s%    '2
 
r/   Nr   r   rQ   r/   r-   r0   r0   >  r   r/   r0   c                      e Zd ZddZdS )r   r   r%   r'   r   c                F    || _         t          |j                  | _        d S rf   )r   r   rS   r   s     r-   r   z.AsyncCompletionsWithStreamingResponse.__init__H  s%    '8
 
r/   Nr   r   rQ   r/   r-   r   r   G  r   r/   r   )9
__future__r   typingr   typing_extensionsr   r   httpx r   typesr	   _typesr
   r   r   r   r   r   r   r   _utilsr   r   r   r   r   _compatr   	_resourcer   r   	_responser   r   
_constantsr   
_streamingr   r   _base_clientr   types.completionr    types.model_paramr!   types.metadata_paramr"   types.anthropic_beta_paramr#   __all__r$   r%   r(   r   r0   r   rQ   r/   r-   <module>r      s   # " " " " "       / / / / / / / /        , , , , , , Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z e e e e e e e e e e e e e e % % % % % % 9 9 9 9 9 9 9 9 X X X X X X X X ( ( ( ( ( ( , , , , , , , , / / / / / / ) ) ) ) ) ) * * * * * * 0 0 0 0 0 0 ; ; ; ; ; ;,
-E
 E
 E
 E
 E
/ E
 E
 E
PE
 E
 E
 E
 E
' E
 E
 E
P
 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
r/   