class Ollama::Commands::Embeddings
embeddings = ollama.embeddings(model: ‘mxbai-embed-large’, prompt: ‘The sky is blue because of rayleigh scattering’)
@example Generating embeddings for a prompt
embedding requests for generating vector representations of text.
the base command structure and provides the necessary functionality to execute
generates embeddings for text input using a specified model. It inherits from
This class is used to interact with the Ollama API’s embeddings endpoint, which
A command class that represents the embeddings API endpoint for Ollama.
def self.path
-
(String)- the API endpoint path '/api/embeddings' for embeddings requests
def self.path '/api/embeddings' end
def initialize(model:, prompt:, options: nil, keep_alive: nil)
-
keep_alive(String, nil) -- duration to keep the model loaded in memory -
options(Ollama::Options, nil) -- optional configuration parameters for the model -
prompt(String) -- the text prompt to generate embeddings for -
model(String) -- the name of the model to use for generating embeddings
def initialize(model:, prompt:, options: nil, keep_alive: nil) @model, @prompt, @options, @keep_alive, @stream = model, prompt, options, keep_alive, false end
def perform(handler)
-
(self)- returns the current instance after initiating the request
Parameters:
-
handler(Ollama::Handler) -- the handler object responsible for processing API
def perform(handler) @client.request(method: :post, path: self.class.path, body: to_json, stream:, handler:) end