class Ollama::Handlers::DumpJSON
ollama.generate(model: ‘llama3.1’, prompt: ‘Hello World’, &DumpJSON)
@example Using the DumpJSON handler to output response data as JSON
that supports response processing.
implements the standard handler interface and can be used with any command
making it easy to inspect the raw data returned by Ollama commands. It
This class is designed to serialize and display API responses in JSON format,
output stream.
A handler that outputs JSON representations of responses to the specified
def call(response)
-
(self)- returns the handler instance itself after processing the response
Parameters:
-
response(Ollama::Response) -- the response object to be serialized and output
def call(response) @output.puts JSON::pretty_generate(response, allow_nan: true, max_nesting: false) self end