1. SQLite Memory

1. SQLite Memory#

The memory SQLite database can be thought of as a normalized source of truth. The memory module is the primary way PyRIT keeps track of requests and responses to targets and scores. Most of this is done automatically. All Prompt Targets write to memory for later retrieval. All scorers also write to memory when scoring.

The schema is found in memory_models.py and can be programmatically viewed as follows

from pyrit.memory import SQLiteMemory

# Use in-memory database to avoid file corruption issues
memory = SQLiteMemory(db_path=":memory:")
memory.print_schema()

memory.dispose_engine()
Database Schema:
================

Table: PromptMemoryEntries
--------------------------
  id: CHAR(32) NOT NULL
  role: VARCHAR NOT NULL
  conversation_id: VARCHAR NOT NULL
  sequence: INTEGER NOT NULL
  timestamp: DATETIME NOT NULL
  labels: JSON NOT NULL
  prompt_metadata: JSON NOT NULL
  targeted_harm_categories: JSON NULL
  converter_identifiers: JSON NULL
  prompt_target_identifier: JSON NOT NULL
  attack_identifier: JSON NOT NULL
  response_error: VARCHAR NULL
  original_value_data_type: VARCHAR NOT NULL
  original_value: VARCHAR NOT NULL
  original_value_sha256: VARCHAR NULL
  converted_value_data_type: VARCHAR NOT NULL
  converted_value: VARCHAR NULL
  converted_value_sha256: VARCHAR NULL
  original_prompt_id: CHAR(32) NOT NULL

Table: EmbeddingData
--------------------
  id: CHAR(32) NOT NULL
  embedding: ARRAY NULL
  embedding_type_name: VARCHAR NULL

Table: ScoreEntries
-------------------
  id: CHAR(32) NOT NULL
  score_value: VARCHAR NOT NULL
  score_value_description: VARCHAR NULL
  score_type: VARCHAR NOT NULL
  score_category: JSON NULL
  score_rationale: VARCHAR NULL
  score_metadata: JSON NOT NULL
  scorer_class_identifier: JSON NOT NULL
  prompt_request_response_id: CHAR(32) NULL
  timestamp: DATETIME NOT NULL
  task: VARCHAR NULL
  objective: VARCHAR NULL

Table: SeedPromptEntries
------------------------
  id: CHAR(32) NOT NULL
  value: VARCHAR NOT NULL
  value_sha256: VARCHAR NULL
  data_type: VARCHAR NOT NULL
  name: VARCHAR NULL
  dataset_name: VARCHAR NULL
  harm_categories: JSON NULL
  description: VARCHAR NULL
  authors: JSON NULL
  groups: JSON NULL
  source: VARCHAR NULL
  date_added: DATETIME NOT NULL
  added_by: VARCHAR NOT NULL
  prompt_metadata: JSON NULL
  parameters: JSON NULL
  prompt_group_id: CHAR(32) NULL
  sequence: INTEGER NULL
  role: VARCHAR NULL
  is_objective: BOOLEAN NULL

Table: AttackResultEntries
--------------------------
  id: CHAR(32) NOT NULL
  conversation_id: VARCHAR NOT NULL
  objective: VARCHAR NOT NULL
  attack_identifier: JSON NOT NULL
  objective_sha256: VARCHAR NULL
  last_response_id: CHAR(32) NULL
  last_score_id: CHAR(32) NULL
  executed_turns: INTEGER NOT NULL DEFAULT ScalarElementColumnDefault(0)
  execution_time_ms: INTEGER NOT NULL DEFAULT ScalarElementColumnDefault(0)
  outcome: VARCHAR NOT NULL DEFAULT ScalarElementColumnDefault('undetermined')
  outcome_reason: VARCHAR NULL
  attack_metadata: JSON NULL
  pruned_conversation_ids: JSON NULL
  adversarial_chat_conversation_ids: JSON NULL
  timestamp: DATETIME NOT NULL

Table: ScenarioResultEntries
----------------------------
  id: CHAR(32) NOT NULL
  scenario_name: VARCHAR NOT NULL
  scenario_description: VARCHAR NULL
  scenario_version: INTEGER NOT NULL DEFAULT ScalarElementColumnDefault(1)
  pyrit_version: VARCHAR NOT NULL
  scenario_init_data: JSON NULL
  objective_target_identifier: JSON NOT NULL
  objective_scorer_identifier: JSON NULL
  scenario_run_state: VARCHAR NOT NULL DEFAULT ScalarElementColumnDefault('CREATED')
  attack_results_json: VARCHAR NOT NULL
  labels: JSON NULL
  number_tries: INTEGER NOT NULL DEFAULT ScalarElementColumnDefault(0)
  completion_time: DATETIME NOT NULL
  timestamp: DATETIME NOT NULL