pyrit.prompt_target.OpenAICompletionTarget#

class OpenAICompletionTarget(max_tokens: int | None | NotGiven = NOT_GIVEN, temperature: float = 1.0, top_p: float = 1.0, frequency_penalty: float = 0.0, presence_penalty: float = 0.0, *args, **kwargs)[source]#

Bases: OpenAITarget

__init__(max_tokens: int | None | NotGiven = NOT_GIVEN, temperature: float = 1.0, top_p: float = 1.0, frequency_penalty: float = 0.0, presence_penalty: float = 0.0, *args, **kwargs)[source]#
Parameters:

max_tokens (int, Optional) – The maximum number of tokens that can be generated in the completion. The token count of your prompt plus max_tokens cannot exceed the model’s context length.

Methods

__init__([max_tokens, temperature, top_p, ...])

dispose_db_engine()

Dispose DuckDB database engine to release database connections and resources.

get_identifier()

is_json_response_supported()

Indicates that this target supports JSON response format.

is_response_format_json(request_piece)

Checks if the response format is JSON and ensures the target supports it.

send_prompt_async(**kwargs)

Sends a normalized prompt async to the prompt target.

set_system_prompt(*, system_prompt, ...[, ...])

Sets the system prompt for the prompt target.

Attributes

api_key_environment_variable: str#
deployment_environment_variable: str#
endpoint_uri_environment_variable: str#
is_json_response_supported() bool[source]#

Indicates that this target supports JSON response format.

async send_prompt_async(**kwargs)#

Sends a normalized prompt async to the prompt target.