output

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package output provides output formatting for geminimini. Copyright 2025 Tomohiro Owada SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	WriteResponse(resp *api.GenerateResponse) error
	WriteStreamEvent(event *api.StreamEvent) error
	WriteError(err error) error
	WriteToolCall(name string, args map[string]interface{}) error
	WriteToolResult(name string, result map[string]interface{}, isError bool) error
}

Formatter is the interface for output formatters

func NewFormatter

func NewFormatter(format string, w io.Writer, errW io.Writer, sanitize bool) (Formatter, error)

NewFormatter creates a formatter for the given format

type JSONError

type JSONError struct {
	Error struct {
		Message string `json:"message"`
	} `json:"error"`
}

JSONError is the JSON error structure

type JSONFormatter

type JSONFormatter struct {
	// contains filtered or unexported fields
}

JSONFormatter outputs structured JSON (non-streaming)

func (*JSONFormatter) WriteError

func (f *JSONFormatter) WriteError(err error) error

func (*JSONFormatter) WriteResponse

func (f *JSONFormatter) WriteResponse(resp *api.GenerateResponse) error

func (*JSONFormatter) WriteStreamEvent

func (f *JSONFormatter) WriteStreamEvent(event *api.StreamEvent) error

func (*JSONFormatter) WriteToolCall

func (f *JSONFormatter) WriteToolCall(name string, args map[string]interface{}) error

func (*JSONFormatter) WriteToolResult

func (f *JSONFormatter) WriteToolResult(name string, result map[string]interface{}, isError bool) error

type JSONResponse

type JSONResponse struct {
	Model        string             `json:"model"`
	Response     string             `json:"response"`
	Usage        *api.UsageMetadata `json:"usage,omitempty"`
	FinishReason string             `json:"finishReason,omitempty"`
}

JSONResponse is the JSON output structure

type StreamJSONFormatter

type StreamJSONFormatter struct {
	// contains filtered or unexported fields
}

StreamJSONFormatter outputs NDJSON (streaming)

func (*StreamJSONFormatter) WriteError

func (f *StreamJSONFormatter) WriteError(err error) error

func (*StreamJSONFormatter) WriteResponse

func (f *StreamJSONFormatter) WriteResponse(resp *api.GenerateResponse) error

func (*StreamJSONFormatter) WriteStreamEvent

func (f *StreamJSONFormatter) WriteStreamEvent(event *api.StreamEvent) error

func (*StreamJSONFormatter) WriteToolCall

func (f *StreamJSONFormatter) WriteToolCall(name string, args map[string]interface{}) error

func (*StreamJSONFormatter) WriteToolResult

func (f *StreamJSONFormatter) WriteToolResult(name string, result map[string]interface{}, isError bool) error

type TextFormatter

type TextFormatter struct {
	// contains filtered or unexported fields
}

TextFormatter outputs plain text (streaming)

func (*TextFormatter) WriteError

func (f *TextFormatter) WriteError(err error) error

func (*TextFormatter) WriteResponse

func (f *TextFormatter) WriteResponse(resp *api.GenerateResponse) error

func (*TextFormatter) WriteStreamEvent

func (f *TextFormatter) WriteStreamEvent(event *api.StreamEvent) error

func (*TextFormatter) WriteToolCall

func (f *TextFormatter) WriteToolCall(name string, args map[string]interface{}) error

func (*TextFormatter) WriteToolResult

func (f *TextFormatter) WriteToolResult(name string, result map[string]interface{}, isError bool) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL