yera.models.interfaces.llms.utils

Utility functions for parsing model reasoning output with delimiters.

Symbols

class ThinkingParser — A parser for model output that separates thinking and response content.

ThinkingParser

A parser for model output that separates thinking and response content.

Attributes

_start

The delimiter marking the start of thinking content.

_end

The delimiter marking the end of thinking content.

_active

Whether the parser is currently in a thinking block.

_starts_thinking

Whether the first block should be considered thinking.

Methods

parse_stream — Convert a stream of raw text chunks into classified tokens.

ThinkingParser.parse_stream

parse_stream(
    stream: Iterator[str],
) → Iterator[LLMToken]

Convert a stream of raw text chunks into classified tokens.

Parameters

stream
type: Iterator[str]

Chunks of model output, of any size.