lex-apollo 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f3802ccfc38ce2517807c30308ecf2e0c7257ff164fce30e83529e11ce9762e
4
- data.tar.gz: f07b13160329615265956271795b41cbaaf898d1e0d0084f46bb7598e6f50733
3
+ metadata.gz: e4b61ece5949747c3f9c63d527451975f1bae1193529322a2dfee5c99fe449f7
4
+ data.tar.gz: 2a8ee392eda6931f18e0c8740ef3c7a57737fee787f85755fe4531bac44b1e11
5
5
  SHA512:
6
- metadata.gz: 7179a58756d5a9f6cfbdde00d06f809a99b5795ff2a7bf8aea599785d0fdc18d363228b844fc769f0cd459eabfdec416540f474e814a84713937eff06692d82b
7
- data.tar.gz: 1eb71fa6a968770f8327e026f42a5cf3bce50ceb18c7ab65545e9bc3ecd325f550c9eb3af239e64f456a8e5263ba4cc3faf66729f2e96aa821e9caf3e317dc51
6
+ metadata.gz: beda1e6d911c593184fa43fb457881b7cc2c8c7052761c3172861afa0b6dd39f449ff51484a8a05fba9479957aff0509f27fb4d462c4e15bb979e30ca8a68d68
7
+ data.tar.gz: d21a75d1bfc573144fab0f83cbf37c691a0fb1d5e9ac403ab6aa735ec04b2842d1cd9aeb431f10cd56f5f61f671b67a010257221aadf1e5844dd2435641ea43f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.9] - 2026-03-23
4
+
5
+ ### Fixed
6
+ - Guard `log.info` call in `redistribute_knowledge` with `Legion::Logging` check to prevent `NoMethodError` when `Helpers::Lex` is not loaded
7
+
8
+ ## [0.3.8] - 2026-03-23
9
+
10
+ ### Changed
11
+ - `Helpers::Embedding.generate` now accepts any non-empty embedding vector and auto-detects dimension
12
+ - Added `dimension` and `zero_vector` module methods for dynamic dimension support
13
+ - Removed hardcoded 1536-dimension requirement (supports any embedding model dimension)
14
+
3
15
  ## [0.3.7] - 2026-03-22
4
16
 
5
17
  ### Changed
@@ -5,15 +5,28 @@ module Legion
5
5
  module Apollo
6
6
  module Helpers
7
7
  module Embedding
8
- DIMENSION = 1536
8
+ DEFAULT_DIMENSION = 1536
9
9
 
10
10
  module_function
11
11
 
12
12
  def generate(text:, **)
13
- return Array.new(DIMENSION, 0.0) unless defined?(Legion::LLM) && Legion::LLM.started?
13
+ return zero_vector unless defined?(Legion::LLM) && Legion::LLM.started?
14
14
 
15
15
  result = Legion::LLM.embed(text: text)
16
- result.is_a?(Array) && result.size == DIMENSION ? result : Array.new(DIMENSION, 0.0)
16
+ if result.is_a?(Array) && result.any?
17
+ @dimension = result.size
18
+ result
19
+ else
20
+ zero_vector
21
+ end
22
+ end
23
+
24
+ def dimension
25
+ @dimension || DEFAULT_DIMENSION
26
+ end
27
+
28
+ def zero_vector
29
+ Array.new(dimension, 0.0)
17
30
  end
18
31
  end
19
32
  end
@@ -167,7 +167,7 @@ module Legion
167
167
  redistributed += 1
168
168
  end
169
169
 
170
- log.info "[apollo] redistributed #{redistributed} entries from departing agent=#{agent_id}"
170
+ Legion::Logging.info("[apollo] redistributed #{redistributed} entries from departing agent=#{agent_id}") if defined?(Legion::Logging)
171
171
  { success: true, redistributed: redistributed, agent_id: agent_id }
172
172
  rescue Sequel::Error => e
173
173
  { success: false, error: e.message }
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Apollo
6
- VERSION = '0.3.7'
6
+ VERSION = '0.3.9'
7
7
  end
8
8
  end
9
9
  end
@@ -48,7 +48,7 @@ RSpec.describe Legion::Extensions::Apollo::Helpers::Embedding do
48
48
  end
49
49
  end
50
50
 
51
- context 'when Legion::LLM returns invalid embedding' do
51
+ context 'when Legion::LLM returns a short embedding' do
52
52
  before do
53
53
  llm = Module.new do
54
54
  define_method(:started?) { true }
@@ -59,9 +59,28 @@ RSpec.describe Legion::Extensions::Apollo::Helpers::Embedding do
59
59
  allow(Legion::LLM).to receive(:embed).and_return([0.1, 0.2])
60
60
  end
61
61
 
62
+ it 'accepts the embedding and updates dimension' do
63
+ result = described_class.generate(text: 'hello world')
64
+ expect(result).to eq([0.1, 0.2])
65
+ expect(described_class.dimension).to eq(2)
66
+ end
67
+ end
68
+
69
+ context 'when Legion::LLM returns nil' do
70
+ before do
71
+ llm = Module.new do
72
+ define_method(:started?) { true }
73
+ define_method(:embed) { |_text:| nil }
74
+ extend self
75
+ end
76
+ stub_const('Legion::LLM', llm)
77
+ allow(Legion::LLM).to receive(:embed).and_return(nil)
78
+ end
79
+
62
80
  it 'returns a zero vector as fallback' do
63
81
  result = described_class.generate(text: 'hello world')
64
- expect(result).to eq(Array.new(1536, 0.0))
82
+ expect(result).to be_an(Array)
83
+ expect(result.all?(&:zero?)).to be true
65
84
  end
66
85
  end
67
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-apollo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity