pyrit.memory.AttackResultEntry#
- class AttackResultEntry(*, entry)[source]#
Bases:
Base
Represents the attack result data in the database.
- 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 attack result entry.
conversation_id (str) – The unique identifier of the conversation that produced this result.
objective (str) – Natural-language description of the attacker’s objective.
attack_identifier (dict[str, str]) – Identifier of the attack (e.g., name, module).
objective_sha256 (str) – The SHA256 hash of the objective.
last_response_id (Uuid) – Foreign key to the last response PromptRequestPiece.
last_score_id (Uuid) – Foreign key to the last score ScoreEntry.
executed_turns (int) – Total number of turns that were executed.
execution_time_ms (int) – Total execution time of the attack in milliseconds.
outcome (AttackOutcome) – The outcome of the attack, indicating success, failure, or undetermined.
outcome_reason (str) – Optional reason for the outcome, providing additional context.
attack_metadata (dict[str, Any]) – Metadata can be included as key-value pairs to provide extra context.
pruned_conversation_ids (List[str]) – List of conversation IDs that were pruned from the attack.
adversarial_chat_conversation_ids (List[str]) – List of conversation IDs used for adversarial chat.
timestamp (DateTime) – The timestamp of the attack result entry.
last_response (PromptMemoryEntry) – Relationship to the last response prompt memory entry.
last_score (ScoreEntry) – Relationship to the last score entry.
- __str__()#
Returns a string representation of the attack result entry.
- __init__(*, entry)#
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
Methods
__init__
(*, entry)A simple constructor that allows initialization from kwargs.
filter_json_serializable_metadata
(metadata)Filter a dictionary to only include JSON-serializable values.
Attributes
metadata
Refers to the
_schema.MetaData
collection that will be used for new_schema.Table
objects.registry
Refers to the
_orm.registry
in use where new_orm.Mapper
objects will be associated.- conversation_id#
- executed_turns#
- execution_time_ms#
- static filter_json_serializable_metadata(metadata: Dict[str, Any]) Dict[str, Any] [source]#
Filter a dictionary to only include JSON-serializable values.
This function iterates through the metadata dictionary and keeps only values that can be serialized to JSON, discarding any non-serializable objects.
- Parameters:
metadata – Dictionary with potentially non-serializable values
- Returns:
Dictionary with only JSON-serializable values
- id#
- last_response: Mapped[PromptMemoryEntry | None]#
- objective#
- objective_sha256#
- outcome_reason#
- timestamp#