Module: OllamaClient
- Defined in:
- lib/ollama_client.rb
Overview
Main entry point for OllamaClient gem
⚠️ THREAD SAFETY WARNING: Global configuration access is protected by mutex, but modifying global config while clients are active can cause race conditions. For concurrent agents or multi-threaded applications, prefer per-client configuration (recommended):
config = Ollama::Config.new
config.model = "llama3.1"
client = Ollama::Client.new(config: config)
Each client instance is thread-safe when using its own config.
Class Method Summary collapse
Class Method Details
.config ⇒ Object
38 39 40 41 42 |
# File 'lib/ollama_client.rb', line 38 def self.config @config_mutex.synchronize do @config ||= Ollama::Config.new end end |
.configure ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ollama_client.rb', line 44 def self.configure if Thread.current != Thread.main && !@warned_thread_config @warned_thread_config = true msg = "[ollama-client] Global OllamaClient.configure called from non-main thread. " \ "While access is mutex-protected, modifying global config concurrently can cause " \ "race conditions. Prefer per-client config: Ollama::Client.new(config: ...)" warn(msg) end @config_mutex.synchronize do @config ||= Ollama::Config.new yield(@config) end end |