pyrit.memory.PromptMemoryEntry#

class PromptMemoryEntry(*, entry)[source]#

Bases: Base

Represents 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.

  • 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.

  • orchestrator_identifier (Dict[str, str]) – The orchestrator 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.

__str__()[source]#

Returns a string representation of the memory 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.

get_prompt_request_piece()

Attributes

conversation_id

converted_value

converted_value_data_type

converted_value_sha256

converter_identifiers

id

idx_conversation_id

labels

metadata

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

orchestrator_identifier

original_prompt_id

original_value

original_value_data_type

original_value_sha256

prompt_metadata

prompt_target_identifier

registry

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

response_error

role

sequence

timestamp

conversation_id#
converted_value#
converted_value_data_type: Mapped[Literal['text', 'image_path', 'audio_path', 'url', 'error']]#
converted_value_sha256#
converter_identifiers: Mapped[dict[str, str]]#
get_prompt_request_piece() PromptRequestPiece[source]#
id#
idx_conversation_id = Index('idx_conversation_id', 'conversation_id')#
labels: Mapped[dict[str, str]]#
orchestrator_identifier: Mapped[dict[str, str]]#
original_prompt_id#
original_value#
original_value_data_type: Mapped[Literal['text', 'image_path', 'audio_path', 'url', 'error']]#
original_value_sha256#
prompt_metadata#
prompt_target_identifier: Mapped[dict[str, str]]#
response_error: Mapped[Literal['blocked', 'none', 'processing', 'unknown']]#
role: Mapped[Literal['system', 'user', 'assistant']]#
sequence#
timestamp#