Class: Ollama::Handlers::DumpYAML

Inherits:
Object
  • Object
show all
Includes:
Concern
Defined in:
lib/ollama/handlers/dump_yaml.rb

Overview

A handler that outputs YAML representations of responses to the specified output stream.

This class is designed to serialize and display API responses in YAML format, making it easy to inspect the raw data returned by Ollama commands. It implements the standard handler interface and can be used with any command that supports response processing.

Examples:

Using the DumpYAML handler to output response data as YAML

ollama.generate(model: 'llama3.1', prompt: 'Hello World', &DumpYAML)

Instance Attribute Summary

Attributes included from Concern

#output, #result

Instance Method Summary collapse

Methods included from Concern

#initialize, #to_proc

Instance Method Details

#call(response) ⇒ self

The call method processes a response by outputting its YAML representation.

This method takes a response object and serializes it into YAML format, writing the result to the configured output stream. It is designed to handle API responses that need to be displayed or logged in a structured YAML format for debugging or inspection purposes.

and output

response

Parameters:

Returns:

  • (self)

    returns the handler instance itself after processing the



26
27
28
29
# File 'lib/ollama/handlers/dump_yaml.rb', line 26

def call(response)
  @output.puts Psych.dump(response)
  self
end