output

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteAskResult added in v0.8.0

func WriteAskResult(w io.Writer, answer string, results []search.Result, collections []config.Collection, format string) error

WriteAskResult writes a generated answer and compact, deduplicated sources.

func WriteAskSources added in v0.8.0

func WriteAskSources(w io.Writer, sources []AskSource) error

WriteAskSources writes compact source rows.

func WriteAskSourcesMarkdown added in v0.8.0

func WriteAskSourcesMarkdown(w io.Writer, sources []AskSource) error

WriteAskSourcesMarkdown writes compact source rows as Markdown.

Types

type AskOutput added in v0.8.0

type AskOutput struct {
	Answer  string      `json:"answer"`
	Sources []AskSource `json:"sources"`
}

AskOutput is the structured JSON shape for qi ask.

type AskSource added in v0.8.0

type AskSource struct {
	Index        int    `json:"index"`
	Indices      []int  `json:"indices"`
	Title        string `json:"title"`
	Path         string `json:"path"`
	Collection   string `json:"collection"`
	RelativePath string `json:"relative_path"`
}

AskSource is a compact source reference for generated answers.

func CompactAskSources added in v0.8.0

func CompactAskSources(results []search.Result, collections []config.Collection) []AskSource

CompactAskSources converts chunk-level search hits into document-level source rows.

type Formatter

type Formatter interface {
	WriteResults(w io.Writer, results []search.Result) error
}

Formatter writes search results to a writer.

func New

func New(format string) Formatter

New returns the formatter for the given format string.

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter writes results as a JSON array.

func (*JSONFormatter) WriteResults

func (f *JSONFormatter) WriteResults(w io.Writer, results []search.Result) error

type MarkdownFormatter

type MarkdownFormatter struct{}

MarkdownFormatter writes results as a Markdown list.

func (*MarkdownFormatter) WriteResults

func (f *MarkdownFormatter) WriteResults(w io.Writer, results []search.Result) error

type TextFormatter

type TextFormatter struct{}

TextFormatter writes human-readable results.

func (*TextFormatter) WriteResults

func (f *TextFormatter) WriteResults(w io.Writer, results []search.Result) error

Jump to

Keyboard shortcuts

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