66
77This module exposes two complementary probes:
88
9- * :func:` _discover_capability_flags_async` discovers the boolean capability flags
10- defined on :class:` TargetCapabilities` (e.g. ``supports_system_prompt``,
9+ * `` _discover_capability_flags_async` ` discovers the boolean capability flags
10+ defined on `` TargetCapabilities` ` (e.g. ``supports_system_prompt``,
1111 ``supports_multi_message_pieces``). For each capability that has a probe
1212 defined, a minimal request is sent to the target. If the request succeeds,
1313 the capability is included in the returned set. Capabilities without a
1414 registered probe fall back to the target's declared native support from
1515 ``target.capabilities``.
16- * :func:` _discover_input_modalities_async` discovers which input modality
16+ * `` _discover_input_modalities_async` ` discovers which input modality
1717 combinations a target actually supports by sending a minimal test request
1818 for each combination declared in ``TargetCapabilities.input_modalities``.
1919
@@ -120,7 +120,7 @@ def _permissive_configuration(
120120 Temporarily replace ``target``'s configuration with one that declares every
121121 boolean capability as natively supported.
122122
123- This bypasses :meth:` PromptTarget._validate_request`, which would otherwise
123+ This bypasses `` PromptTarget._validate_request` `, which would otherwise
124124 short-circuit probes for capabilities the target declares as unsupported
125125 before any API call is made. The original configuration is restored on exit.
126126
@@ -182,9 +182,9 @@ def _probe_metadata(extra: dict[str, str | int] | None = None) -> dict[str, str
182182
183183def _user_text_piece (* , value : str , conversation_id : str ) -> MessagePiece :
184184 """
185- Build a single user-role text :class:` MessagePiece` for use in a probe.
185+ Build a single user-role text `` MessagePiece` ` for use in a probe.
186186
187- The piece's ``prompt_metadata`` is tagged with :data:` PROBE_METADATA_KEY`
187+ The piece's ``prompt_metadata`` is tagged with `` PROBE_METADATA_KEY` `
188188 so that consumers aggregating memory can filter out probe-written rows.
189189
190190 Args:
@@ -229,7 +229,7 @@ async def _send_and_check_async(
229229 retries (int): Number of additional attempts after the first failure.
230230 Only transient errors are retried; non-retryable errors and
231231 non-error responses are final. Retry attempts use exponential
232- backoff starting at :data:` DEFAULT_PROBE_RETRY_BACKOFF_SECONDS`.
232+ backoff starting at `` DEFAULT_PROBE_RETRY_BACKOFF_SECONDS` `.
233233 Defaults to 1.
234234 label (str): Short label used in log messages. Defaults to
235235 ``"Capability probe"``.
@@ -291,8 +291,8 @@ async def _probe_system_prompt_async(target: PromptTarget, timeout_s: float, ret
291291 """
292292 Probe whether ``target`` accepts a system prompt followed by a user message.
293293
294- Writes a system-role :class:` MessagePiece` directly to ``target._memory``
295- rather than calling :meth:` pyrit.prompt_target.PromptChatTarget.set_system_prompt`
294+ Writes a system-role `` MessagePiece` ` directly to ``target._memory``
295+ rather than calling `` pyrit.prompt_target.PromptChatTarget.set_system_prompt` `
296296 (which is only defined on ``PromptChatTarget`` subclasses anyway).
297297 ``set_system_prompt`` can be overridden by subclasses (e.g. mocks) to do
298298 nothing or to perform extra work, which would mask whether the underlying
@@ -526,10 +526,10 @@ async def _discover_capability_flags_async(
526526 Args:
527527 target (PromptTarget): The target to probe.
528528 capabilities (Iterable[CapabilityName] | None): Capabilities to check.
529- Defaults to every member of :class:` CapabilityName`.
529+ Defaults to every member of `` CapabilityName` `.
530530 per_probe_timeout_s (float): Per-attempt timeout (seconds) applied to
531531 each probe request. Defaults to
532- :data:` DEFAULT_PROBE_TIMEOUT_SECONDS`.
532+ `` DEFAULT_PROBE_TIMEOUT_SECONDS` `.
533533 retries (int): Number of additional attempts after the first failure
534534 for each probe. Only exceptions/timeouts are retried; an explicit
535535 error response is final. Set to ``0`` to disable retries.
@@ -593,7 +593,7 @@ async def _discover_capability_flags_async(
593593
594594# Default mapping of non-text modalities to packaged probe assets. Callers can
595595# override via the ``test_assets`` parameter of
596- # :func:` _discover_input_modalities_async`. Modalities whose assets do not exist
596+ # `` _discover_input_modalities_async` `. Modalities whose assets do not exist
597597# on disk are skipped (logged and excluded from the result).
598598DEFAULT_TEST_ASSETS : dict [PromptDataType , str ] = {
599599 "audio_path" : str (_TARGET_CAPABILITIES_DATASET_PATH / "probe_audio.wav" ),
@@ -622,11 +622,11 @@ async def _discover_input_modalities_async(
622622 declared in ``target.capabilities.input_modalities``.
623623 test_assets (dict[PromptDataType, str] | None): Mapping from
624624 non-text modality to a file path used as the probe payload.
625- Defaults to :data:` DEFAULT_TEST_ASSETS`. Combinations whose
625+ Defaults to `` DEFAULT_TEST_ASSETS` `. Combinations whose
626626 non-text assets are missing on disk are skipped.
627627 per_probe_timeout_s (float): Per-attempt timeout (seconds) applied to
628628 each probe request. Defaults to
629- :data:` DEFAULT_PROBE_TIMEOUT_SECONDS`.
629+ `` DEFAULT_PROBE_TIMEOUT_SECONDS` `.
630630 retries (int): Number of additional attempts after the first failure
631631 for each probe. Only exceptions/timeouts are retried; an explicit
632632 error response is final. Set to ``0`` to disable retries.
@@ -685,7 +685,7 @@ async def discover_target_capabilities_async(
685685 """
686686 Probe both the boolean capability flags and the input modality combinations
687687 that ``target`` accepts, and return a merged best-effort
688- :class:` TargetCapabilities`.
688+ `` TargetCapabilities` `.
689689
690690 Boolean capabilities with a registered probe are checked with live
691691 requests; capabilities without a probe fall back to the target's
@@ -704,17 +704,17 @@ async def discover_target_capabilities_async(
704704 the target's declared support.
705705 test_assets (dict[PromptDataType, str] | None): Mapping from non-text
706706 modality to a file path used as the probe payload. Defaults to
707- :data:` DEFAULT_TEST_ASSETS`. Combinations whose non-text assets
707+ `` DEFAULT_TEST_ASSETS` `. Combinations whose non-text assets
708708 are missing on disk are skipped.
709709 capabilities (Iterable[CapabilityName] | None): Capabilities to probe.
710- Defaults to every member of :class:` CapabilityName`. Capabilities
710+ Defaults to every member of `` CapabilityName` `. Capabilities
711711 not listed here fall back to the target's declared support.
712712 retries (int): Number of additional attempts after the first failure
713713 for each probe. Only exceptions/timeouts are retried; an explicit
714714 error response is final. Set to ``0`` to disable retries.
715715 Defaults to 1.
716716 apply (bool): If True, install the discovered capabilities on ``target``
717- via :meth:` PromptTarget.apply_capabilities` before returning.
717+ via `` PromptTarget.apply_capabilities` ` before returning.
718718 Probe results are an upper bound (the request was accepted, not
719719 necessarily honored), so leave this False when you want to inspect
720720 or diff the result before committing to it. Defaults to False.
@@ -790,7 +790,7 @@ def _create_test_message(
790790 test_assets : dict [PromptDataType , str ],
791791) -> Message :
792792 """
793- Build a minimal :class:` Message` that exercises ``modalities``.
793+ Build a minimal `` Message` ` that exercises ``modalities``.
794794
795795 Args:
796796 modalities (frozenset[PromptDataType]): The modalities to include.
0 commit comments