
    pi                       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      Z8y)     )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dd       Zedd       Zeeeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	eeeeeeeddded
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	eeeeeeeddded
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	 e
g d	g d
      eeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	y)r$   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/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
        )CompletionsWithRawResponseselfs    a/opt/services/ai/voice_agent/venv/lib/python3.12/site-packages/anthropic/resources/completions.pywith_raw_responsezCompletions.with_raw_response   s     *$//    c                    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
        ) CompletionsWithStreamingResponser*   s    r,   with_streaming_responsez#Completions.with_streaming_response'   s     055r.   Nmetadatastop_sequencesstreamtemperaturetop_ktop_pbetasextra_headersextra_query
extra_bodytimeoutc                    y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+   max_tokens_to_samplemodelpromptr4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   s                  r,   createzCompletions.create0       P 	r.   
r4   r5   r7   r8   r9   r:   r;   r<   r=   r>   c                    y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
        NrA   r+   rC   rD   rE   r6   r4   r5   r7   r8   r9   r:   r;   r<   r=   r>   s                  r,   rF   zCompletions.create   rG   r.   c                    yrJ   rA   rK   s                  r,   rF   zCompletions.create  rG   r.   rC   rD   rE   rC   rD   rE   r6   c                  t        |      s| j                  j                  t        k(  rd}i t	        dt        |
      rdj                  d |
D              nt        i      |xs i }| j                  dt        |||||||||	d	|rt        j                  nt        j                        t        ||||      t        |xs dt        t           	      S )
NX  anthropic-beta,c              3  2   K   | ]  }t        |        y wNstr.0es     r,   	<genexpr>z%Completions.create.<locals>.<genexpr>       9PQ#a&9P   /v1/complete	rC   rD   rE   r4   r5   r6   r7   r8   r9   r;   r<   r=   r>   Fbodyoptionscast_tor6   
stream_cls)r   _clientr>   r   r   joinr   _postr   r	   CompletionCreateParamsStreaming"CompletionCreateParamsNonStreamingr   r    r   rB   s                  r,   rF   zCompletions.createn  s    *  T\\%9%9_%LG
/T\]bTc9P%9P1Pirst
"
 zz ,@"$ (&4$#.""
  )HH-PP  )+Q[el ?Uj)/  
 	
r.   )returnr)   )rj   r1   rC   intrD   r!   rE   rV   r4   MetadataParam | Omitr5   SequenceNotStr[str] | Omitr6   zLiteral[False] | Omitr7   float | Omitr8   
int | Omitr9   ro   r:   List[AnthropicBetaParam] | Omitr;   Headers | Noner<   Query | Noner=   Body | Noner>   'float | httpx.Timeout | None | NotGivenrj   r    )rC   rl   rD   r!   rE   rV   r6   Literal[True]r4   rm   r5   rn   r7   ro   r8   rp   r9   ro   r:   rq   r;   rr   r<   rs   r=   rt   r>   ru   rj   zStream[Completion])rC   rl   rD   r!   rE   rV   r6   boolr4   rm   r5   rn   r7   ro   r8   rp   r9   ro   r:   rq   r;   rr   r<   rs   r=   rt   r>   ru   rj   Completion | Stream[Completion])rC   rl   rD   r!   rE   rV   r4   rm   r5   rn   r6   %Literal[False] | Literal[True] | Omitr7   ro   r8   rp   r9   ro   r:   rq   r;   rr   r<   rs   r=   rt   r>   ru   rj   rx   __name__
__module____qualname__r   r-   r2   r   r   r   rF   r   rA   r.   r,   r$   r$      s   0 0 6 6  *.59(,$( "15 )-$("&;D%g "g 	g
 g 'g 3g &g "g g g /g &g  "!g"  #g$ 9%g& 
'g gR  *.59$( "15 )-$("&;D%g "g 	g
 g g 'g 3g "g g g /g &g  "!g"  #g$ 9%g& 
'g gR  *.59$( "15 )-$("&;D%g "g 	g
 g g 'g 3g "g g g /g &g  "!g"  #g$ 9%g& 
)'g gR >@uv *.598<$( "15 )-$("&;D%2
 "2
 	2

 2
 '2
 32
 62
 "2
 2
 2
 /2
 &2
  "!2
"  #2
$ 9%2
& 
)'2
 w2
r.   c                     e Zd Zedd       Zedd       Zeeeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	eeeeeeeddded
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	eeeeeeeddded
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	 e
g d	g d
      eeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	y)r%   c                    t        |       S r(   )AsyncCompletionsWithRawResponser*   s    r,   r-   z"AsyncCompletions.with_raw_response  s     /t44r.   c                    t        |       S r0   )%AsyncCompletionsWithStreamingResponser*   s    r,   r2   z(AsyncCompletions.with_streaming_response  s     5T::r.   Nr3   c                  K   ywr@   rA   rB   s                  r,   rF   zAsyncCompletions.create       P 	   rH   c                  K   ywrJ   rA   rK   s                  r,   rF   zAsyncCompletions.create"  r   r   c                  K   ywrJ   rA   rK   s                  r,   rF   zAsyncCompletions.create  r   r   rM   rN   c                 K   t        |      s| j                  j                  t        k(  rd}i t	        dt        |
      rdj                  d |
D              nt        i      |xs i }| j                  dt        |||||||||	d	|rt        j                  nt        j                         d {   t        ||||      t        |xs dt        t           	       d {   S 7 57 w)
NrP   rQ   rR   c              3  2   K   | ]  }t        |        y wrT   rU   rW   s     r,   rZ   z*AsyncCompletions.create.<locals>.<genexpr>  r[   r\   r]   r^   r_   Fr`   )r   re   r>   r   r   rf   r   rg   r   r	   rh   ri   r   r    r   rB   s                  r,   rF   zAsyncCompletions.create  s    *  T\\%9%9_%LG
/T\]bTc9P%9P1Pirst
"
 ZZ,,@"$ (&4$#.""
  )HH-PP   )+Q[el ?U":./   
 
 	

s$   B,C(.C$
/0C(C& C(&C()rj   r   )rj   r   rk   )rC   rl   rD   r!   rE   rV   r6   rv   r4   rm   r5   rn   r7   ro   r8   rp   r9   ro   r:   rq   r;   rr   r<   rs   r=   rt   r>   ru   rj   zAsyncStream[Completion])rC   rl   rD   r!   rE   rV   r6   rw   r4   rm   r5   rn   r7   ro   r8   rp   r9   ro   r:   rq   r;   rr   r<   rs   r=   rt   r>   ru   rj   $Completion | AsyncStream[Completion])rC   rl   rD   r!   rE   rV   r4   rm   r5   rn   r6   ry   r7   ro   r8   rp   r9   ro   r:   rq   r;   rr   r<   rs   r=   rt   r>   ru   rj   r   rz   rA   r.   r,   r%   r%     s   5 5 ; ;  *.59(,$( "15 )-$("&;D%g "g 	g
 g 'g 3g &g "g g g /g &g  "!g"  #g$ 9%g& 
'g gR  *.59$( "15 )-$("&;D%g "g 	g
 g g 'g 3g "g g g /g &g  "!g"  #g$ 9%g& 
!'g gR  *.59$( "15 )-$("&;D%g "g 	g
 g g 'g 3g "g g g /g &g  "!g"  #g$ 9%g& 
.'g gR >@uv *.598<$( "15 )-$("&;D%2
 "2
 	2

 2
 '2
 32
 62
 "2
 2
 2
 /2
 &2
  "!2
"  #2
$ 9%2
& 
.'2
 w2
r.   c                      e Zd ZddZy)r)   c                Z    || _         t        j                  |j                        | _        y rT   )_completionsr   to_raw_response_wrapperrF   r+   completionss     r,   __init__z#CompletionsWithRawResponse.__init__-  s%    '&>>
r.   Nr   r$   rj   Noner{   r|   r}   r   rA   r.   r,   r)   r)   ,      
r.   r)   c                      e Zd ZddZy)r   c                Z    || _         t        j                  |j                        | _        y rT   )r   r   async_to_raw_response_wrapperrF   r   s     r,   r   z(AsyncCompletionsWithRawResponse.__init__6  s%    '&DD
r.   Nr   r%   rj   r   r   rA   r.   r,   r   r   5  r   r.   r   c                      e Zd ZddZy)r1   c                F    || _         t        |j                        | _        y rT   )r   r   rF   r   s     r,   r   z)CompletionsWithStreamingResponse.__init__?  s    '2
r.   Nr   r   rA   r.   r,   r1   r1   >  r   r.   r1   c                      e Zd ZddZy)r   c                F    || _         t        |j                        | _        y rT   )r   r   rF   r   s     r,   r   z.AsyncCompletionsWithStreamingResponse.__init__H  s    '8
r.   Nr   r   rA   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   r1   r   rA   r.   r,   <module>r      s    #  /   , Z Z Z e e % 9 X ( , / ) * 0 ;,
-E
/ E
PE
' E
P
 

 

 

 
r.   