2.0.9

TokenEstimator

Package: flyte.extras

Protocol for records that can estimate their own token count.

Implement this on your record type and the `TokenBatcher` will
call it automatically when no explicit `estimated_tokens` is passed
to `TokenBatcher.submit`.

Example::

    @dataclass
    class Prompt:
        text: str

        def estimate_tokens(self) -> int:
            return len(self.text) // 4 + 1
protocol TokenEstimator()

Methods

Method Description
estimate_tokens()

estimate_tokens()

def estimate_tokens()