Class: Legion::Extensions::Agentic::Self::SelfTalk::Helpers::DialogueTurn

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb

Constant Summary collapse

POSITIONS =
%i[support oppose question clarify].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dialogue_id:, voice_id:, content:, position: :clarify, strength: 0.5) ⇒ DialogueTurn

Returns a new instance of DialogueTurn.



16
17
18
19
20
21
22
23
24
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 16

def initialize(dialogue_id:, voice_id:, content:, position: :clarify, strength: 0.5)
  @id          = SecureRandom.uuid
  @dialogue_id = dialogue_id
  @voice_id    = voice_id
  @content     = content
  @position    = POSITIONS.include?(position) ? position : :clarify
  @strength    = strength.clamp(0.0, 1.0)
  @created_at  = Time.now.utc
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def created_at
  @created_at
end

#dialogue_idObject (readonly)

Returns the value of attribute dialogue_id.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def dialogue_id
  @dialogue_id
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def id
  @id
end

#positionObject (readonly)

Returns the value of attribute position.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def position
  @position
end

#strengthObject (readonly)

Returns the value of attribute strength.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def strength
  @strength
end

#voice_idObject (readonly)

Returns the value of attribute voice_id.



14
15
16
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 14

def voice_id
  @voice_id
end

Instance Method Details

#to_hObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/dialogue_turn.rb', line 26

def to_h
  {
    id:          @id,
    dialogue_id: @dialogue_id,
    voice_id:    @voice_id,
    content:     @content,
    position:    @position,
    strength:    @strength.round(10),
    created_at:  @created_at
  }
end