lex-llm-ollama 0.1.5 → 0.1.6

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: a2dc0a8753b2476cdcbfc6828b668c237e90a3cab9cbdc54871318c5278f5584
4
- data.tar.gz: 816cfdf03f47f05413992fb71ff1753b49a6451197ca753965e077a94e2c7626
3
+ metadata.gz: a9b4ccf479be5fe7a785b15c5a8f5cc328c3e916736d75b22584af2a7e3488b5
4
+ data.tar.gz: 8ee2de3a028a8a877a4055e83019652feb8208f1d359db91584b9a795b5b20ed
5
5
  SHA512:
6
- metadata.gz: 3f2c7ac5d68f8d1ef5a95d9a20eed2dfa186d759a590c385b7b325c39fa973c149622c30373f8f03acd882915487cacb4815cf332cd3079b4df3629d0bd52d2a
7
- data.tar.gz: eb0a2212c0e4623d253e702204cbfb0733aa27948399ef238d34bd8539b19cc757b11662cc35b0e4ca8b731b815d2994b38c6f7b19db8b8a5cb93fa5013bc7fa
6
+ metadata.gz: de11691a812a9a45ec23ee8b2391cdc902c77043acd368f6b48d3ace4e53acd20da23a8d8d2b66d90a6878542ec186d6b2bf809a86e660b545ff5fe2aeed8577
7
+ data.tar.gz: 8080ef3565c62e8c587036d70fce6f08ac15c4890b3d5b4316a1cf8f85ac9407483c0638292d1bd24857451490a9a49d4287db40c75f5a921d1a4d5dfffa6a6e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.6 - 2026-04-30
4
+
5
+ - Add `Legion::Logging::Helper` to Ollama module, RegistryPublisher, and RegistryEventBuilder.
6
+ - Replace all bare rescue blocks with `handle_exception` calls including level, handled, and operation.
7
+ - Add info-level action logging to Provider key actions: list_running_models, readiness, list_models, show_model, pull_model.
8
+ - Add info-level logging to RegistryPublisher publish methods.
9
+ - Add rescue-with-handle_exception to Provider#list_running_models, show_model, and pull_model.
10
+ - Update README to reflect current architecture and file layout.
11
+
3
12
  ## 0.1.5 - 2026-04-28
4
13
 
5
14
  - Publish best-effort provider/model availability events to `llm.registry` from Ollama readiness and model discovery.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # lex-llm-ollama
2
2
 
3
- LegionIO LLM provider extension for Ollama.
3
+ LegionIO LLM provider extension for [Ollama](https://ollama.ai).
4
4
 
5
5
  This gem lives under `Legion::Extensions::Llm::Ollama` and depends on `lex-llm` for shared provider-neutral routing, fleet, and schema primitives.
6
6
 
@@ -10,14 +10,27 @@ Load it with `require 'legion/extensions/llm/ollama'`.
10
10
 
11
11
  - `Legion::Extensions::Llm::Provider` registration as `:ollama`
12
12
  - Ollama-native chat requests through `POST /api/chat`
13
- - streaming chat support
14
- - model discovery through `GET /api/tags`
15
- - running model inspection through `GET /api/ps`
16
- - model details through `POST /api/show`
17
- - model download helper through `POST /api/pull`
18
- - embeddings through `POST /api/embed`
19
- - best-effort `llm.registry` availability events from readiness and model discovery when Legion Transport is loaded
20
- - shared fleet/default settings via `Legion::Extensions::Llm.provider_settings`
13
+ - Streaming chat support
14
+ - Model discovery through `GET /api/tags`
15
+ - Running model inspection through `GET /api/ps`
16
+ - Model details through `POST /api/show`
17
+ - Model download helper through `POST /api/pull`
18
+ - Embeddings through `POST /api/embed`
19
+ - Best-effort `llm.registry` availability events from readiness and model discovery when Legion Transport is loaded
20
+ - Shared fleet/default settings via `Legion::Extensions::Llm.provider_settings`
21
+ - Full `Legion::Logging::Helper` integration with structured `handle_exception` in every rescue block
22
+
23
+ ## Architecture
24
+
25
+ ```
26
+ Legion::Extensions::Llm::Ollama
27
+ ├── Provider # Ollama provider (chat, stream, embed, models, readiness)
28
+ ├── RegistryPublisher # Best-effort async llm.registry event publishing
29
+ ├── RegistryEventBuilder # Sanitized lex-llm registry envelope construction
30
+ └── Transport/
31
+ ├── Exchanges::LlmRegistry # Topic exchange for llm.registry
32
+ └── Messages::RegistryEvent # AMQP message wrapper for registry events
33
+ ```
21
34
 
22
35
  ## Defaults
23
36
 
@@ -46,3 +59,16 @@ Legion::Extensions::Llm.configure do |config|
46
59
  config.default_embedding_model = "nomic-embed-text:latest"
47
60
  end
48
61
  ```
62
+
63
+ ## Development
64
+
65
+ ```bash
66
+ bundle install
67
+ bundle exec rspec # 0 failures
68
+ bundle exec rubocop -A # auto-fix
69
+ bundle exec rubocop # lint check
70
+ ```
71
+
72
+ ## License
73
+
74
+ Apache-2.0
@@ -47,27 +47,42 @@ module Legion
47
47
  def version_url = '/api/version'
48
48
 
49
49
  def list_running_models
50
+ log.info { "listing running models from #{api_base}#{running_models_url}" }
50
51
  connection.get(running_models_url).body.fetch('models', [])
52
+ rescue StandardError => e
53
+ handle_exception(e, level: :error, handled: true, operation: 'ollama.list_running_models')
54
+ []
51
55
  end
52
56
 
53
57
  def readiness(live: false)
58
+ log.info { "checking readiness live=#{live} at #{api_base}" }
54
59
  super.tap do |metadata|
55
60
  self.class.registry_publisher.publish_readiness_async(metadata) if live
56
61
  end
57
62
  end
58
63
 
59
64
  def list_models
65
+ log.info { "discovering models from #{api_base}#{models_url}" }
60
66
  super.tap do |models|
67
+ log.info { "discovered #{models.size} model(s) from Ollama" }
61
68
  self.class.registry_publisher.publish_models_async(models, readiness: readiness(live: false))
62
69
  end
63
70
  end
64
71
 
65
72
  def show_model(model)
73
+ log.info { "fetching model details for #{model}" }
66
74
  connection.post(show_model_url, { model: model }).body
75
+ rescue StandardError => e
76
+ handle_exception(e, level: :error, handled: true, operation: 'ollama.show_model')
77
+ raise
67
78
  end
68
79
 
69
80
  def pull_model(model, stream: false)
81
+ log.info { "pulling model #{model} stream=#{stream}" }
70
82
  connection.post(pull_url, { model: model, stream: stream }).body
83
+ rescue StandardError => e
84
+ handle_exception(e, level: :error, handled: true, operation: 'ollama.pull_model')
85
+ raise
71
86
  end
72
87
 
73
88
  private
@@ -6,6 +6,8 @@ module Legion
6
6
  module Ollama
7
7
  # Builds sanitized lex-llm registry envelopes for Ollama provider state.
8
8
  class RegistryEventBuilder # rubocop:disable Metrics/ClassLength
9
+ include Legion::Logging::Helper
10
+
9
11
  def readiness(readiness)
10
12
  registry_event_class.public_send(
11
13
  readiness[:ready] ? :available : :unavailable,
@@ -129,7 +131,8 @@ module Legion
129
131
  configured_node = (::Legion::Settings.dig(:node, :canonical_name) if defined?(::Legion::Settings))
130
132
  value = configured_node.to_s.strip
131
133
  value.empty? ? :ollama : value.to_sym
132
- rescue StandardError
134
+ rescue StandardError => e
135
+ handle_exception(e, level: :debug, handled: true, operation: 'ollama.registry.provider_instance')
133
136
  :ollama
134
137
  end
135
138
 
@@ -6,6 +6,8 @@ module Legion
6
6
  module Ollama
7
7
  # Best-effort publisher for Ollama provider availability events.
8
8
  class RegistryPublisher
9
+ include Legion::Logging::Helper
10
+
9
11
  APP_ID = 'lex-llm-ollama'
10
12
 
11
13
  def initialize(builder: RegistryEventBuilder.new)
@@ -13,10 +15,12 @@ module Legion
13
15
  end
14
16
 
15
17
  def publish_readiness_async(readiness)
18
+ log.info { 'publishing readiness event to llm.registry' }
16
19
  schedule { publish_event(@builder.readiness(readiness)) }
17
20
  end
18
21
 
19
22
  def publish_models_async(models, readiness:)
23
+ log.info { "publishing #{Array(models).size} model event(s) to llm.registry" }
20
24
  schedule do
21
25
  Array(models).each do |model|
22
26
  publish_event(@builder.model_available(model, readiness:))
@@ -33,10 +37,10 @@ module Legion
33
37
  Thread.current.abort_on_exception = false
34
38
  yield
35
39
  rescue StandardError => e
36
- log_publish_failure(e, level: :debug)
40
+ handle_exception(e, level: :debug, handled: true, operation: 'ollama.registry.schedule_thread')
37
41
  end
38
42
  rescue StandardError => e
39
- log_publish_failure(e, level: :debug)
43
+ handle_exception(e, level: :debug, handled: true, operation: 'ollama.registry.schedule')
40
44
  false
41
45
  end
42
46
 
@@ -45,7 +49,7 @@ module Legion
45
49
 
46
50
  message_class.new(event:, app_id: APP_ID).publish(spool: false)
47
51
  rescue StandardError => e
48
- log_publish_failure(e)
52
+ handle_exception(e, level: :warn, handled: true, operation: 'ollama.registry.publish_event')
49
53
  false
50
54
  end
51
55
 
@@ -56,7 +60,8 @@ module Legion
56
60
  return true unless ::Legion::Transport::Connection.respond_to?(:session_open?)
57
61
 
58
62
  ::Legion::Transport::Connection.session_open?
59
- rescue StandardError
63
+ rescue StandardError => e
64
+ handle_exception(e, level: :debug, handled: true, operation: 'ollama.registry.publishing_available?')
60
65
  false
61
66
  end
62
67
 
@@ -70,7 +75,8 @@ module Legion
70
75
 
71
76
  require 'legion/extensions/llm/ollama/transport/messages/registry_event'
72
77
  message_class_defined?
73
- rescue LoadError
78
+ rescue LoadError => e
79
+ handle_exception(e, level: :debug, handled: true, operation: 'ollama.registry.transport_load')
74
80
  false
75
81
  end
76
82
 
@@ -81,18 +87,6 @@ module Legion
81
87
  def message_class
82
88
  ::Legion::Extensions::Llm::Ollama::Transport::Messages::RegistryEvent
83
89
  end
84
-
85
- def log_publish_failure(error, level: :warn)
86
- message = "[lex-llm-ollama] llm.registry publish failed: #{error.class}: #{error.message}"
87
- logger = ::Legion::Extensions::Llm.logger if defined?(::Legion::Extensions::Llm)
88
- if logger.respond_to?(level)
89
- logger.public_send(level, message)
90
- elsif logger.respond_to?(:debug)
91
- logger.debug(message)
92
- end
93
- rescue StandardError
94
- nil
95
- end
96
90
  end
97
91
  end
98
92
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module Ollama
7
- VERSION = '0.1.5'
7
+ VERSION = '0.1.6'
8
8
  end
9
9
  end
10
10
  end
@@ -12,6 +12,7 @@ module Legion
12
12
  # Ollama provider extension namespace.
13
13
  module Ollama
14
14
  extend ::Legion::Extensions::Core if ::Legion::Extensions.const_defined?(:Core, false)
15
+ extend Legion::Logging::Helper
15
16
 
16
17
  PROVIDER_FAMILY = :ollama
17
18
 
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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO