Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pyrit/memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
This package defines the core `MemoryInterface` and concrete implementations for different storage backends.
"""

from typing import Any

from pyrit.memory.azure_sql_memory import AzureSQLMemory
from pyrit.memory.central_memory import CentralMemory
from pyrit.memory.memory_embedding import MemoryEmbedding
from pyrit.memory.memory_exporter import MemoryExporter
from pyrit.memory.memory_interface import MemoryInterface
from pyrit.memory.memory_models import AttackResultEntry, EmbeddingDataEntry, PromptMemoryEntry, SeedEntry
from pyrit.memory.sqlite_memory import SQLiteMemory
Expand All @@ -27,3 +28,17 @@
"PromptMemoryEntry",
"SeedEntry",
]


def __getattr__(name: str) -> Any: # noqa: N807 - module __getattr__ hook must use this name
if name == "MemoryExporter":
from pyrit.common.deprecation import print_deprecation_message
from pyrit.memory.memory_exporter import MemoryExporter

print_deprecation_message(
old_item="pyrit.memory.MemoryExporter",
new_item="the pyrit.output module or direct serialization",
removed_in="0.15.0",
)
return MemoryExporter
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
5 changes: 5 additions & 0 deletions pyrit/memory/memory_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,11 @@ def export_conversations(
Returns:
Path: The path to the exported file.
"""
print_deprecation_message(
old_item="MemoryInterface.export_conversations",
new_item="the pyrit.output module or direct serialization of get_message_pieces results",
removed_in="0.15.0",
)
data = self.get_message_pieces(
attack_id=attack_id,
conversation_id=conversation_id,
Expand Down
11 changes: 11 additions & 0 deletions pyrit/memory/sqlite_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from sqlalchemy.pool import StaticPool
from sqlalchemy.sql.expression import TextClause

from pyrit.common.deprecation import print_deprecation_message
from pyrit.common.path import DB_DATA_PATH
from pyrit.common.singleton import Singleton
from pyrit.memory.memory_interface import MemoryInterface
Expand Down Expand Up @@ -499,6 +500,11 @@ def export_conversations(
Raises:
ValueError: If the specified export format is not supported.
"""
print_deprecation_message(
old_item="SQLiteMemory.export_conversations",
Comment thread
rlundeen2 marked this conversation as resolved.
new_item="the pyrit.output module or direct serialization of get_message_pieces results",
removed_in="0.15.0",
)
# Import here to avoid circular import issues
from pyrit.memory.memory_exporter import MemoryExporter

Expand Down Expand Up @@ -585,6 +591,11 @@ def export_all_tables(self, *, export_type: str = "json") -> None:
Args:
export_type (str): The format to export the data in (defaults to "json").
"""
print_deprecation_message(
old_item="SQLiteMemory.export_all_tables",
new_item="the pyrit.output module or direct serialization of table query results",
removed_in="0.15.0",
)
table_models = self.get_all_table_models()

for model in table_models:
Expand Down
Loading