sizeInTokens method

int sizeInTokens(
  1. String text
)

Runs an invocation of only the tokenization for the LLM, and returns the size (in tokens) of the result.

Implementation

int sizeInTokens(String text) {
  final textPtr = text.copyToNative();
  final errorMessageMemory = calloc<Pointer<Char>>();
  final size = bindings.LlmInferenceEngine_Session_SizeInTokens(
    worker,
    textPtr,
    errorMessageMemory,
  );
  handleErrorMessage(errorMessageMemory);
  return size;
}