Module: Legion::LLM::Discovery
- Extended by:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/discovery.rb,
lib/legion/llm/discovery/ollama.rb,
lib/legion/llm/discovery/system.rb
Defined Under Namespace
Class Attribute Summary collapse
-
.embedding_fallback_chain ⇒ Object
readonly
Returns the value of attribute embedding_fallback_chain.
-
.embedding_model ⇒ Object
readonly
Returns the value of attribute embedding_model.
-
.embedding_provider ⇒ Object
readonly
Returns the value of attribute embedding_provider.
Class Method Summary collapse
Class Attribute Details
.embedding_fallback_chain ⇒ Object (readonly)
Returns the value of attribute embedding_fallback_chain.
18 19 20 |
# File 'lib/legion/llm/discovery.rb', line 18 def @embedding_fallback_chain end |
.embedding_model ⇒ Object (readonly)
Returns the value of attribute embedding_model.
18 19 20 |
# File 'lib/legion/llm/discovery.rb', line 18 def @embedding_model end |
.embedding_provider ⇒ Object (readonly)
Returns the value of attribute embedding_provider.
18 19 20 |
# File 'lib/legion/llm/discovery.rb', line 18 def @embedding_provider end |
Class Method Details
.can_embed? ⇒ Boolean
20 21 22 |
# File 'lib/legion/llm/discovery.rb', line 20 def @can_embed == true end |
.detect_embedding_capability ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/legion/llm/discovery.rb', line 39 def log.debug '[llm][discovery] detect_embedding_capability.enter' = Legion::LLM.settings[:embedding] || {} found = () if found @can_embed = true @embedding_provider = found[:provider] @embedding_model = found[:model] @embedding_fallback_chain = () log.info "[llm][discovery] embedding available provider=#{@embedding_provider} model=#{@embedding_model}" else @can_embed = false @embedding_fallback_chain = [] log.info '[llm][discovery] no embedding provider available' end rescue StandardError => e @can_embed = false @embedding_fallback_chain = [] handle_exception(e, level: :warn, operation: 'llm.discovery.detect_embedding_capability') end |
.reset! ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/legion/llm/discovery.rb', line 60 def reset! log.debug '[llm][discovery] reset' @can_embed = nil @embedding_provider = nil @embedding_model = nil @embedding_fallback_chain = nil end |
.run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/legion/llm/discovery.rb', line 24 def run log.debug '[llm][discovery] run.enter' return unless Legion::LLM.settings.dig(:providers, :ollama, :enabled) Ollama.refresh! System.refresh! names = Ollama.model_names count = names.size log.info "[llm][discovery] ollama model_count=#{count} models=#{names.join(', ')}" log.info "[llm][discovery] system total_mb=#{System.total_memory_mb} available_mb=#{System.available_memory_mb}" rescue StandardError => e handle_exception(e, level: :warn, operation: 'llm.discovery.run') end |