class Ollama::Handlers::Single

ollama.generate(model: ‘llama3.1’, prompt: ‘Hello World’, &Single)
@example Using the Single handler to collect a single response
collected.
one is present, or the complete array of responses when multiple are
execution and provides a result that is either the single response when only
The Single handler is designed to accumulate responses during command
array of responses.
A handler that collects responses and returns either a single response or an

def call(response)

Returns:
  • (self) - returns the handler instance itself after processing the response

Parameters:
  • response (Ollama::Response) -- the response object to be processed and stored
def call(response)
  @array << response
  self
end

def initialize(output: $stdout)

Parameters:
  • output (IO) -- the output stream to be used for handling responses,
def initialize(output: $stdout)
  super
  @array = []
end

def result

Returns:
  • (Ollama::Response, Array, nil) - the collected response data,
def result
  @array.size <= 1 ? @array.first : @array
end