Class: LittleGhost::Models::Details
- Inherits:
-
Data
- Object
- Data
- LittleGhost::Models::Details
- Defined in:
- lib/little_ghost/models/details.rb
Overview
Immutable normalized facts about one physical model.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#observed_at ⇒ Object
readonly
Returns the value of attribute observed_at.
-
#provenance ⇒ Object
readonly
Returns the value of attribute provenance.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #context_window ⇒ Object
-
#initialize(target:, attributes: {}, provenance: {}, observed_at: nil) ⇒ Details
constructor
A new instance of Details.
- #input_modalities ⇒ Object
- #known? ⇒ Boolean
- #max_output_tokens ⇒ Object
- #pricing ⇒ Object
- #supported_parameters ⇒ Object
- #to_h ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes
6 7 8 |
# File 'lib/little_ghost/models/details.rb', line 6 def attributes @attributes end |
#observed_at ⇒ Object (readonly)
Returns the value of attribute observed_at
6 7 8 |
# File 'lib/little_ghost/models/details.rb', line 6 def observed_at @observed_at end |
#provenance ⇒ Object (readonly)
Returns the value of attribute provenance
6 7 8 |
# File 'lib/little_ghost/models/details.rb', line 6 def provenance @provenance end |
#target ⇒ Object (readonly)
Returns the value of attribute 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_window ⇒ Object
25 |
# File 'lib/little_ghost/models/details.rb', line 25 def context_window = self[:context_window] || self[:context_window_tokens] |
#input_modalities ⇒ Object
23 |
# File 'lib/little_ghost/models/details.rb', line 23 def input_modalities = self[:input_modalities] |
#known? ⇒ Boolean
21 |
# File 'lib/little_ghost/models/details.rb', line 21 def known? = !attributes.empty? |
#max_output_tokens ⇒ Object
26 |
# File 'lib/little_ghost/models/details.rb', line 26 def max_output_tokens = self[:max_output_tokens] |
#pricing ⇒ Object
22 |
# File 'lib/little_ghost/models/details.rb', line 22 def pricing = self[:pricing] || {}.freeze |
#supported_parameters ⇒ Object
24 |
# File 'lib/little_ghost/models/details.rb', line 24 def supported_parameters = self[:supported_parameters] |
#to_h ⇒ Object
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 |