Class: Cline::Usage

Inherits:
Struct
  • Object
show all
Defined in:
lib/cline/usage.rb

Overview

Track usage statistics associated to a message

Instance Attribute Summary collapse

Public API collapse

Instance Attribute Details

#cache_read_tokensObject

Returns the value of attribute cache_read_tokens

Returns:

  • (Object)

    the current value of cache_read_tokens



3
4
5
# File 'lib/cline/usage.rb', line 3

def cache_read_tokens
  @cache_read_tokens
end

#cache_write_tokensObject

Returns the value of attribute cache_write_tokens

Returns:

  • (Object)

    the current value of cache_write_tokens



3
4
5
# File 'lib/cline/usage.rb', line 3

def cache_write_tokens
  @cache_write_tokens
end

#cline_modelObject

Returns the value of attribute cline_model

Returns:

  • (Object)

    the current value of cline_model



3
4
5
# File 'lib/cline/usage.rb', line 3

def cline_model
  @cline_model
end

#costObject

Returns the value of attribute cost

Returns:

  • (Object)

    the current value of cost



3
4
5
# File 'lib/cline/usage.rb', line 3

def cost
  @cost
end

#input_tokensObject

Returns the value of attribute input_tokens

Returns:

  • (Object)

    the current value of input_tokens



3
4
5
# File 'lib/cline/usage.rb', line 3

def input_tokens
  @input_tokens
end

#output_tokensObject

Returns the value of attribute output_tokens

Returns:

  • (Object)

    the current value of output_tokens



3
4
5
# File 'lib/cline/usage.rb', line 3

def output_tokens
  @output_tokens
end

Instance Method Details

#context_tokensInteger

Returns Total context tokens consumed.

Returns:

  • (Integer)

    Total context tokens consumed



28
29
30
# File 'lib/cline/usage.rb', line 28

def context_tokens
  input_tokens + output_tokens + cache_read_tokens + cache_write_tokens
end

#context_tokens_limitInteger?

Returns Maximum context window limit for the used model.

Returns:

  • (Integer, nil)

    Maximum context window limit for the used model



33
34
35
# File 'lib/cline/usage.rb', line 33

def context_tokens_limit
  cline_model&.context_window
end