legion-llm 0.5.11 → 0.5.12
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 +8 -0
- data/lib/legion/llm/pipeline/steps/knowledge_capture.rb +39 -12
- data/lib/legion/llm/pipeline/steps/rag_context.rb +23 -5
- data/lib/legion/llm/version.rb +1 -1
- 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: d3d1202bc5192676ef21a045629561762a5b4b48b924df76a1d1867bb9c7fcfb
|
|
4
|
+
data.tar.gz: b67db39aa8974294a5bd45ea90408709d371a8a0186e7a120688b7773a35a518
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e15b22d7a9a10ecccf2cb868551736e1518e9d3cc8236a6efdab68d92f0e780b703f4047d0ab69cdea6eb6fa529714e0779c9a0f2da9a61df2501b890e33b88
|
|
7
|
+
data.tar.gz: 1f49b84a3a30fe42cb4dd59c534ac0c35de96777cf8e2fa63c1017ddf38a1d040a6d36a84a55ecec3945813b71e784973cd6e9edc87a05b7a631d5b82536f5be
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Legion LLM Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.12] - 2026-03-26
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- RagContext (step 8): `apollo_available?` now also returns true when `Legion::Apollo.started?`; `apollo_retrieve` calls `Legion::Apollo.retrieve(scope: :all)` to merge global + local results when the core library is available
|
|
7
|
+
- KnowledgeCapture (step 19): after global writeback, also writes response content to `Legion::Apollo::Local` when started — tags with `['llm_response', model]`
|
|
8
|
+
- `local_capture_enabled?` guard — only writes to local store when `Apollo::Local.started?`, no-op otherwise
|
|
9
|
+
- `ingest_to_local` rescues errors and appends to `@warnings` — pipeline never crashes on local ingest failure
|
|
10
|
+
|
|
3
11
|
## [0.5.11] - 2026-03-25
|
|
4
12
|
|
|
5
13
|
### Added
|
|
@@ -6,24 +6,51 @@ module Legion
|
|
|
6
6
|
module Steps
|
|
7
7
|
module KnowledgeCapture
|
|
8
8
|
def step_knowledge_capture
|
|
9
|
-
return unless defined?(Legion::Extensions::Apollo::Helpers::Writeback)
|
|
10
|
-
|
|
11
9
|
response = current_response
|
|
10
|
+
|
|
11
|
+
if defined?(Legion::Extensions::Apollo::Helpers::Writeback)
|
|
12
|
+
Legion::Extensions::Apollo::Helpers::Writeback.evaluate_and_route(
|
|
13
|
+
request: @request,
|
|
14
|
+
response: response,
|
|
15
|
+
enrichments: @enrichments
|
|
16
|
+
)
|
|
17
|
+
@timeline.record(
|
|
18
|
+
category: :knowledge, key: 'knowledge:capture',
|
|
19
|
+
direction: :outbound, detail: 'evaluated writeback to apollo',
|
|
20
|
+
from: 'pipeline', to: 'apollo'
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
ingest_to_local(response: response) if local_capture_enabled?
|
|
25
|
+
rescue StandardError => e
|
|
26
|
+
@warnings << "knowledge_capture error: #{e.message}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def local_capture_enabled?
|
|
32
|
+
defined?(::Legion::Apollo::Local) && ::Legion::Apollo::Local.started?
|
|
33
|
+
rescue StandardError
|
|
34
|
+
false
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def ingest_to_local(response:)
|
|
12
38
|
return unless response
|
|
13
39
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
40
|
+
content = response.message[:content].to_s
|
|
41
|
+
return if content.empty?
|
|
42
|
+
|
|
43
|
+
model = response.routing[:model].to_s
|
|
44
|
+
tags = ['llm_response', model].reject(&:empty?)
|
|
19
45
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
46
|
+
::Legion::Apollo::Local.ingest(
|
|
47
|
+
content: content,
|
|
48
|
+
tags: tags,
|
|
49
|
+
source_channel: 'llm_pipeline',
|
|
50
|
+
confidence: 0.8
|
|
24
51
|
)
|
|
25
52
|
rescue StandardError => e
|
|
26
|
-
@warnings << "
|
|
53
|
+
@warnings << "local_knowledge_capture error: #{e.message}"
|
|
27
54
|
end
|
|
28
55
|
end
|
|
29
56
|
end
|
|
@@ -107,18 +107,36 @@ module Legion
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def apollo_available?
|
|
110
|
-
defined?(::Legion::Extensions::Apollo::Runners::Knowledge)
|
|
110
|
+
return true if defined?(::Legion::Extensions::Apollo::Runners::Knowledge)
|
|
111
|
+
|
|
112
|
+
defined?(::Legion::Apollo) && ::Legion::Apollo.started?
|
|
113
|
+
rescue StandardError
|
|
114
|
+
false
|
|
111
115
|
end
|
|
112
116
|
|
|
113
117
|
def apollo_retrieve(query:, strategy:)
|
|
114
118
|
full_limit = rag_settings.fetch(:full_limit, 10)
|
|
115
119
|
compact_limit = rag_settings.fetch(:compact_limit, 5)
|
|
116
120
|
confidence = rag_settings.fetch(:min_confidence, 0.5)
|
|
117
|
-
|
|
118
121
|
limit = strategy == :rag_compact ? compact_limit : full_limit
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
|
|
123
|
+
if defined?(::Legion::Extensions::Apollo::Runners::Knowledge)
|
|
124
|
+
::Legion::Extensions::Apollo::Runners::Knowledge.retrieve_relevant(
|
|
125
|
+
query: query, limit: limit, min_confidence: confidence
|
|
126
|
+
)
|
|
127
|
+
elsif defined?(::Legion::Apollo)
|
|
128
|
+
begin
|
|
129
|
+
if ::Legion::Apollo.started?
|
|
130
|
+
::Legion::Apollo.retrieve(text: query, limit: limit, scope: :all)
|
|
131
|
+
else
|
|
132
|
+
[]
|
|
133
|
+
end
|
|
134
|
+
rescue StandardError
|
|
135
|
+
[]
|
|
136
|
+
end
|
|
137
|
+
else
|
|
138
|
+
[]
|
|
139
|
+
end
|
|
122
140
|
end
|
|
123
141
|
|
|
124
142
|
def extract_query
|
data/lib/legion/llm/version.rb
CHANGED