Module: OllamaChat::Utils::ValueFormatter

Included in:
Chat, FollowChat, MessageList, Tools::Concern
Defined in:
lib/ollama_chat/utils/value_formatter.rb

Overview

Module to format values for user consumption.

Instance Method Summary collapse

Instance Method Details

#format_bytes(bytes) ⇒ String

Formats a byte value into a human‑readable string with units

Parameters:

  • bytes (Integer)

    the number of bytes to format

Returns:

  • (String)

    the formatted byte string



7
8
9
# File 'lib/ollama_chat/utils/value_formatter.rb', line 7

def format_bytes(bytes)
  Tins::Unit.format(bytes, unit: ?B, prefix: :iec_uc, format: '%.1f %U')
end

#format_tokens(tokens) ⇒ String

Formats a token count into a human‑readable string with units

Parameters:

  • tokens (Integer)

    the number of tokens to format

Returns:

  • (String)

    the formatted token string



15
16
17
# File 'lib/ollama_chat/utils/value_formatter.rb', line 15

def format_tokens(tokens)
  Tins::Unit.format(tokens, unit: ?T, prefix: :si_uc, format: '%.1f %U')
end