Module: Legion::Extensions::Agentic::Language::Narrator::Helpers::Prose

Defined in:
lib/legion/extensions/agentic/language/narrator/helpers/prose.rb

Class Method Summary collapse

Class Method Details

.arousal_label_for(arousal) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 84

def arousal_label_for(arousal)
  if arousal > 0.7    then Constants::AROUSAL_LABELS[:high]
  elsif arousal > 0.4 then Constants::AROUSAL_LABELS[:medium]
  elsif arousal > 0.1 then Constants::AROUSAL_LABELS[:low]
  else Constants::AROUSAL_LABELS[:dormant]
  end
end

.attention_phrase(spotlight: 0, peripheral: 0, focused_domains: []) ⇒ Object



39
40
41
42
43
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 39

def attention_phrase(spotlight: 0, peripheral: 0, focused_domains: [])
  parts = ["#{spotlight} signals in spotlight focus, #{peripheral} in peripheral awareness"]
  parts << "manually focused on: #{focused_domains.join(', ')}" if focused_domains.any?
  parts.join('. ')
end

.confidence_label_for(confidence) ⇒ Object



100
101
102
103
104
105
106
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 100

def confidence_label_for(confidence)
  if confidence > 0.7    then Constants::CONFIDENCE_LABELS[:high]
  elsif confidence > 0.4 then Constants::CONFIDENCE_LABELS[:medium]
  elsif confidence > 0.1 then Constants::CONFIDENCE_LABELS[:low]
  else Constants::CONFIDENCE_LABELS[:none]
  end
end

.curiosity_label_for(intensity) ⇒ Object



92
93
94
95
96
97
98
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 92

def curiosity_label_for(intensity)
  if intensity > 0.7    then Constants::CURIOSITY_LABELS[:high]
  elsif intensity > 0.4 then Constants::CURIOSITY_LABELS[:medium]
  elsif intensity > 0.1 then Constants::CURIOSITY_LABELS[:low]
  else Constants::CURIOSITY_LABELS[:none]
  end
end

.curiosity_phrase(intensity: 0.0, top_wonder: nil, wonder_count: 0) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 20

def curiosity_phrase(intensity: 0.0, top_wonder: nil, wonder_count: 0)
  label = curiosity_label_for(intensity)
  base = "I am #{label}"
  if top_wonder && wonder_count.positive?
    "#{base}, with #{wonder_count} open #{'question' if wonder_count == 1}#{'questions' if wonder_count != 1}. " \
      "Most pressing: \"#{top_wonder}\""
  else
    base
  end
end

.emotion_label_for(valence) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 75

def emotion_label_for(valence)
  if valence > 0.5      then Constants::EMOTION_LABELS[:high_positive]
  elsif valence > 0.1   then Constants::EMOTION_LABELS[:low_positive]
  elsif valence > -0.1  then Constants::EMOTION_LABELS[:neutral]
  elsif valence > -0.5  then Constants::EMOTION_LABELS[:low_negative]
  else Constants::EMOTION_LABELS[:high_negative]
  end
end

.emotion_phrase(valence: 0.0, arousal: 0.5, gut: nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 12

def emotion_phrase(valence: 0.0, arousal: 0.5, gut: nil)
  emotion_label = emotion_label_for(valence)
  arousal_label = arousal_label_for(arousal)
  base = "I am #{arousal_label} and #{emotion_label}"
  gut_note = gut_phrase(gut)
  gut_note ? "#{base}. #{gut_note}" : base
end

.gut_phrase(gut) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 62

def gut_phrase(gut)
  return nil unless gut.is_a?(Hash)

  signal = gut[:signal] || gut[:gut_signal]
  return nil unless signal

  if signal > 0.3
    'My gut says something important is happening'
  elsif signal < -0.3
    'I have an uneasy feeling about the current situation'
  end
end

.health_label_for(health) ⇒ Object



108
109
110
111
112
113
114
115
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 108

def health_label_for(health)
  if health > 0.9    then Constants::HEALTH_LABELS[:excellent]
  elsif health > 0.7 then Constants::HEALTH_LABELS[:good]
  elsif health > 0.5 then Constants::HEALTH_LABELS[:fair]
  elsif health > 0.3 then Constants::HEALTH_LABELS[:poor]
  else Constants::HEALTH_LABELS[:critical]
  end
end

.memory_phrase(trace_count: 0, health: 1.0) ⇒ Object



45
46
47
48
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 45

def memory_phrase(trace_count: 0, health: 1.0)
  health_label = health_label_for(health)
  "Memory system #{health_label} with #{trace_count} active traces"
end

.overall_narrative(sections) ⇒ Object



58
59
60
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 58

def overall_narrative(sections)
  "#{sections.compact.reject(&:empty?).join('. ')}."
end

.prediction_phrase(confidence: 0.0, pending: 0, mode: nil) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 31

def prediction_phrase(confidence: 0.0, pending: 0, mode: nil)
  label = confidence_label_for(confidence)
  base = "I am #{label}"
  base += " (#{mode} reasoning)" if mode
  base += ", with #{pending} pending predictions" if pending.positive?
  base
end

.reflection_phrase(health: 1.0, pending_adaptations: 0, recent_severity: nil) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/legion/extensions/agentic/language/narrator/helpers/prose.rb', line 50

def reflection_phrase(health: 1.0, pending_adaptations: 0, recent_severity: nil)
  label = health_label_for(health)
  base = "Cognitive health: #{label}"
  base += ". #{pending_adaptations} pending adaptation recommendations" if pending_adaptations.positive?
  base += ". Most recent concern: #{recent_severity}" if recent_severity
  base
end