pyrit.models.PromptRequestPiece#

class PromptRequestPiece(*, role: Literal['system', 'user', 'assistant'], original_value: str, converted_value: str | None = None, id: UUID | None = None, conversation_id: str | None = None, sequence: int = -1, labels: Dict[str, str] | None = None, prompt_metadata: str | None = None, converter_identifiers: List[Dict[str, str]] | None = None, prompt_target_identifier: Dict[str, str] | None = None, orchestrator_identifier: Dict[str, str] | None = None, scorer_identifier: Dict[str, str] = None, original_value_data_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text', converted_value_data_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text', response_error: Literal['blocked', 'none', 'processing', 'unknown'] = 'none', originator: Literal['orchestrator', 'converter', 'undefined', 'scorer'] = 'undefined', original_prompt_id: UUID | None = None, timestamp: datetime | None = None)[source]#

Bases: ABC

Represents a prompt request piece.

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

  • 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__(*, role: Literal['system', 'user', 'assistant'], original_value: str, converted_value: str | None = None, id: UUID | None = None, conversation_id: str | None = None, sequence: int = -1, labels: Dict[str, str] | None = None, prompt_metadata: str | None = None, converter_identifiers: List[Dict[str, str]] | None = None, prompt_target_identifier: Dict[str, str] | None = None, orchestrator_identifier: Dict[str, str] | None = None, scorer_identifier: Dict[str, str] = None, original_value_data_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text', converted_value_data_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text', response_error: Literal['blocked', 'none', 'processing', 'unknown'] = 'none', originator: Literal['orchestrator', 'converter', 'undefined', 'scorer'] = 'undefined', original_prompt_id: UUID | None = None, timestamp: datetime | None = None)[source]#

Methods

__init__(*, role, original_value[, ...])

compute_sha256()

This method computes the SHA256 hash values asynchronously.

to_chat_message()

to_prompt_request_response()

Attributes

async compute_sha256()[source]#

This method computes the SHA256 hash values asynchronously. It should be called after object creation if original_value and converted_value are set.

property converted_value: str#
property converted_value_sha256#
property original_value: str#
property original_value_sha256#
to_chat_message() ChatMessage[source]#
to_prompt_request_response() PromptRequestResponse[source]#