Class: LittleGhost::Models::Details

Inherits:
Data
  • Object
show all
Defined in:
lib/little_ghost/models/details.rb

Overview

Immutable normalized facts about one physical model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target:, attributes: {}, provenance: {}, observed_at: nil) ⇒ Details

Returns a new instance of Details.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/little_ghost/models/details.rb', line 7

def initialize(target:, attributes: {}, provenance: {}, observed_at: nil)
  normalized = attributes.to_h.each_with_object({}) do |(key, value), result|
    result[key.to_sym] = freeze_value(value)
  end
  sources = provenance.to_h.each_with_object({}) { |(key, value), result| result[key.to_sym] = value.to_s.freeze }
  super(
    target: Target.parse(target),
    attributes: normalized.freeze,
    provenance: sources.freeze,
    observed_at:
  )
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



6
7
8
# File 'lib/little_ghost/models/details.rb', line 6

def attributes
  @attributes
end

#observed_atObject (readonly)

Returns the value of attribute observed_at

Returns:

  • (Object)

    the current value of observed_at



6
7
8
# File 'lib/little_ghost/models/details.rb', line 6

def observed_at
  @observed_at
end

#provenanceObject (readonly)

Returns the value of attribute provenance

Returns:

  • (Object)

    the current value of provenance



6
7
8
# File 'lib/little_ghost/models/details.rb', line 6

def provenance
  @provenance
end

#targetObject (readonly)

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



6
7
8
# File 'lib/little_ghost/models/details.rb', line 6

def target
  @target
end

Instance Method Details

#[](name) ⇒ Object



20
# File 'lib/little_ghost/models/details.rb', line 20

def [](name) = attributes[name.to_sym]

#context_windowObject



25
# File 'lib/little_ghost/models/details.rb', line 25

def context_window = self[:context_window] || self[:context_window_tokens]

#input_modalitiesObject



23
# File 'lib/little_ghost/models/details.rb', line 23

def input_modalities = self[:input_modalities]

#known?Boolean

Returns:

  • (Boolean)


21
# File 'lib/little_ghost/models/details.rb', line 21

def known? = !attributes.empty?

#max_output_tokensObject



26
# File 'lib/little_ghost/models/details.rb', line 26

def max_output_tokens = self[:max_output_tokens]

#pricingObject



22
# File 'lib/little_ghost/models/details.rb', line 22

def pricing = self[:pricing] || {}.freeze

#supported_parametersObject



24
# File 'lib/little_ghost/models/details.rb', line 24

def supported_parameters = self[:supported_parameters]

#to_hObject



28
29
30
# File 'lib/little_ghost/models/details.rb', line 28

def to_h
  attributes.merge(target: target.to_s, provenance:, observed_at:)
end