Module: Legion::Extensions::Agentic::Self::SelfTalk::Runners::SelfTalk
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb
Constant Summary collapse
- VOICE_BANK =
{ critic: [ { content: 'What could go wrong with this approach?', position: :challenge }, { content: 'Are we overlooking any risks here?', position: :challenge }, { content: 'This needs more careful consideration.', position: :caution } ], advocate: [ { content: 'This aligns with our core values.', position: :support }, { content: 'The potential benefits outweigh the risks.', position: :support }, { content: 'We should move forward with this.', position: :affirm } ], explorer: [ { content: 'What alternatives have we not considered?', position: :explore }, { content: 'There may be an unconventional approach here.', position: :explore }, { content: 'Let us examine this from another angle.', position: :clarify } ], pragmatist: [ { content: 'What is the simplest path forward?', position: :simplify }, { content: 'Focus on what is actionable now.', position: :prioritize }, { content: 'We need concrete next steps.', position: :clarify } ] }.freeze
- VOICE_BANK_GENERIC =
[ { content: 'Let us think this through carefully.', position: :clarify }, { content: 'More reflection is needed on this topic.', position: :clarify }, { content: 'What do we know for certain here?', position: :clarify } ].freeze
Instance Method Summary collapse
- #add_turn(dialogue_id:, voice_id:, content:, position: :clarify, strength: 0.5) ⇒ Object
- #amplify_voice(voice_id:, amount: Helpers::Constants::VOLUME_BOOST) ⇒ Object
- #conclude_dialogue(dialogue_id:, summary: nil) ⇒ Object
- #dampen_voice(voice_id:, amount: Helpers::Constants::VOLUME_DECAY) ⇒ Object
- #deadlock_dialogue(dialogue_id:) ⇒ Object
- #decay_voices ⇒ Object
- #dialogue_report(dialogue_id:) ⇒ Object
- #generate_voice_turn(dialogue_id:, voice_id:) ⇒ Object
- #register_voice(name:, voice_type:, volume: Helpers::Constants::DEFAULT_VOLUME, bias_direction: nil) ⇒ Object
- #self_talk_status ⇒ Object
- #start_dialogue(topic:) ⇒ Object
Instance Method Details
#add_turn(dialogue_id:, voice_id:, content:, position: :clarify, strength: 0.5) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 31 def add_turn(dialogue_id:, voice_id:, content:, position: :clarify, strength: 0.5, **) result = engine.add_turn( dialogue_id: dialogue_id, voice_id: voice_id, content: content, position: position, strength: strength ) log.debug "[self_talk] add_turn: dialogue=#{dialogue_id} voice=#{voice_id} added=#{result[:added]}" result end |
#amplify_voice(voice_id:, amount: Helpers::Constants::VOLUME_BOOST) ⇒ Object
72 73 74 75 76 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 72 def amplify_voice(voice_id:, amount: Helpers::Constants::VOLUME_BOOST, **) result = engine.amplify_voice(voice_id: voice_id, amount: amount) log.debug "[self_talk] amplify_voice: id=#{voice_id} volume=#{result[:volume]}" result end |
#conclude_dialogue(dialogue_id:, summary: nil) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 43 def conclude_dialogue(dialogue_id:, summary: nil, **) resolved_summary = summary || generate_summary_for_dialogue(dialogue_id) result = engine.conclude_dialogue(dialogue_id: dialogue_id, summary: resolved_summary) log.info "[self_talk] conclude_dialogue: id=#{dialogue_id} concluded=#{result[:concluded]}" result end |
#dampen_voice(voice_id:, amount: Helpers::Constants::VOLUME_DECAY) ⇒ Object
78 79 80 81 82 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 78 def dampen_voice(voice_id:, amount: Helpers::Constants::VOLUME_DECAY, **) result = engine.dampen_voice(voice_id: voice_id, amount: amount) log.debug "[self_talk] dampen_voice: id=#{voice_id} volume=#{result[:volume]}" result end |
#deadlock_dialogue(dialogue_id:) ⇒ Object
66 67 68 69 70 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 66 def deadlock_dialogue(dialogue_id:, **) result = engine.deadlock_dialogue(dialogue_id: dialogue_id) log.warn "[self_talk] deadlock_dialogue: id=#{dialogue_id} deadlocked=#{result[:deadlocked]}" result end |
#decay_voices ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 96 def decay_voices(**) decayed = 0 voice_list = engine.voices.values.select(&:active).map do |voice| voice.dampen!(Helpers::Constants::VOLUME_DECAY) decayed += 1 { id: voice.id, name: voice.name, volume: voice.volume } end log.debug "[self-talk] voice decay: decayed=#{decayed} voices" { decayed: decayed, voices: voice_list } end |
#dialogue_report(dialogue_id:) ⇒ Object
84 85 86 87 88 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 84 def dialogue_report(dialogue_id:, **) result = engine.dialogue_report(dialogue_id: dialogue_id) log.debug "[self_talk] dialogue_report: id=#{dialogue_id} found=#{result[:found]}" result end |
#generate_voice_turn(dialogue_id:, voice_id:) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 50 def generate_voice_turn(dialogue_id:, voice_id:, **) dialogue_data = engine.dialogues[dialogue_id] voice_data = engine.voices[voice_id] return missing_entity_error(dialogue_data) unless dialogue_data && voice_data content, source = resolve_turn_content(voice_data, dialogue_data) turn_result = add_turn( dialogue_id: dialogue_id, voice_id: voice_id, content: content[:content], position: content[:position] ) log.debug "[self_talk] generate_voice_turn: dialogue=#{dialogue_id} voice=#{voice_id} source=#{source}" { generated: true, source: source, turn: turn_result[:turn] } end |
#register_voice(name:, voice_type:, volume: Helpers::Constants::DEFAULT_VOLUME, bias_direction: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 13 def register_voice(name:, voice_type:, volume: Helpers::Constants::DEFAULT_VOLUME, bias_direction: nil, **) result = engine.register_voice( name: name, voice_type: voice_type, volume: volume, bias_direction: bias_direction ) log.info "[self_talk] register_voice: name=#{name} type=#{voice_type} registered=#{result[:registered]}" result end |
#self_talk_status ⇒ Object
90 91 92 93 94 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 90 def self_talk_status(**) summary = engine.to_h log.debug "[self_talk] status: voices=#{summary[:voice_count]} dialogues=#{summary[:dialogue_count]}" summary end |
#start_dialogue(topic:) ⇒ Object
25 26 27 28 29 |
# File 'lib/legion/extensions/agentic/self/self_talk/runners/self_talk.rb', line 25 def start_dialogue(topic:, **) result = engine.start_dialogue(topic: topic) log.debug "[self_talk] start_dialogue: topic=#{topic} id=#{result[:dialogue][:id]}" result end |