Class: Axn::RubyLLM::Ask

Inherits:
Object
  • Object
show all
Includes:
Axn
Defined in:
lib/axn/ruby_llm/ask.rb

Defined Under Namespace

Classes: StubMessage

Instance Method Summary collapse

Instance Method Details

#callObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/axn/ruby_llm/ask.rb', line 42

def call
  expose(
    response: parsed_response,
    raw_message: llm_response,
    input_tokens: llm_response.input_tokens,
    output_tokens: llm_response.output_tokens,
    cost_breakdown:,
    cost: cost_breakdown&.total,
    stubbed: false,
  )
  record_otel_attributes!(
    input_tokens: llm_response.input_tokens,
    output_tokens: llm_response.output_tokens,
    cost: cost_breakdown&.total,
    response_model: llm_response.model_id,
    stubbed: false,
  )
rescue ::RubyLLM::RateLimitError => e
  fail! "Rate limit reached: #{e.message}"
end