pyrit.prompt_target.PromptChatTarget#
- class PromptChatTarget(*, max_requests_per_minute: int | None = None)[source]#
Bases:
PromptTarget
A prompt chat target is a target where you can explicitly set the conversation history using memory.
Some algorithms require conversation to be modified (e.g. deleting the last message) or set explicitly. These algorithms will require PromptChatTargets be used.
As a concrete example, OpenAI chat targets are PromptChatTargets. You can set made-up conversation history. Realtime chat targets or OpenAI completions are NOT PromptChatTargets. You don’t send the conversation history.
Methods
__init__
(*[, max_requests_per_minute])dispose_db_engine
()Dispose DuckDB database engine to release database connections and resources.
get_identifier
()Abstract method to determine if JSON response format is supported by the target.
is_response_format_json
(request_piece)Checks if the response format is JSON and ensures the target supports it.
send_prompt_async
(*, prompt_request)Sends a normalized prompt async to the prompt target.
set_system_prompt
(*, system_prompt, ...[, ...])Sets the system prompt for the prompt target.
Attributes
- abstract is_json_response_supported() bool [source]#
Abstract method to determine if JSON response format is supported by the target.
- Returns:
True if JSON response is supported, False otherwise.
- Return type:
- is_response_format_json(request_piece: PromptRequestPiece) bool [source]#
Checks if the response format is JSON and ensures the target supports it.
- Parameters:
request_piece – A PromptRequestPiece object with a prompt_metadata dictionary that may include a “response_format” key.
- Returns:
True if the response format is JSON and supported, False otherwise.
- Return type:
- Raises:
ValueError – If “json” response format is requested but unsupported.