continue_text¶
basemode.continue_.continue_text
async def continue_text(
prefix: str,
model: str = "gpt-4o-mini",
*,
max_tokens: int = 200,
temperature: float = 0.9,
context: str = "",
strategy: str | None = None,
rewind: bool = False,
strict_max_tokens: bool = False,
record_health: bool = True,
observation: ObservationContext | None = None,
retry_empty_completion: bool = True,
on_raw_head: RawHeadCallback | None = None,
raw_head_chars: int = 32,
on_usage: UsageCallback | None = None,
**extra,
) -> AsyncGenerator[str, None]
Stream a single continuation token-by-token.
Notes¶
- Model names are normalized before strategy selection.
strategyoverrides auto-detection.rewind=Trueholds the prefix's last short token back fromsystem/few_shotgeneration so a word split across the boundary is rejoined exactly rather than heuristically; the request is reissued in full if the model does not re-emit it.strict_max_tokens=Truestops the visible stream atmax_tokensusing client-side token counting. Some models are sent a wider budget than requested, because their hidden reasoning would otherwise consume it (seebasemode.strategies.compat); pass this flag when the visible length must matchmax_tokensexactly.extrais forwarded to LiteLLM request kwargs.observationattaches allow-listed caller provenance such assource="loom"and a package version. It never carries prompt or response content.record_healthis retained for source compatibility but no longer bypasses the unified observation ledger. Set the documented global recording opt-out to disable local recording.retry_empty_completion=Falsedisables the default retry after an empty first response.on_raw_headreceives up toraw_head_charsunprocessed opening characters;on_usagereceives every provider usage payload after the stream ends. See Python API.- Raises
EmptyCompletionError(withmodel,strategy, andfinish_reason) if both the initial request and enabled retry end without content.