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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/legion/extensions/apollo/helpers/embedding.rb +16 -3
- data/lib/legion/extensions/apollo/runners/knowledge.rb +1 -1
- data/lib/legion/extensions/apollo/version.rb +1 -1
- data/spec/legion/extensions/apollo/helpers/embedding_spec.rb +21 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4b61ece5949747c3f9c63d527451975f1bae1193529322a2dfee5c99fe449f7
|
|
4
|
+
data.tar.gz: 2a8ee392eda6931f18e0c8740ef3c7a57737fee787f85755fe4531bac44b1e11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
8
|
+
DEFAULT_DIMENSION = 1536
|
|
9
9
|
|
|
10
10
|
module_function
|
|
11
11
|
|
|
12
12
|
def generate(text:, **)
|
|
13
|
-
return
|
|
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.
|
|
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
|
-
|
|
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 }
|
|
@@ -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
|
|
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
|
|
82
|
+
expect(result).to be_an(Array)
|
|
83
|
+
expect(result.all?(&:zero?)).to be true
|
|
65
84
|
end
|
|
66
85
|
end
|
|
67
86
|
end
|