Class: Ollama::Commands::Pull
- Inherits:
- 
      Object
      
        - Object
- Ollama::Commands::Pull
 
- Includes:
- DTO
- Defined in:
- lib/ollama/commands/pull.rb
Overview
Create Command name, if stream was true, set stream_handler
The command method creates a command method for the Ollama client
Defines a new command method that corresponds to an Ollama API endpoint. The command method can be invoked with parameters and an optional handler to process responses. It determines which handler to use based on whether the command supports streaming and the presence of an explicit handler.
as default, otherwise default_handler.
Instance Attribute Summary collapse
- 
  
    
      #client  ⇒ Object 
    
    
  
  
  
  
    
    
      writeonly
    
  
  
  
  
  
  
    The client attribute writer allows setting the client instance associated with the object. 
- 
  
    
      #insecure  ⇒ TrueClass, ... 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The insecure attribute reader returns the insecure connection setting associated with the object. 
- 
  
    
      #model  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The model attribute reader returns the model name associated with the object. 
- 
  
    
      #stream  ⇒ TrueClass, FalseClass 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The stream attribute reader returns the streaming behavior setting associated with the object. 
Class Method Summary collapse
- 
  
    
      .path  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    The path method returns the API endpoint path for pull requests. 
Instance Method Summary collapse
- 
  
    
      #initialize(model:, insecure: nil, stream: true)  ⇒ Pull 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    The initialize method sets up a new instance with streaming enabled by default. 
- 
  
    
      #perform(handler)  ⇒ self 
    
    
  
  
  
  
  
  
  
  
  
    The perform method executes a command request using the specified handler. 
Methods included from DTO
#==, #as_array, #as_array_of_hashes, #as_hash, #as_json, #empty?, #to_json
Constructor Details
#initialize(model:, insecure: nil, stream: true) ⇒ Pull
The initialize method sets up a new instance with streaming enabled by default.
This method is responsible for initializing a new object instance and configuring it with a default setting that enables streaming behavior. It is typically called during the object creation process to establish the initial state of the instance.
| 43 44 45 | # File 'lib/ollama/commands/pull.rb', line 43 def initialize(model:, insecure: nil, stream: true) @model, @insecure, @stream = model, insecure, stream end | 
Instance Attribute Details
#client=(value) ⇒ Object (writeonly)
The client attribute writer allows setting the client instance associated with the object.
This method assigns the client that will be used to perform requests and handle responses for this command. It is typically called internally when a command is executed through a client instance.
| 74 75 76 | # File 'lib/ollama/commands/pull.rb', line 74 def client=(value) @client = value end | 
#insecure ⇒ TrueClass, ... (readonly)
The insecure attribute reader returns the insecure connection setting associated with the object.
| 57 58 59 | # File 'lib/ollama/commands/pull.rb', line 57 def insecure @insecure end | 
#model ⇒ String (readonly)
The model attribute reader returns the model name associated with the object.
| 50 51 52 | # File 'lib/ollama/commands/pull.rb', line 50 def model @model end | 
#stream ⇒ TrueClass, FalseClass (readonly)
The stream attribute reader returns the streaming behavior setting associated with the object.
| 64 65 66 | # File 'lib/ollama/commands/pull.rb', line 64 def stream @stream end | 
Class Method Details
.path ⇒ String
The path method returns the API endpoint path for pull requests.
This class method provides the specific URL path used to interact with the Ollama API’s pull endpoint. It is utilized internally by the command structure to determine the correct API route for downloading models from a remote registry.
| 27 28 29 | # File 'lib/ollama/commands/pull.rb', line 27 def self.path '/api/pull' end | 
Instance Method Details
#perform(handler) ⇒ self
The perform method executes a command request using the specified handler.
This method initiates a request to the Ollama API endpoint associated with the command, utilizing the client instance to send the request and process responses through the provided handler. It handles both streaming and non-streaming scenarios based on the command’s configuration.
responses
| 87 88 89 | # File 'lib/ollama/commands/pull.rb', line 87 def perform(handler) @client.request(method: :post, path: self.class.path, body: to_json, stream:, handler:) end |