Module: OllamaChat::TokenEstimator

Included in:
Chat
Defined in:
lib/ollama_chat/token_estimator.rb,
lib/ollama_chat/token_estimator.rb

Overview

A data structure that holds the results of a token estimation, providing convenient formatting methods for both byte size and token count.

Defined Under Namespace

Classes: Crude, Estimate

Class Method Summary collapse

Class Method Details

.estimate(text) ⇒ OllamaChat::TokenEstimator::Estimate

Estimates token count for a given piece of content.

Parameters:

  • text (String, Integer)

    The content to estimate (string or raw byte count).

Returns:



33
34
35
# File 'lib/ollama_chat/token_estimator.rb', line 33

def self.estimate(text)
  OllamaChat::TokenEstimator::Crude.new(text).perform
end