pyrit.prompt_converter.RangeSelectionStrategy#

class RangeSelectionStrategy(*, start_proportion: float = 0.0, end_proportion: float = 1.0)[source]#

Bases: TextSelectionStrategy

Selects text based on proportional start and end positions.

__init__(*, start_proportion: float = 0.0, end_proportion: float = 1.0) None[source]#

Initializes the range selection strategy.

Parameters:
  • start_proportion (float) – The starting position as a proportion (0.0 to 1.0). Defaults to 0.0.

  • end_proportion (float) – The ending position as a proportion (0.0 to 1.0). Defaults to 1.0.

Raises:

ValueError – If proportions are not between 0.0 and 1.0, or start >= end.

Methods

__init__(*[, start_proportion, end_proportion])

Initializes the range selection strategy.

select_range(*, text)

Selects a range based on proportional positions.

select_range(*, text: str) tuple[int, int][source]#

Selects a range based on proportional positions.

Parameters:

text (str) – The input text to select from.

Returns:

A tuple of (start_index, end_index).

Return type:

tuple[int, int]