Class: Legion::Extensions::Agentic::Integration::Synthesis::Helpers::SynthesisStream
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Integration::Synthesis::Helpers::SynthesisStream
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.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
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#freshness ⇒ Object
readonly
Returns the value of attribute freshness.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#stream_type ⇒ Object
readonly
Returns the value of attribute stream_type.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #coherence_label ⇒ Object
- #confidence_label ⇒ Object
- #decay_freshness! ⇒ Object
- #effective_weight ⇒ Object
-
#initialize(stream_type:, content:, weight: DEFAULT_WEIGHT, confidence: DEFAULT_WEIGHT) ⇒ SynthesisStream
constructor
A new instance of SynthesisStream.
- #stale? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(stream_type:, content:, weight: DEFAULT_WEIGHT, confidence: DEFAULT_WEIGHT) ⇒ SynthesisStream
Returns a new instance of SynthesisStream.
16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 16 def initialize(stream_type:, content:, weight: DEFAULT_WEIGHT, confidence: DEFAULT_WEIGHT) @id = SecureRandom.uuid @stream_type = stream_type @content = content @weight = weight.clamp(0.0, 1.0) @confidence = confidence.clamp(0.0, 1.0) @freshness = 1.0 @created_at = Time.now.utc end |
Instance Attribute Details
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def confidence @confidence end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def created_at @created_at end |
#freshness ⇒ Object (readonly)
Returns the value of attribute freshness.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def freshness @freshness end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def id @id end |
#stream_type ⇒ Object (readonly)
Returns the value of attribute stream_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def stream_type @stream_type end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 14 def weight @weight end |
Instance Method Details
#coherence_label ⇒ Object
38 39 40 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 38 def coherence_label COHERENCE_LABELS.find { |range, _| range.cover?(@weight) }&.last || :chaotic end |
#confidence_label ⇒ Object
42 43 44 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 42 def confidence_label CONFIDENCE_LABELS.find { |range, _| range.cover?(@confidence) }&.last || :guessing end |
#decay_freshness! ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 26 def decay_freshness! @freshness = (@freshness - FRESHNESS_DECAY).clamp(0.0, 1.0) end |
#effective_weight ⇒ Object
34 35 36 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 34 def effective_weight (@weight * @freshness * @confidence).round(10) end |
#stale? ⇒ Boolean
30 31 32 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 30 def stale? @freshness < 0.1 end |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb', line 46 def to_h { id: @id, stream_type: @stream_type, content: @content, weight: @weight, confidence: @confidence, freshness: @freshness, effective_weight: effective_weight, stale: stale?, coherence_label: coherence_label, confidence_label: confidence_label, created_at: @created_at } end |