Class: SolidLoop::LlmUsageParser::Anthropic

Inherits:
Object
  • Object
show all
Defined in:
app/services/solid_loop/llm_usage_parser/anthropic.rb

Class Method Summary collapse

Class Method Details

.call(usage) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/solid_loop/llm_usage_parser/anthropic.rb', line 6

def self.call(usage)
  input  = usage["input_tokens"].to_i
  output = usage["output_tokens"].to_i
  cached = usage.dig("cache_read_input_tokens").to_i

  {
    tokens_prompt:        input,
    tokens_completion:    output,
    tokens_total:         input + output,
    tokens_prompt_cached: cached,
    cost:                 0.0,
    tps:                  0.0
  }
end