pyrit.memory.PromptMemoryEntry#
- class PromptMemoryEntry(*, entry)[source]#
Bases:
BaseRepresents the prompt data.
Because of the nature of database and sql alchemy, type ignores are abundant :)
- Parameters:
__tablename__ (str) – The name of the database table.
__table_args__ (dict) – Additional arguments for the database table.
id (Uuid) – The unique identifier for the memory entry.
role (PromptType) – system, assistant, user
conversation_id (str) – The identifier for the conversation which is associated with a single target.
sequence (int) – The order of the conversation within a conversation_id. Can be the same number for multi-part requests or multi-part responses.
timestamp (DateTime) – The timestamp of the memory entry.
labels (Dict[str, str]) – The labels associated with the memory entry. Several can be standardized.
targeted_harm_categories (List[str]) – The targeted harm categories for the memory entry.
prompt_metadata (JSON) – The metadata associated with the prompt. This can be specific to any scenarios. Because memory is how components talk with each other, this can be component specific. e.g. the URI from a file uploaded to a blob store, or a document type you want to upload.
converters (list[PromptConverter]) – The converters for the prompt.
prompt_target (PromptTarget) – The target for the prompt.
attack_identifier (Dict[str, str]) – The attack identifier for the prompt.
original_value_data_type (PromptDataType) – The data type of the original prompt (text, image)
original_value (str) – The text of the original prompt. If prompt is an image, it’s a link.
original_value_sha256 (str) – The SHA256 hash of the original prompt data.
converted_value_data_type (PromptDataType) – The data type of the converted prompt (text, image)
converted_value (str) – The text of the converted prompt. If prompt is an image, it’s a link.
converted_value_sha256 (str) – The SHA256 hash of the original prompt data.
idx_conversation_id (Index) – The index for the conversation ID.
original_prompt_id (UUID) – The original prompt id. It is equal to id unless it is a duplicate.
scores (list[ScoreEntry]) – The list of scores associated with the prompt.
- __init__(*, entry)#
Initialize a PromptMemoryEntry from a MessagePiece.
- Parameters:
entry (MessagePiece) – The message piece to convert into a database entry.
Methods
__init__(*, entry)Initialize a PromptMemoryEntry from a MessagePiece.
Convert this database entry back into a MessagePiece object.
Attributes
metadataRefers to the
_schema.MetaDatacollection that will be used for new_schema.Tableobjects.registryRefers to the
_orm.registryin use where new_orm.Mapperobjects will be associated.- conversation_id#
- converted_value#
- converted_value_sha256#
- get_message_piece() MessagePiece[source]#
Convert this database entry back into a MessagePiece object.
- Returns:
The reconstructed message piece with all its data and scores.
- Return type:
- id#
- idx_conversation_id = Index('idx_conversation_id', 'conversation_id')#
- original_prompt_id#
- original_value#
- original_value_sha256#
- sequence#
- timestamp#