Class: Ollama::Commands::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama/commands/version.rb

Overview

A command class that represents the version API endpoint for Ollama.

This class is used to interact with the Ollama API's version endpoint, which retrieves information about the Ollama server's version. It inherits from the base command structure and provides the necessary functionality to execute version requests.

Examples:

Retrieving the Ollama server version

version = ollama.version
puts version[:version] # => "0.1.0" or similar version string

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVersion

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 a default setting that disables streaming behavior. It is typically called during the object creation process to establish the initial state of the instance.



32
33
34
# File 'lib/ollama/commands/version.rb', line 32

def initialize
  @stream = 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.



51
52
53
# File 'lib/ollama/commands/version.rb', line 51

def client=(value)
  @client = value
end

#streamTrueClass, FalseClass (readonly)

The stream attribute reader returns the streaming behavior setting associated with the object.

whether streaming is enabled for the command execution

Returns:

  • (TrueClass, FalseClass)

    the streaming behavior flag, indicating



41
42
43
# File 'lib/ollama/commands/version.rb', line 41

def stream
  @stream
end

Class Method Details

.pathString

The path method returns the API endpoint path for version requests.

This class method provides the specific URL path used to interact with the Ollama API's version endpoint. It is utilized internally by the command structure to determine the correct API route for version-related operations.

requests

Returns:

  • (String)

    the API endpoint path '/api/version' for version



22
23
24
# File 'lib/ollama/commands/version.rb', line 22

def self.path
  '/api/version'
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.

Parameters:

  • handler (Ollama::Handler)

    the handler object responsible for processing API responses

Returns:

  • (self)

    returns the current instance after initiating the request



63
64
65
# File 'lib/ollama/commands/version.rb', line 63

def perform(handler)
  @client.request(method: :get, path: self.class.path, stream:, handler:)
end