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 programatically viewed as follows:

from pyrit.memory import SQLiteMemory

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
  converter_identifiers: JSON NULL
  prompt_target_identifier: JSON NOT NULL
  orchestrator_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: VARCHAR NULL
  score_rationale: VARCHAR NULL
  score_metadata: VARCHAR NULL
  scorer_class_identifier: JSON NOT NULL
  prompt_request_response_id: CHAR(32) NULL
  timestamp: DATETIME NOT NULL
  task: 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

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