Class: Ollama::Commands::Embed

Inherits:
Object
  • Object
show all
Includes:
DTO
Defined in:
lib/ollama/commands/embed.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DTO

#as_array_of_hashes, #as_json, #empty?, #to_json

Constructor Details

#initialize(model:, input:, options: nil, truncate: nil, keep_alive: nil) ⇒ Embed

Returns a new instance of Embed.



8
9
10
11
12
# File 'lib/ollama/commands/embed.rb', line 8

def initialize(model:, input:, options: nil, truncate: nil, keep_alive: nil)
  @model, @input, @options, @truncate, @keep_alive =
    model, input, options, truncate, keep_alive
  @stream = false
end

Instance Attribute Details

#client=(value) ⇒ Object (writeonly)

Sets the attribute client

Parameters:

  • value

    the value to set the attribute client to.



16
17
18
# File 'lib/ollama/commands/embed.rb', line 16

def client=(value)
  @client = value
end

#inputObject (readonly)

Returns the value of attribute input.



14
15
16
# File 'lib/ollama/commands/embed.rb', line 14

def input
  @input
end

#keep_aliveObject (readonly)

Returns the value of attribute keep_alive.



14
15
16
# File 'lib/ollama/commands/embed.rb', line 14

def keep_alive
  @keep_alive
end

#modelObject (readonly)

Returns the value of attribute model.



14
15
16
# File 'lib/ollama/commands/embed.rb', line 14

def model
  @model
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/ollama/commands/embed.rb', line 14

def options
  @options
end

#streamObject (readonly)

Returns the value of attribute stream.



14
15
16
# File 'lib/ollama/commands/embed.rb', line 14

def stream
  @stream
end

#truncateObject (readonly)

Returns the value of attribute truncate.



14
15
16
# File 'lib/ollama/commands/embed.rb', line 14

def truncate
  @truncate
end

Class Method Details

.pathObject



4
5
6
# File 'lib/ollama/commands/embed.rb', line 4

def self.path
  '/api/embed'
end

Instance Method Details

#perform(handler) ⇒ Object



18
19
20
# File 'lib/ollama/commands/embed.rb', line 18

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