pyrit.prompt_target.TextTarget#
- class TextTarget(*, text_stream: ~typing.IO[str] = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]#
Bases:
PromptTargetThe TextTarget takes prompts, adds them to memory and writes them to io which is sys.stdout by default.
This can be useful in various situations, for example, if operators want to generate prompts but enter them manually.
- __init__(*, text_stream: ~typing.IO[str] = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) None[source]#
Initialize the TextTarget.
- Parameters:
text_stream (IO[str]) – The text stream to write prompts to. Defaults to sys.stdout.
Methods
__init__(*[, text_stream])Initialize the TextTarget.
Target does not require cleanup.
dispose_db_engine()Dispose database engine to release database connections and resources.
get_identifier()Get an identifier dictionary for this prompt target.
import_scores_from_csv(csv_file_path)Import message pieces and their scores from a CSV file.
send_prompt_async(*, message)Asynchronously write a message to the text stream.
set_model_name(*, model_name)Set the model name for this target.
Attributes
A list of PromptConverters that are supported by the prompt target.
- import_scores_from_csv(csv_file_path: Path) list[MessagePiece][source]#
Import message pieces and their scores from a CSV file.
- Parameters:
csv_file_path (Path) – The path to the CSV file containing scores.
- Returns:
A list of message pieces imported from the CSV.
- Return type: