Class: Ollama::Client
- Inherits:
-
Object
- Object
- Ollama::Client
- Includes:
- Chat, Generate, ModelManagement
- Defined in:
- lib/ollama/client.rb,
lib/ollama/client/chat.rb,
lib/ollama/client/generate.rb,
lib/ollama/client/model_management.rb,
lib/ollama/client/chat_stream_processor.rb
Overview
Main client class for interacting with the Ollama API.
Provides methods for all 12 Ollama API endpoints, organized into modules:
-
Chat: multi-turn conversations with tool support
-
Generate: prompt-to-completion with structured output
-
ModelManagement: CRUD, pull/push, list, show, version
Defined Under Namespace
Modules: Chat, Generate, ModelManagement Classes: ChatStreamProcessor
Instance Attribute Summary collapse
-
#embeddings ⇒ Object
readonly
Returns the value of attribute embeddings.
Instance Method Summary collapse
-
#history_sanitizer(model_name_or_profile, trace_store: nil) ⇒ Ollama::HistorySanitizer
Build a history sanitizer appropriate for a model profile.
-
#initialize(config: nil) ⇒ Client
constructor
A new instance of Client.
-
#profile(model_name) ⇒ Ollama::ModelProfile
Return the capability profile for a model name.
Methods included from ModelManagement
#copy_model, #create_model, #delete_model, #list_model_names, #list_models, #list_running, #pull, #push_model, #show_model, #version
Methods included from Generate
Methods included from Chat
Constructor Details
#initialize(config: nil) ⇒ Client
Returns a new instance of Client.
35 36 37 38 39 |
# File 'lib/ollama/client.rb', line 35 def initialize(config: nil) @config = config || default_config @base_uri = URI(@config.base_url) @embeddings = Embeddings.new(@config) end |
Instance Attribute Details
#embeddings ⇒ Object (readonly)
Returns the value of attribute embeddings.
33 34 35 |
# File 'lib/ollama/client.rb', line 33 def @embeddings end |
Instance Method Details
#history_sanitizer(model_name_or_profile, trace_store: nil) ⇒ Ollama::HistorySanitizer
Build a history sanitizer appropriate for a model profile. Convenience method for multi-turn agent loops.
56 57 58 59 |
# File 'lib/ollama/client.rb', line 56 def history_sanitizer(model_name_or_profile, trace_store: nil) p = model_name_or_profile.is_a?(ModelProfile) ? model_name_or_profile : profile(model_name_or_profile) HistorySanitizer.for(p, trace_store: trace_store) end |
#profile(model_name) ⇒ Ollama::ModelProfile
Return the capability profile for a model name. Profiles drive prompt adaptation, streaming event routing, and defaults.
46 47 48 |
# File 'lib/ollama/client.rb', line 46 def profile(model_name) ModelProfile.for(model_name) end |