Class: Legion::Extensions::Agentic::Inference::Horizon::Helpers::Projection

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:, domain: :general, horizon_distance: Constants::DEFAULT_HORIZON, confidence: 1.0, construal_level: nil) ⇒ Projection

Returns a new instance of Projection.



14
15
16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 14

def initialize(description:, domain: :general, horizon_distance: Constants::DEFAULT_HORIZON,
               confidence: 1.0, construal_level: nil)
  @id               = SecureRandom.uuid
  @description      = description
  @domain           = domain
  @horizon_distance = horizon_distance.clamp(0.0, 1.0)
  @confidence       = confidence.clamp(0.0, 1.0)
  @construal_level  = construal_level || derive_construal_level(@horizon_distance)
  @created_at       = Time.now.utc
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def confidence
  @confidence
end

#construal_levelObject (readonly)

Returns the value of attribute construal_level.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def construal_level
  @construal_level
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def description
  @description
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def domain
  @domain
end

#horizon_distanceObject (readonly)

Returns the value of attribute horizon_distance.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def horizon_distance
  @horizon_distance
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 12

def id
  @id
end

Instance Method Details

#abstract?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 29

def abstract?
  @horizon_distance >= 0.7
end

#concrete?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 25

def concrete?
  @horizon_distance <= 0.3
end

#to_hObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb', line 33

def to_h
  {
    id:               @id,
    description:      @description,
    domain:           @domain,
    horizon_distance: @horizon_distance.round(10),
    confidence:       @confidence.round(10),
    construal_level:  @construal_level,
    concrete:         concrete?,
    abstract:         abstract?,
    created_at:       @created_at
  }
end