Class: Legion::Extensions::Agentic::Memory::Transfer::Helpers::DomainKnowledge

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb

Constant Summary collapse

PROFICIENCY_LABELS =
[
  [0.0, 0.2,  'novice'],
  [0.2, 0.4,  'beginner'],
  [0.4, 0.6,  'intermediate'],
  [0.6, 0.8,  'advanced'],
  [0.8, 1.01, 'expert']
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain:) ⇒ DomainKnowledge

Returns a new instance of DomainKnowledge.



22
23
24
25
26
27
28
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 22

def initialize(domain:)
  @id             = SecureRandom.uuid
  @domain         = domain
  @proficiency    = 0.0
  @learn_count    = 0
  @transfer_count = 0
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 12

def id
  @id
end

#learn_countObject (readonly)

Returns the value of attribute learn_count.



12
13
14
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 12

def learn_count
  @learn_count
end

#proficiencyObject (readonly)

Returns the value of attribute proficiency.



12
13
14
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 12

def proficiency
  @proficiency
end

#transfer_countObject (readonly)

Returns the value of attribute transfer_count.



12
13
14
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 12

def transfer_count
  @transfer_count
end

Instance Method Details

#apply_boost!(amount) ⇒ Object



41
42
43
44
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 41

def apply_boost!(amount)
  @proficiency = (@proficiency + amount).clamp(0.0, 1.0).round(10)
  self
end

#apply_penalty!(amount) ⇒ Object



46
47
48
49
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 46

def apply_penalty!(amount)
  @proficiency = (@proficiency - amount).clamp(0.0, 1.0).round(10)
  self
end

#learn!(amount:) ⇒ Object



30
31
32
33
34
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 30

def learn!(amount:)
  @proficiency = (@proficiency + amount).clamp(0.0, 1.0).round(10)
  @learn_count += 1
  self
end

#proficiency_labelObject



51
52
53
54
55
56
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 51

def proficiency_label
  PROFICIENCY_LABELS.each do |low, high, label|
    return label if @proficiency >= low && @proficiency < high
  end
  'novice'
end

#record_transfer!Object



36
37
38
39
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 36

def record_transfer!
  @transfer_count += 1
  self
end

#to_hObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb', line 58

def to_h
  {
    id:                @id,
    domain:            @domain,
    proficiency:       @proficiency.round(10),
    proficiency_label: proficiency_label,
    learn_count:       @learn_count,
    transfer_count:    @transfer_count
  }
end