pyrit.prompt_target.PromptTarget#
- class PromptTarget(verbose: bool = False, max_requests_per_minute: int | None = None, endpoint: str = '', model_name: str = '', underlying_model: str | None = None)[source]#
Bases:
ABC,IdentifierAbstract base class for prompt targets.
A prompt target is a destination where prompts can be sent to interact with various services, models, or APIs. This class defines the interface that all prompt targets must implement.
- __init__(verbose: bool = False, max_requests_per_minute: int | None = None, endpoint: str = '', model_name: str = '', underlying_model: str | None = None) None[source]#
Initialize the PromptTarget.
- Parameters:
verbose (bool) – Enable verbose logging. Defaults to False.
max_requests_per_minute (int, Optional) – Maximum number of requests per minute.
endpoint (str) – The endpoint URL. Defaults to empty string.
model_name (str) – The model name. Defaults to empty string.
underlying_model (str, Optional) – The underlying model name (e.g., “gpt-4o”) for identification purposes. This is useful when the deployment name in Azure differs from the actual model. If not provided, model_name will be used for the identifier. Defaults to None.
Methods
__init__([verbose, max_requests_per_minute, ...])Initialize the PromptTarget.
Dispose database engine to release database connections and resources.
Get an identifier dictionary for this prompt target.
send_prompt_async(*, message)Send a normalized prompt async to the prompt target.
set_model_name(*, model_name)Set the model name for this target.
Attributes
A list of PromptConverters that are supported by the prompt target.
- dispose_db_engine() None[source]#
Dispose database engine to release database connections and resources.
- get_identifier() Dict[str, Any][source]#
Get an identifier dictionary for this prompt target.
This includes essential attributes needed for scorer evaluation and registry tracking. Subclasses should override this method to include additional relevant attributes (e.g., temperature, top_p) when available.
- Returns:
A dictionary containing identification attributes.
- Return type:
Dict[str, Any]
Note
If the self._underlying_model is specified, either passed in during instantiation or via environment variable, it is used as the “model_name” for the identifier. Otherwise, self._model_name (which is often the deployment name in Azure) is used.
- abstract async send_prompt_async(*, message: Message) list[Message][source]#
Send a normalized prompt async to the prompt target.