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.
26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 26 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.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def id @id end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def mode @mode end |
#salience ⇒ Object (readonly)
Returns the value of attribute salience.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def salience @salience end |
#source_subsystem ⇒ Object (readonly)
Returns the value of attribute source_subsystem.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def source_subsystem @source_subsystem end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def topic @topic end |
#urgency ⇒ Object (readonly)
Returns the value of attribute urgency.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def urgency @urgency end |
#voice ⇒ Object (readonly)
Returns the value of attribute voice.
23 24 25 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 23 def voice @voice end |
Instance Method Details
#background? ⇒ Boolean
44 45 46 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 44 def background? @urgency < 0.2 end |
#condensed_content ⇒ Object
34 35 36 37 38 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 34 def condensed_content words = @content.split keep = [(words.size * CONDENSATION_RATIO).ceil, 1].max words.first(keep).join(' ') end |
#decay_salience! ⇒ Object
48 49 50 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 48 def decay_salience! @salience = [@salience - SALIENCE_DECAY, SALIENCE_FLOOR].max end |
#salient? ⇒ Boolean
52 53 54 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 52 def salient? @salience >= 0.3 end |
#to_h ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 61 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
56 57 58 59 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 56 def urgency_label URGENCY_LABELS.each { |range, lbl| return lbl if range.cover?(@urgency) } :background end |
#urgent? ⇒ Boolean
40 41 42 |
# File 'lib/legion/extensions/agentic/language/inner_speech/helpers/utterance.rb', line 40 def urgent? @urgency >= 0.6 end |