pyrit.prompt_converter.PersuasionConverter#

class PersuasionConverter(*, converter_target: PromptChatTarget, persuasion_technique: str)[source]#

Bases: PromptConverter

Converter to rephrase prompts using a variety of persuasion techniques.

Based on https://arxiv.org/abs/2401.06373 by Zeng et al.

Parameters:
  • converter_target (PromptChatTarget) – Chat target used to perform rewriting on user prompt

  • persuasion_technique

  • {"authority_endorsement" – Persuasion technique to be used by the converter, determines the system prompt to be used to generate new prompts. - authority_endorsement: Citing authoritative sources in support of a claim. - evidence_based: Using empirical data, statistics, and facts to support a claim or decision. - expert_endorsement: Citing domain experts in support of a claim. - logical_appeal: Using logic or reasoning to support a claim. - misrepresentation: Presenting oneself or an issue in a way that’s not genuine or true.

  • "evidence_based" – Persuasion technique to be used by the converter, determines the system prompt to be used to generate new prompts. - authority_endorsement: Citing authoritative sources in support of a claim. - evidence_based: Using empirical data, statistics, and facts to support a claim or decision. - expert_endorsement: Citing domain experts in support of a claim. - logical_appeal: Using logic or reasoning to support a claim. - misrepresentation: Presenting oneself or an issue in a way that’s not genuine or true.

  • "expert_endorsement" – Persuasion technique to be used by the converter, determines the system prompt to be used to generate new prompts. - authority_endorsement: Citing authoritative sources in support of a claim. - evidence_based: Using empirical data, statistics, and facts to support a claim or decision. - expert_endorsement: Citing domain experts in support of a claim. - logical_appeal: Using logic or reasoning to support a claim. - misrepresentation: Presenting oneself or an issue in a way that’s not genuine or true.

  • "logical_appeal" – Persuasion technique to be used by the converter, determines the system prompt to be used to generate new prompts. - authority_endorsement: Citing authoritative sources in support of a claim. - evidence_based: Using empirical data, statistics, and facts to support a claim or decision. - expert_endorsement: Citing domain experts in support of a claim. - logical_appeal: Using logic or reasoning to support a claim. - misrepresentation: Presenting oneself or an issue in a way that’s not genuine or true.

  • "misrepresentation"} – Persuasion technique to be used by the converter, determines the system prompt to be used to generate new prompts. - authority_endorsement: Citing authoritative sources in support of a claim. - evidence_based: Using empirical data, statistics, and facts to support a claim or decision. - expert_endorsement: Citing domain experts in support of a claim. - logical_appeal: Using logic or reasoning to support a claim. - misrepresentation: Presenting oneself or an issue in a way that’s not genuine or true.

__init__(*, converter_target: PromptChatTarget, persuasion_technique: str)[source]#

Methods

__init__(*, converter_target, ...)

convert_async(*, prompt[, input_type])

Converter to generate versions of prompt with new, prepended sentences.

convert_tokens_async(*, prompt[, ...])

Converts substrings within a prompt that are enclosed by specified start and end tokens.

get_identifier()

input_supported(input_type)

Checks if the input type is supported by the converter

send_persuasion_prompt_async(request)

async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text') ConverterResult[source]#

Converter to generate versions of prompt with new, prepended sentences.

input_supported(input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error']) bool[source]#

Checks if the input type is supported by the converter

Parameters:

input_type – The input type to check

Returns:

True if the input type is supported, False otherwise

Return type:

bool

async send_persuasion_prompt_async(request)[source]#