pyrit.prompt_converter.IndexSelectionStrategy#

class IndexSelectionStrategy(*, start: int = 0, end: int | None = None)[source]#

Bases: TextSelectionStrategy

Selects text based on absolute character indices.

__init__(*, start: int = 0, end: int | None = None) None[source]#

Initializes the index selection strategy.

Parameters:
  • start (int) – The starting character index (inclusive). Defaults to 0.

  • end (Optional[int]) – The ending character index (exclusive). If None, selects to end of text.

Methods

__init__(*[, start, end])

Initializes the index selection strategy.

select_range(*, text)

Selects a range based on absolute character indices.

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

Selects a range based on absolute character indices.

Parameters:

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

Returns:

A tuple of (start_index, end_index).

Return type:

tuple[int, int]