Module: Legion::Extensions::Agentic::Language::ConceptualBlending::Runners::ConceptualBlending

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb

Instance Method Summary collapse

Instance Method Details

#add_space_element(space_id:, name:, properties: {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 22

def add_space_element(space_id:, name:, properties: {}, **)
  log.debug "[conceptual_blending] add_element: space=#{space_id} name=#{name}"
  engine.add_element_to_space(space_id: space_id, name: name, properties: properties)
  { success: true, space_id: space_id, element: name }
rescue ArgumentError => e
  log.debug "[conceptual_blending] add_element failed: #{e.message}"
  { success: false, error: e.message }
end

#add_space_relation(space_id:, from:, to:, type:) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 31

def add_space_relation(space_id:, from:, to:, type:, **)
  log.debug "[conceptual_blending] add_relation: space=#{space_id} #{from}->#{to} type=#{type}"
  engine.add_relation_to_space(space_id: space_id, from: from, to: to, type: type)
  { success: true, space_id: space_id, relation: { from: from, to: to, type: type } }
rescue ArgumentError => e
  log.debug "[conceptual_blending] add_relation failed: #{e.message}"
  { success: false, error: e.message }
end

#best_blends(limit: 5) ⇒ Object



67
68
69
70
71
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 67

def best_blends(limit: 5, **)
  log.debug "[conceptual_blending] best_blends: limit=#{limit}"
  blends = engine.best_blends(limit: limit)
  { success: true, blends: blends.map(&:to_h), count: blends.size }
end

#blend_quality(blend_id:) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 73

def blend_quality(blend_id:, **)
  log.debug "[conceptual_blending] blend_quality: blend=#{blend_id}"
  quality = engine.blend_quality(blend_id: blend_id)
  { success: true }.merge(quality)
rescue ArgumentError => e
  log.debug "[conceptual_blending] blend_quality failed: #{e.message}"
  { success: false, error: e.message }
end

#compress_blend(blend_id:, removed_element:) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 58

def compress_blend(blend_id:, removed_element:, **)
  log.debug "[conceptual_blending] compress: blend=#{blend_id} remove=#{removed_element}"
  blend = engine.compress_blend(blend_id: blend_id, removed_element: removed_element)
  { success: true, blend: blend.to_h }
rescue ArgumentError => e
  log.debug "[conceptual_blending] compress failed: #{e.message}"
  { success: false, error: e.message }
end

#conceptual_blending_statsObject



89
90
91
92
93
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 89

def conceptual_blending_stats(**)
  log.debug '[conceptual_blending] stats'
  stats = engine.to_h
  { success: true }.merge(stats)
end

#create_blend(space_a_id:, space_b_id:, blend_type: :double_scope) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 40

def create_blend(space_a_id:, space_b_id:, blend_type: :double_scope, **)
  log.debug "[conceptual_blending] blend: a=#{space_a_id} b=#{space_b_id} type=#{blend_type}"
  blend = engine.blend(space_a_id: space_a_id, space_b_id: space_b_id, blend_type: blend_type)
  { success: true, blend: blend.to_h }
rescue ArgumentError => e
  log.debug "[conceptual_blending] blend failed: #{e.message}"
  { success: false, error: e.message }
end

#create_mental_space(name:, domain:) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 13

def create_mental_space(name:, domain:, **)
  log.debug "[conceptual_blending] create_space: name=#{name} domain=#{domain}"
  space = engine.create_space(name: name, domain: domain)
  { success: true, space: space.to_h }
rescue ArgumentError => e
  log.debug "[conceptual_blending] create_space failed: #{e.message}"
  { success: false, error: e.message }
end

#elaborate_blend(blend_id:, emergent_property:) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 49

def elaborate_blend(blend_id:, emergent_property:, **)
  log.debug "[conceptual_blending] elaborate: blend=#{blend_id} property=#{emergent_property}"
  blend = engine.elaborate_blend(blend_id: blend_id, emergent_property: emergent_property)
  { success: true, blend: blend.to_h }
rescue ArgumentError => e
  log.debug "[conceptual_blending] elaborate failed: #{e.message}"
  { success: false, error: e.message }
end

#update_conceptual_blendingObject



82
83
84
85
86
87
# File 'lib/legion/extensions/agentic/language/conceptual_blending/runners/conceptual_blending.rb', line 82

def update_conceptual_blending(**)
  log.debug '[conceptual_blending] update: decay + prune cycle'
  decayed = engine.decay_stale
  pruned  = engine.prune_weak
  { success: true, decayed: decayed, pruned: pruned }
end