lex-llm-ollama 0.2.22 → 0.2.24
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 +10 -0
- data/lex-llm-ollama.gemspec +1 -1
- data/lib/legion/extensions/llm/ollama/translator.rb +29 -18
- data/lib/legion/extensions/llm/ollama/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe9668a684e60453a26c187e8e5dddfa15835ce18b4b6d627cb32bd17be1fef8
|
|
4
|
+
data.tar.gz: a858a4b969945856c39ba64397067ef1f7c8c776de47b669a1e7b7c8a6704abf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52b01a8dfa63402561d7e5e9b09ed09d92ac7d01ef9dfa0fa04e15463399da4168f6948f0f23e5d1807d6b2f09f04d103079ff35959077d717bbb2f2889fa7aa
|
|
7
|
+
data.tar.gz: 3fccbb4c70de27e38f87d4809f628819f33ff9ce4a3640b7cf29c67deda5b01ed394797b7c1ddb438f980d680d2bd0c8768b4388a2e57ff8e1d62f1cc4ccc5b5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.24] - 2026-07-24
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Translator propagates `done_reason` and usage through content chunks.** When ollama sends `done: true` on a chunk that also has content, the stop_reason and usage were previously lost. Now extracts them before branching and passes through to whatever chunk type is emitted.
|
|
7
|
+
|
|
8
|
+
## [0.2.23] - 2026-07-05
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Stop_reason mapping now uses the shared `Legion::Extensions::Llm::StopReasonMapping` mixin from lex-llm (>= 0.6.9) instead of a local `OLLAMA_STOP_REASON_MAP` (a copy of the same drifting 3-entry map vLLM carried). The shared vocabulary maps `tool_calls`/`tool_use`/`function_call` to `:tool_use` (plus `stop`/`end_turn`/`eos`, `length`/`max_tokens`, `stop_sequence`, `content_filter`) and is inherited by every provider so it no longer drifts per gem. Ollama's `done_reason`-to-stop_reason resolution is unchanged in behavior.
|
|
12
|
+
|
|
3
13
|
## [0.2.22] - 2026-06-20
|
|
4
14
|
|
|
5
15
|
### Fixed
|
data/lex-llm-ollama.gemspec
CHANGED
|
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_dependency 'legion-logging', '>= 1.3.2'
|
|
28
28
|
spec.add_dependency 'legion-settings', '>= 1.3.14'
|
|
29
29
|
spec.add_dependency 'legion-transport', '>= 1.4.14'
|
|
30
|
-
spec.add_dependency 'lex-llm', '>= 0.6.
|
|
30
|
+
spec.add_dependency 'lex-llm', '>= 0.6.9'
|
|
31
31
|
end
|
|
@@ -21,13 +21,10 @@ module Legion
|
|
|
21
21
|
# - assistant_prefill: false — Ollama does not support assistant prefill.
|
|
22
22
|
class Translator
|
|
23
23
|
include Legion::Logging::Helper
|
|
24
|
+
# Shared stop_reason vocabulary. Ollama returns structured tool_calls and
|
|
25
|
+
# OpenAI-style done_reason strings; inherits the common map.
|
|
26
|
+
include Legion::Extensions::Llm::StopReasonMapping
|
|
24
27
|
|
|
25
|
-
# Ollama-specific stop_reason mapping (done_reason field).
|
|
26
|
-
OLLAMA_STOP_REASON_MAP = {
|
|
27
|
-
'stop' => :end_turn,
|
|
28
|
-
'tool_use' => :tool_use,
|
|
29
|
-
'length' => :max_tokens
|
|
30
|
-
}.freeze
|
|
31
28
|
FALLBACK_STOP_REASON = :end_turn
|
|
32
29
|
|
|
33
30
|
# G18 parameter mapping: canonical params -> Ollama options keys.
|
|
@@ -392,7 +389,7 @@ module Legion
|
|
|
392
389
|
|
|
393
390
|
def map_stop_reason(done_reason, done = nil)
|
|
394
391
|
if done_reason
|
|
395
|
-
|
|
392
|
+
stop_reason_lookup(done_reason) || FALLBACK_STOP_REASON
|
|
396
393
|
elsif done
|
|
397
394
|
FALLBACK_STOP_REASON
|
|
398
395
|
end
|
|
@@ -420,16 +417,24 @@ module Legion
|
|
|
420
417
|
done_reason = data[:done_reason] || data['done_reason']
|
|
421
418
|
request_id = data[:request_id] || data['request_id'] || data[:id] || data['id']
|
|
422
419
|
|
|
420
|
+
chunk_stop_reason = done_reason ? map_stop_reason(done_reason, done) : nil
|
|
421
|
+
chunk_usage = done ? build_chunk_usage(data) : nil
|
|
422
|
+
|
|
423
423
|
# Tool call delta
|
|
424
424
|
tool_calls = message[:tool_calls] || message['tool_calls']
|
|
425
|
-
|
|
425
|
+
unless Array(tool_calls).empty?
|
|
426
|
+
return build_tool_call_chunk(tool_calls, request_id,
|
|
427
|
+
stop_reason: chunk_stop_reason, usage: chunk_usage)
|
|
428
|
+
end
|
|
426
429
|
|
|
427
430
|
# Thinking delta
|
|
428
431
|
thinking_content = message[:thinking] || message['thinking']
|
|
429
432
|
unless thinking_content.to_s.empty?
|
|
430
433
|
return Canonical::Chunk.thinking_delta(
|
|
431
434
|
delta: thinking_content.to_s,
|
|
432
|
-
request_id: request_id
|
|
435
|
+
request_id: request_id,
|
|
436
|
+
stop_reason: chunk_stop_reason,
|
|
437
|
+
usage: chunk_usage
|
|
433
438
|
)
|
|
434
439
|
end
|
|
435
440
|
|
|
@@ -438,7 +443,9 @@ module Legion
|
|
|
438
443
|
unless content.to_s.empty?
|
|
439
444
|
return Canonical::Chunk.text_delta(
|
|
440
445
|
delta: content.to_s,
|
|
441
|
-
request_id: request_id
|
|
446
|
+
request_id: request_id,
|
|
447
|
+
stop_reason: chunk_stop_reason,
|
|
448
|
+
usage: chunk_usage
|
|
442
449
|
)
|
|
443
450
|
end
|
|
444
451
|
|
|
@@ -448,20 +455,22 @@ module Legion
|
|
|
448
455
|
nil
|
|
449
456
|
end
|
|
450
457
|
|
|
451
|
-
def
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
458
|
+
def build_chunk_usage(data)
|
|
459
|
+
Canonical::Usage.from_hash({
|
|
460
|
+
input_tokens: data[:prompt_eval_count] || data['prompt_eval_count'],
|
|
461
|
+
output_tokens: data[:eval_count] || data['eval_count']
|
|
462
|
+
})
|
|
463
|
+
end
|
|
456
464
|
|
|
465
|
+
def build_done_chunk(data, done_reason, request_id)
|
|
457
466
|
Canonical::Chunk.done(
|
|
458
467
|
request_id: request_id,
|
|
459
|
-
usage:
|
|
468
|
+
usage: build_chunk_usage(data),
|
|
460
469
|
stop_reason: map_stop_reason(done_reason, true)
|
|
461
470
|
)
|
|
462
471
|
end
|
|
463
472
|
|
|
464
|
-
def build_tool_call_chunk(tool_calls, request_id)
|
|
473
|
+
def build_tool_call_chunk(tool_calls, request_id, stop_reason: nil, usage: nil)
|
|
465
474
|
first_call = tool_calls.first
|
|
466
475
|
first_call = first_call.transform_keys(&:to_sym) if first_call.is_a?(Hash)
|
|
467
476
|
function = first_call[:function] || first_call['function'] || {}
|
|
@@ -476,7 +485,9 @@ module Legion
|
|
|
476
485
|
|
|
477
486
|
Canonical::Chunk.tool_call_delta(
|
|
478
487
|
tool_call: tc,
|
|
479
|
-
request_id: request_id
|
|
488
|
+
request_id: request_id,
|
|
489
|
+
stop_reason: stop_reason,
|
|
490
|
+
usage: usage
|
|
480
491
|
)
|
|
481
492
|
end
|
|
482
493
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-llm-ollama
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LegionIO
|
|
@@ -71,14 +71,14 @@ dependencies:
|
|
|
71
71
|
requirements:
|
|
72
72
|
- - ">="
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.6.
|
|
74
|
+
version: 0.6.9
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.6.
|
|
81
|
+
version: 0.6.9
|
|
82
82
|
description: Ollama provider integration for the LegionIO LLM routing framework.
|
|
83
83
|
email:
|
|
84
84
|
- matthewdiverson@gmail.com
|