llumpy.retry.AsyncRetryHandler

class AsyncRetryHandler[source]

Bases: _FormatMixIn, ABC

Async retry handler to validate LLM responses

__init__()

Methods

__init__()

try_prompt(async_prompt_fn, extract_fn, retries)

Prompt an LLM to get a valid response

async try_prompt(async_prompt_fn, extract_fn, retries)[source]

Prompt an LLM to get a valid response

Parameters:
  • async_prompt_fn (Callable[[], Awaitable[Any]]) – Async prompt callback function

  • extract_fn (Callable[[Any], str | None]) – Prompt text extraction callback function

  • retries (int) – Number of retries allowed

Raises:

ExceededRetriesError – Exceed the number of permitted retries

Returns:

Validated chat response text

Return type:

Any