pyrit.prompt_target.GandalfTarget#

class GandalfTarget(*, level: GandalfLevel, max_requests_per_minute: int | None = None)[source]#

Bases: PromptTarget

A prompt target for the Gandalf security challenge.

__init__(*, level: GandalfLevel, max_requests_per_minute: int | None = None) None[source]#

Initialize the Gandalf target.

Parameters:
  • level (GandalfLevel) – The Gandalf level to target.

  • max_requests_per_minute (int, Optional) – Number of requests the target can handle per minute before hitting a rate limit. The number of requests sent to the target will be capped at the value provided.

Methods

__init__(*, level[, max_requests_per_minute])

Initialize the Gandalf target.

check_password(password)

Check if the password is correct.

dispose_db_engine()

Dispose database engine to release database connections and resources.

get_identifier()

Get an identifier dictionary for this prompt target.

send_prompt_async(**kwargs)

Send a normalized prompt async to the prompt target.

set_model_name(*, model_name)

Set the model name for this target.

Attributes

supported_converters

A list of PromptConverters that are supported by the prompt target.

async check_password(password: str) bool[source]#

Check if the password is correct.

Returns:

True if the password is correct, False otherwise.

Return type:

bool

Raises:

ValueError – If the chat returned an empty response.

async send_prompt_async(**kwargs: Any) Any#

Send a normalized prompt async to the prompt target.

Returns:

A list of message responses. Most targets return a single message,

but some (like response target with tool calls) may return multiple messages.

Return type:

list[Message]

supported_converters: List[Any]#

A list of PromptConverters that are supported by the prompt target. An empty list implies that the prompt target supports all converters.