Class: Ollama::Commands::Copy
- Inherits:
- 
      Object
      
        - Object
- Ollama::Commands::Copy
 
- Includes:
- DTO
- Defined in:
- lib/ollama/commands/copy.rb
Overview
A command class that represents the copy API endpoint for Ollama.
This class is used to interact with the Ollama API’s copy endpoint, which creates a copy of an existing model with a new name. It inherits from the base command structure and provides the necessary functionality to execute copy requests for model duplication.
Instance Attribute Summary collapse
- 
  
    
      #client  ⇒ Object 
    
    
  
  
  
  
    
    
      writeonly
    
  
  
  
  
  
  
    The client attribute writer allows setting the client instance associated with the object. 
- 
  
    
      #destination  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The destination attribute reader returns the destination model name associated with the object. 
- 
  
    
      #source  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The source attribute reader returns the source model name associated with the object. 
- 
  
    
      #stream  ⇒ 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 copy requests. 
Instance Method Summary collapse
- 
  
    
      #initialize(source:, destination:)  ⇒ Copy 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    The initialize method sets up a new instance with streaming disabled. 
- 
  
    
      #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(source:, destination:) ⇒ Copy
The initialize method sets up a new instance with streaming disabled.
This method is responsible for initializing a new object instance and configuring it with the source and destination model names. It explicitly disables streaming since copy operations are typically non-streaming.
| 32 33 34 | # File 'lib/ollama/commands/copy.rb', line 32 def initialize(source:, destination:) @source, @destination, @stream = source, destination, false 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.
| 61 62 63 | # File 'lib/ollama/commands/copy.rb', line 61 def client=(value) @client = value end | 
#destination ⇒ String (readonly)
The destination attribute reader returns the destination model name associated with the object.
| 44 45 46 | # File 'lib/ollama/commands/copy.rb', line 44 def destination @destination end | 
#source ⇒ String (readonly)
The source attribute reader returns the source model name associated with the object.
| 39 40 41 | # File 'lib/ollama/commands/copy.rb', line 39 def source @source end | 
#stream ⇒ FalseClass (readonly)
The stream attribute reader returns the streaming behavior setting associated with the object.
| 51 52 53 | # File 'lib/ollama/commands/copy.rb', line 51 def stream @stream end | 
Class Method Details
.path ⇒ String
The path method returns the API endpoint path for copy requests.
This class method provides the specific URL path used to interact with the Ollama API’s copy endpoint. It is utilized internally by the command structure to determine the correct API route for duplicating models.
| 20 21 22 | # File 'lib/ollama/commands/copy.rb', line 20 def self.path '/api/copy' end | 
Instance Method Details
#perform(handler) ⇒ self
The perform method executes a command request using the specified handler.
This method initiates a POST request to the Ollama API’s copy endpoint, utilizing the client instance to send the request and process responses through the provided handler. It handles non-streaming scenarios since copy commands do not support streaming.
responses
| 74 75 76 | # File 'lib/ollama/commands/copy.rb', line 74 def perform(handler) @client.request(method: :post, path: self.class.path, body: to_json, stream:, handler:) end |