o
    î6Wj|�  ã                   @  st  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Z2G dd„ deƒZ3G dd„ deƒZ4G dd„ dƒZ5G dd„ dƒZ6G dd„ dƒZ7G d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d3dd„ƒZed4dd„ƒZeeeeeeeeddded	œd5d&d'„ƒZ	eeeeeeeddded(œ
d6d+d'„ƒZ	eeeeeeeddded(œ
d7d.d'„ƒZ	e
g d/¢g d0¢ƒeeeeeeeddded	œd8d2d'„ƒZ	dS )9r#   ÚreturnÚCompletionsWithRawResponsec                 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
        )r'   ©Úself© r,   ún/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/anthropic/resources/completions.pyÚwith_raw_response   ó   zCompletions.with_raw_responseÚ CompletionsWithStreamingResponsec                 C  r(   ©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*   r,   r,   r-   Úwith_streaming_response'   ó   z#Completions.with_streaming_responseN©Ú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                C  ó   dS ©aS  [Legacy] Create a Text Completion.

        The Text Completions API is a legacy API.

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

        Future models and features will not be compatible with Text Completions. See our
        [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-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://platform.claude.com/docs/en/build-with-claude/working-with-messages)
              and our guide to
              [prompt design](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
              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://platform.claude.com/docs/en/build-with-claude/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.

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

              Recommended for advanced use cases only.

          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
        Nr,   ©r+   r@   rB   rC   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r,   r,   r-   Úcreate0   ó   izCompletions.create©
r5   r6   r8   r9   r:   r;   r<   r=   r>   r?   úLiteral[True]úStream[Completion]c                C  rO   ©aS  [Legacy] Create a Text Completion.

        The Text Completions API is a legacy API.

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

        Future models and features will not be compatible with Text Completions. See our
        [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-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://platform.claude.com/docs/en/build-with-claude/working-with-messages)
              and our guide to
              [prompt design](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
              for more details.

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

              See [streaming](https://platform.claude.com/docs/en/build-with-claude/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.

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

              Recommended for advanced use cases only.

          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
        Nr,   ©r+   r@   rB   rC   r7   r5   r6   r8   r9   r:   r;   r<   r=   r>   r?   r,   r,   r-   rR   ›   rS   ÚboolúCompletion | Stream[Completion]c                C  rO   rW   r,   rX   r,   r,   r-   rR     rS   ©r@   rB   rC   ©r@   rB   rC   r7   ú%Literal[False] | Literal[True] | Omitc                C  sœ   t |ƒs| jjtkrd}i tdt |
ƒrd dd„ |
D ƒ¡ntiƒ¥|p$i ¥}| jdt|||||||||	dœ	|r:t	j
nt	jƒt||||d�t|pHd	tt d
�S )NéX  úanthropic-betaú,c                 s  ó   � | ]}t |ƒV  qd S ©N©rD   ©Ú.0Úer,   r,   r-   Ú	<genexpr>‰  ó   € z%Completions.create.<locals>.<genexpr>ú/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   rQ   r,   r,   r-   rR   q  s>   &ÿþ÷ÿòÿé)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   rU   r5   rE   r6   rF   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r&   rV   )r@   rA   rB   r    rC   rD   r7   rY   r5   rE   r6   rF   r8   rH   r9   rI   r:   rH   r;   rJ   r<   rK   r=   rL   r>   rM   r?   rN   r&   rZ   )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&   rZ   ©Ú__name__Ú
__module__Ú__qualname__r   r.   r2   r   r   r   rR   r   r,   r,   r,   r-   r#      ón    	îjîjîjîc                   @  r%   )9r$   r&   ÚAsyncCompletionsWithRawResponsec                 C  r(   r)   )r|   r*   r,   r,   r-   r.   ¨  r/   z"AsyncCompletions.with_raw_responseÚ%AsyncCompletionsWithStreamingResponsec                 C  r(   r1   )r}   r*   r,   r,   r-   r2   ²  r3   z(AsyncCompletions.with_streaming_responseNr4   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                Ã  ó   �dS rP   r,   rQ   r,   r,   r-   rR   »  ó   €izAsyncCompletions.createrT   rU   úAsyncStream[Completion]c                Ã  r~   rW   r,   rX   r,   r,   r-   rR   &  r   rY   ú$Completion | AsyncStream[Completion]c                Ã  r~   rW   r,   rX   r,   r,   r-   rR   ‘  r   r[   r\   r]   c                Ã  sª   �t |ƒs| jjtkrd}i tdt |
ƒrd dd„ |
D ƒ¡ntiƒ¥|p%i ¥}| jdt|||||||||	dœ	|r;t	j
nt	jƒI d H t||||d�t|pLd	tt d
�I d H S )Nr^   r_   r`   c                 s  ra   rb   rc   rd   r,   r,   r-   rg     rh   z*AsyncCompletions.create.<locals>.<genexpr>ri   rj   rk   Frl   )r   rq   r?   r   r   rr   r   rs   r   r   rt   ru   r   r   r   rQ   r,   r,   r-   rR   ü  s@   €&ÿþ÷ÿòÿé)r&   r|   )r&   r}   rv   )r@   rA   rB   r    rC   rD   r7   rU   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   rY   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�   rw   r,   r,   r,   r-   r$   §  r{   c                   @  ó   e Zd Zddd„ZdS )	r'   Úcompletionsr#   r&   ÚNonec                 C  ó   || _ t |j¡| _d S rb   )Ú_completionsr   Úto_raw_response_wrapperrR   ©r+   rƒ   r,   r,   r-   Ú__init__3  ó   
ÿz#CompletionsWithRawResponse.__init__N©rƒ   r#   r&   r„   ©rx   ry   rz   r‰   r,   r,   r,   r-   r'   2  ó    r'   c                   @  r‚   )	r|   rƒ   r$   r&   r„   c                 C  r…   rb   )r†   r   Úasync_to_raw_response_wrapperrR   rˆ   r,   r,   r-   r‰   <  rŠ   z(AsyncCompletionsWithRawResponse.__init__N©rƒ   r$   r&   r„   rŒ   r,   r,   r,   r-   r|   ;  r�   r|   c                   @  r‚   )	r0   rƒ   r#   r&   r„   c                 C  ó   || _ t|jƒ| _d S rb   )r†   r   rR   rˆ   r,   r,   r-   r‰   E  ó   
ÿz)CompletionsWithStreamingResponse.__init__Nr‹   rŒ   r,   r,   r,   r-   r0   D  r�   r0   c                   @  r‚   )	r}   rƒ   r$   r&   r„   c                 C  r�   rb   )r†   r   rR   rˆ   r,   r,   r-   r‰   N  r‘   z.AsyncCompletionsWithStreamingResponse.__init__Nr�   rŒ   r,   r,   r,   r-   r}   M  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}   r,   r,   r,   r-   Ú<module>   s>   (      			