33
44import abc
55import logging
6- import warnings
76from typing import Any , Union , final
87
98from pyrit .common .deprecation import print_deprecation_message
1211from pyrit .models import Message , MessagePiece
1312from pyrit .models .json_response_config import _JsonResponseConfig
1413from pyrit .prompt_target .common .target_capabilities import CapabilityName , TargetCapabilities
15- from pyrit .prompt_target .common .target_configuration import TargetConfiguration , resolve_configuration_compat
14+ from pyrit .prompt_target .common .target_configuration import TargetConfiguration
1615
1716logger = logging .getLogger (__name__ )
1817
@@ -44,24 +43,6 @@ class PromptTarget(Identifiable):
4443 # constructor parameter, which takes precedence over the class-level value.
4544 _DEFAULT_CONFIGURATION : TargetConfiguration = TargetConfiguration (capabilities = TargetCapabilities ())
4645
47- def __init_subclass__ (cls , ** kwargs : Any ) -> None :
48- """
49- Auto-promote the deprecated ``_DEFAULT_CAPABILITIES`` class attribute.
50-
51- If a subclass defines ``_DEFAULT_CAPABILITIES`` directly, this hook wraps it
52- in a ``TargetConfiguration`` and assigns it to ``_DEFAULT_CONFIGURATION``,
53- emitting a ``DeprecationWarning`` to guide migration.
54- """
55- super ().__init_subclass__ (** kwargs )
56- if "_DEFAULT_CAPABILITIES" in cls .__dict__ :
57- warnings .warn (
58- f"{ cls .__name__ } ._DEFAULT_CAPABILITIES is deprecated and will be removed in v0.14.0. "
59- "Use _DEFAULT_CONFIGURATION = TargetConfiguration(capabilities=...) instead." ,
60- DeprecationWarning ,
61- stacklevel = 2 ,
62- )
63- cls ._DEFAULT_CONFIGURATION = TargetConfiguration (capabilities = cls .__dict__ ["_DEFAULT_CAPABILITIES" ])
64-
6546 def __init__ (
6647 self ,
6748 verbose : bool = False ,
@@ -70,7 +51,6 @@ def __init__(
7051 model_name : str = "" ,
7152 underlying_model : str | None = None ,
7253 custom_configuration : TargetConfiguration | None = None ,
73- custom_capabilities : TargetCapabilities | None = None ,
7454 ) -> None :
7555 """
7656 Initialize the PromptTarget.
@@ -88,13 +68,7 @@ def __init__(
8868 for this target instance. Useful for targets whose capabilities depend on deployment
8969 configuration (e.g., Playwright, HTTP). If None, uses the class-level
9070 ``_DEFAULT_CONFIGURATION``. Defaults to None.
91- custom_capabilities (TargetCapabilities | None): **Deprecated.** Use
92- ``custom_configuration`` instead. Will be removed in v0.14.0.
9371 """
94- custom_configuration = resolve_configuration_compat (
95- custom_configuration = custom_configuration ,
96- custom_capabilities = custom_capabilities ,
97- )
9872 self ._memory = CentralMemory .get_memory_instance ()
9973 self ._verbose = verbose
10074 self ._max_requests_per_minute = max_requests_per_minute
@@ -454,25 +428,6 @@ def get_default_configuration(cls, underlying_model: str | None = None) -> Targe
454428 )
455429 return cls ._DEFAULT_CONFIGURATION
456430
457- @classmethod
458- def get_default_capabilities (cls , underlying_model : str | None = None ) -> TargetCapabilities :
459- """
460- Return the default capabilities for the given model.
461-
462- **Deprecated.** Use :meth:`get_default_configuration` instead.
463- Will be removed in v0.14.0.
464-
465- Returns:
466- TargetCapabilities: The capabilities for the given model or class default.
467- """
468- warnings .warn (
469- "get_default_capabilities() is deprecated and will be removed in v0.14.0. "
470- "Use get_default_configuration() instead." ,
471- DeprecationWarning ,
472- stacklevel = 2 ,
473- )
474- return cls .get_default_configuration (underlying_model ).capabilities
475-
476431 def _build_identifier (self ) -> ComponentIdentifier :
477432 """
478433 Build the identifier for this target.
0 commit comments