Class: Riffer::Providers::FinishReason

Inherits:
Object
  • Object
show all
Defined in:
lib/riffer/providers/finish_reason.rb

Overview

Normalized reason an LLM call finished, paired with the provider’s raw wire value. reason carries the same meaning for every provider.

Constant Summary collapse

VALUES =

The normalized vocabulary every provider maps into.

%i[stop length tool_calls content_filter error other].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason:, raw: nil) ⇒ FinishReason

Raises Riffer::ArgumentError when reason is outside VALUES. – : (reason: Symbol, ?raw: String?) -> void



19
20
21
22
23
24
25
26
# File 'lib/riffer/providers/finish_reason.rb', line 19

def initialize(reason:, raw: nil)
  unless VALUES.include?(reason)
    raise Riffer::ArgumentError, "reason must be one of #{VALUES.inspect}, got #{reason.inspect}"
  end

  @reason = reason
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

The provider’s raw finish-reason value, when one exists on the wire.



14
15
16
# File 'lib/riffer/providers/finish_reason.rb', line 14

def raw
  @raw
end

#reasonObject (readonly)

The normalized reason.



11
12
13
# File 'lib/riffer/providers/finish_reason.rb', line 11

def reason
  @reason
end