
    -:jy                    $   d dl m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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mZ dd
lmZmZ ddlmZmZ ddlm Z  erddl!m"Z"m#Z# ddgZ$ G d de      Z% G d de      Z& G d d      Z' G d d      Z(y)    )annotations)TYPE_CHECKINGListUnionoverload)LiteralN   )
Completioncompletion_create_params)	NOT_GIVENBodyQueryHeadersNotGiven)required_argsmaybe_transform)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperasync_to_raw_response_wrapper)StreamAsyncStream)make_request_options)	AnthropicAsyncAnthropicCompletionsAsyncCompletionsc                      e Zd ZU ded<   d fdZeeeeeeeddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zeeeeeeddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Zeeeeeeddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
       Z eg dg d      eeeeeeddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z xZ	S )r   CompletionsWithRawResponsewith_raw_responsec                D    t         |   |       t        |       | _        y N)super__init__r   r    selfclient	__class__s     a/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/anthropic/resources/completions.pyr$   zCompletions.__init__   s     !;D!A    NX  
metadatastop_sequencesstreamtemperaturetop_ktop_pextra_headersextra_query
extra_bodytimeoutc                    ya  
        Create a completion

        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.

              As we improve Claude, we develop new versions of it that you can query. This
              parameter controls which version of Claude answers your request. Right now we
              are offering two model families: Claude, and Claude Instant. You can use them by
              setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
              [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
              additional details.

          prompt: The prompt that you want Claude to complete.

              For proper response generation you will need to format your prompt as follows:

              ```javascript
              const userQuestion = r"Why is the sky blue?";
              const prompt = `

Human: ${userQuestion}

Assistant:`;
              ```

              See our
              [comments on prompts](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
              for more context.

          metadata: An object describing metadata about the request.

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

              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
              [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
              for details.

          temperature: Amount of randomness injected into the response.

              Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
              multiple choice, and closer to 1 for creative and generative tasks.

          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).

          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.

          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promptr-   r.   r/   r0   r1   r2   r3   r4   r5   r6   s                 r)   createzCompletions.create       t 	r*   	r-   r.   r0   r1   r2   r3   r4   r5   r6   c                    ya  
        Create a completion

        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.

              As we improve Claude, we develop new versions of it that you can query. This
              parameter controls which version of Claude answers your request. Right now we
              are offering two model families: Claude, and Claude Instant. You can use them by
              setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
              [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
              additional details.

          prompt: The prompt that you want Claude to complete.

              For proper response generation you will need to format your prompt as follows:

              ```javascript
              const userQuestion = r"Why is the sky blue?";
              const prompt = `

Human: ${userQuestion}

Assistant:`;
              ```

              See our
              [comments on prompts](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
              for more context.

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

              See
              [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
              for details.

          metadata: An object describing metadata about the request.

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

              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. Ranges from 0 to 1. Use temp closer to 0 for analytical /
              multiple choice, and closer to 1 for creative and generative tasks.

          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).

          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.

          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
        Nr9   r&   r;   r<   r=   r/   r-   r.   r0   r1   r2   r3   r4   r5   r6   s                 r)   r>   zCompletions.create{   r?   r*   c                    yrB   r9   rC   s                 r)   r>   zCompletions.create   r?   r*   r;   r<   r=   r;   r<   r=   r/   c                   | j                  dt        |||||||||	d	t        j                        t	        |
|||      t
        |xs dt        t
                 S Nz/v1/complete)	r;   r<   r=   r-   r.   r/   r0   r1   r2   )r3   r4   r5   r6   F)bodyoptionscast_tor/   
stream_cls)_postr   r   CompletionCreateParamsr   r
   r   r:   s                 r)   r>   zCompletions.create3  sy    ( zz ,@"$ (&4$#.""
 )?? )+Q[el ?Uj)+  
 	
r*   )r'   r   returnNoner;   intr<   3Union[str, Literal['claude-2', 'claude-instant-1']]r=   strr-   ,completion_create_params.Metadata | NotGivenr.   List[str] | NotGivenr/   zLiteral[False] | NotGivenr0   float | NotGivenr1   int | NotGivenr2   rW   r3   Headers | Noner4   Query | Noner5   Body | Noner6   'float | httpx.Timeout | None | NotGivenrO   r
   )r;   rR   r<   rS   r=   rT   r/   Literal[True]r-   rU   r.   rV   r0   rW   r1   rX   r2   rW   r3   rY   r4   rZ   r5   r[   r6   r\   rO   zStream[Completion])r;   rR   r<   rS   r=   rT   r/   boolr-   rU   r.   rV   r0   rW   r1   rX   r2   rW   r3   rY   r4   rZ   r5   r[   r6   r\   rO   Completion | Stream[Completion])r;   rR   r<   rS   r=   rT   r-   rU   r.   rV   r/   )Literal[False] | Literal[True] | NotGivenr0   rW   r1   rX   r2   rW   r3   rY   r4   rZ   r5   r[   r6   r\   rO   r_   
__name__
__module____qualname____annotations__r$   r   r   r>   r   __classcell__r(   s   @r)   r   r      sZ   11B  BK/8,5(1 )"+ )-$("&;>#Y "Y C	Y
 Y ?Y -Y *Y &Y Y  Y &Y "Y   !Y" 9#Y$ 
%Y Yv  BK/8(1 )"+ )-$("&;>#Y "Y C	Y
 Y Y ?Y -Y &Y Y  Y &Y "Y   !Y" 9#Y$ 
%Y Yv  BK/8(1 )"+ )-$("&;>#Y "Y C	Y
 Y Y ?Y -Y &Y Y  Y &Y "Y   !Y" 9#Y$ 
)%Y Yv >@uv BK/8<E(1 )"+ )-$("&;>#)
 ")
 C	)

 )
 ?)
 -)
 :)
 &)
 )
  )
 &)
 ")
   !)
" 9#)
$ 
)%)
 w)
r*   c                      e Zd ZU ded<   d fdZeeeeeeeddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zeeeeeeddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Zeeeeeeddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
       Z eg dg d      eeeeeeddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z xZ	S )r   AsyncCompletionsWithRawResponser    c                D    t         |   |       t        |       | _        y r"   )r#   r$   ri   r    r%   s     r)   r$   zAsyncCompletions.__init__c  s     !@!Fr*   Nr+   r,   c                  K   ywr8   r9   r:   s                 r)   r>   zAsyncCompletions.createg       t 	   r@   c                  K   ywrB   r9   rC   s                 r)   r>   zAsyncCompletions.create  rl   rm   c                  K   ywrB   r9   rC   s                 r)   r>   zAsyncCompletions.create  rl   rm   rE   rF   c                  K   | j                  dt        |||||||||	d	t        j                        t	        |
|||      t
        |xs dt        t
                  d {   S 7 wrH   )rM   r   r   rN   r   r
   r   r:   s                 r)   r>   zAsyncCompletions.create{  s     ( ZZ ,@"$ (&4$#.""
 )?? )+Q[el ?U":.+   
 
 	
 
s   AA&A$ A&)r'   r   rO   rP   rQ   )r;   rR   r<   rS   r=   rT   r/   r]   r-   rU   r.   rV   r0   rW   r1   rX   r2   rW   r3   rY   r4   rZ   r5   r[   r6   r\   rO   zAsyncStream[Completion])r;   rR   r<   rS   r=   rT   r/   r^   r-   rU   r.   rV   r0   rW   r1   rX   r2   rW   r3   rY   r4   rZ   r5   r[   r6   r\   rO   $Completion | AsyncStream[Completion])r;   rR   r<   rS   r=   rT   r-   rU   r.   rV   r/   r`   r0   rW   r1   rX   r2   rW   r3   rY   r4   rZ   r5   r[   r6   r\   rO   rq   ra   rg   s   @r)   r   r   `  sZ   66G  BK/8,5(1 )"+ )-$("&;>#Y "Y C	Y
 Y ?Y -Y *Y &Y Y  Y &Y "Y   !Y" 9#Y$ 
%Y Yv  BK/8(1 )"+ )-$("&;>#Y "Y C	Y
 Y Y ?Y -Y &Y Y  Y &Y "Y   !Y" 9#Y$ 
!%Y Yv  BK/8(1 )"+ )-$("&;>#Y "Y C	Y
 Y Y ?Y -Y &Y Y  Y &Y "Y   !Y" 9#Y$ 
.%Y Yv >@uv BK/8<E(1 )"+ )-$("&;>#)
 ")
 C	)

 )
 ?)
 -)
 :)
 &)
 )
  )
 &)
 ")
   !)
" 9#)
$ 
.%)
 w)
r*   c                      e Zd ZddZy)r   c                8    t        |j                        | _        y r"   )r   r>   r&   completionss     r)   r$   z#CompletionsWithRawResponse.__init__  s    -
r*   N)ru   r   rO   rP   rb   rc   rd   r$   r9   r*   r)   r   r         
r*   r   c                      e Zd ZddZy)ri   c                8    t        |j                        | _        y r"   )r   r>   rt   s     r)   r$   z(AsyncCompletionsWithRawResponse.__init__  s    3
r*   N)ru   r   rO   rP   rv   r9   r*   r)   ri   ri     rw   r*   ri   ))
__future__r   typingr   r   r   r   typing_extensionsr   httpxtypesr
   r   _typesr   r   r   r   r   _utilsr   r   	_resourcer   r   	_responser   r   
_streamingr   r   _base_clientr   _clientr   r   __all__r   r   r   ri   r9   r*   r)   <module>r      sr    # 7 7 %  8 > > 3 9 N , /3,
-E
/ E
P
E
' E
P

 

 
r*   