Class: Legion::Extensions::Agentic::Integration::Synthesis::Helpers::Synthesis

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb

Constant Summary

Constants included from Constants

Constants::COHERENCE_LABELS, Constants::COHERENCE_THRESHOLD, Constants::CONFIDENCE_LABELS, Constants::DEFAULT_WEIGHT, Constants::FRESHNESS_DECAY, Constants::MAX_STREAMS, Constants::MAX_SYNTHESES, Constants::MIN_STREAMS_FOR_SYNTHESIS, Constants::NOVELTY_THRESHOLD, Constants::STREAM_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(streams:, coherence:, novelty:, confidence:, content:) ⇒ Synthesis

Returns a new instance of Synthesis.



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

def initialize(streams:, coherence:, novelty:, confidence:, content:)
  @id         = SecureRandom.uuid
  @streams    = streams
  @coherence  = coherence.clamp(0.0, 1.0)
  @novelty    = novelty.clamp(0.0, 1.0)
  @confidence = confidence.clamp(0.0, 1.0)
  @content    = content
  @created_at = Time.now.utc
end

Instance Attribute Details

#coherenceObject (readonly)

Returns the value of attribute coherence.



14
15
16
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 14

def coherence
  @coherence
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



14
15
16
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 14

def confidence
  @confidence
end

#contentObject (readonly)

Returns the value of attribute content.



14
15
16
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.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/integration/synthesis/helpers/synthesis.rb', line 14

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 14

def id
  @id
end

#noveltyObject (readonly)

Returns the value of attribute novelty.



14
15
16
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 14

def novelty
  @novelty
end

#streamsObject (readonly)

Returns the value of attribute streams.



14
15
16
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 14

def streams
  @streams
end

Instance Method Details

#coherence_labelObject



34
35
36
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 34

def coherence_label
  COHERENCE_LABELS.find { |range, _| range.cover?(@coherence) }&.last || :chaotic
end

#confidence_labelObject



38
39
40
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 38

def confidence_label
  CONFIDENCE_LABELS.find { |range, _| range.cover?(@confidence) }&.last || :guessing
end

#fragmented?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 26

def fragmented?
  @coherence < COHERENCE_THRESHOLD
end

#novel?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 30

def novel?
  @novelty > NOVELTY_THRESHOLD
end

#to_hObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb', line 42

def to_h
  {
    id:               @id,
    streams:          @streams,
    coherence:        @coherence,
    novelty:          @novelty,
    confidence:       @confidence,
    content:          @content,
    fragmented:       fragmented?,
    novel:            novel?,
    coherence_label:  coherence_label,
    confidence_label: confidence_label,
    created_at:       @created_at
  }
end