Class: RubyLlmMesh::Providers::LocalNode
- Defined in:
- lib/ruby_llm_mesh/providers/local_node.rb
Overview
OpenAI-compatible local runtime (Ollama, LM Studio, vLLM, llama.cpp server, etc.). When peer discovery is enabled, tries healthy peers from Mesh::PeerRegistry.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from RubyLlmMesh::Providers::Base
Instance Method Details
#complete(prompt:, system: nil, model: nil, **options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby_llm_mesh/providers/local_node.rb', line 12 def complete(prompt:, system: nil, model: nil, **) model ||= config.local_node_model = [] << { role: "system", content: system } if system << { role: "user", content: prompt } body = { model: model, messages: , stream: false, temperature: .fetch(:temperature, 0.7) } body[:options] = { num_predict: [:max_tokens] } if [:max_tokens] errors = [] peer_bases.each do |base_url| begin return complete_against(base_url, model: model, body: body, messages: ) rescue RateLimitError, TimeoutError, ProviderError => e registry.mark_unhealthy(base_url, error: e.) errors << e next end end raise errors.last || ProviderError.new("No healthy local peers available", provider: name) end |
#name ⇒ Object
8 9 10 |
# File 'lib/ruby_llm_mesh/providers/local_node.rb', line 8 def name :local_node end |