Class: Legion::Extensions::Agentic::Language::InnerSpeech::Helpers::Utterance
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Language::InnerSpeech::Helpers::Utterance
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb
Constant Summary
Constants included from Constants
Constants::AUTOMATIC_SPEED, Constants::CONDENSATION_RATIO, Constants::CONTROLLED_SPEED, Constants::EGOCENTRIC_SPEED, Constants::MAX_HISTORY, Constants::MAX_STREAM_LENGTH, Constants::MAX_UTTERANCES, Constants::RUMINATION_THRESHOLD, Constants::SALIENCE_DECAY, Constants::SALIENCE_FLOOR, Constants::SPEECH_MODES, Constants::URGENCY_LABELS, Constants::VOICE_TYPES
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#salience ⇒ Object
readonly
Returns the value of attribute salience.
-
#source_subsystem ⇒ Object
readonly
Returns the value of attribute source_subsystem.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
-
#urgency ⇒ Object
readonly
Returns the value of attribute urgency.
-
#voice ⇒ Object
readonly
Returns the value of attribute voice.
Instance Method Summary collapse
- #background? ⇒ Boolean
- #condensed_content ⇒ Object
- #decay_salience! ⇒ Object
-
#initialize(id:, content:, mode: :narrating, **opts) ⇒ Utterance
constructor
A new instance of Utterance.
- #salient? ⇒ Boolean
- #to_h ⇒ Object
- #urgency_label ⇒ Object
- #urgent? ⇒ Boolean
Constructor Details
#initialize(id:, content:, mode: :narrating, **opts) ⇒ Utterance
Returns a new instance of Utterance.
15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 15 def initialize(id:, content:, mode: :narrating, **opts) @id = id @content = content @mode = resolve_mode(mode) apply_opts(opts) @created_at = Time.now.utc end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def id @id end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def mode @mode end |
#salience ⇒ Object (readonly)
Returns the value of attribute salience.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def salience @salience end |
#source_subsystem ⇒ Object (readonly)
Returns the value of attribute source_subsystem.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def source_subsystem @source_subsystem end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def topic @topic end |
#urgency ⇒ Object (readonly)
Returns the value of attribute urgency.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def urgency @urgency end |
#voice ⇒ Object (readonly)
Returns the value of attribute voice.
12 13 14 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 12 def voice @voice end |
Instance Method Details
#background? ⇒ Boolean
33 34 35 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 33 def background? @urgency < 0.2 end |
#condensed_content ⇒ Object
23 24 25 26 27 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def condensed_content words = @content.split keep = [(words.size * CONDENSATION_RATIO).ceil, 1].max words.first(keep).join(' ') end |
#decay_salience! ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 37 def decay_salience! @salience = [@salience - SALIENCE_DECAY, SALIENCE_FLOOR].max end |
#salient? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 41 def salient? @salience >= 0.3 end |
#to_h ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 50 def to_h { id: @id, content: @content, condensed: condensed_content, mode: @mode, voice: @voice, topic: @topic, urgency: @urgency.round(4), salience: @salience.round(4), source_subsystem: @source_subsystem, urgency_label: urgency_label } end |
#urgency_label ⇒ Object
45 46 47 48 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 45 def urgency_label URGENCY_LABELS.each { |range, lbl| return lbl if range.cover?(@urgency) } :background end |
#urgent? ⇒ Boolean
29 30 31 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 29 def urgent? @urgency >= 0.6 end |