Class: Riffer::Providers::FinishReason

Inherits:
Object
  • Object
show all
Defined in:
lib/riffer/providers/finish_reason.rb,
sig/generated/riffer/providers/finish_reason.rbs

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.

Returns:

  • (Array[Symbol])
%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

Parameters:

  • reason: (Symbol)
  • raw: (String, nil) (defaults to: nil)


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

#rawString? (readonly)

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

Returns:

  • (String, nil)


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

def raw
  @raw
end

#reasonSymbol (readonly)

The normalized reason.

Returns:

  • (Symbol)


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

def reason
  @reason
end