answer

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package answer provides answer generation utilities for RAG systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

generator implements Generator interface.

func New

func New(llm chat.Client, opts ...Option) *Generator

New creates a new generator.

Required: llm. Optional (via options): WithPromptTemplate, WithLogger, WithCollector.

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context, query *core.Query, chunks []*core.Chunk) (*core.Result, error)

Generate generates an answer based on query and retrieved context.

func (*Generator) GenerateHypotheticalDocument

func (g *Generator) GenerateHypotheticalDocument(ctx context.Context, query *core.Query) (string, error)

GenerateHypotheticalDocument generates a hypothetical document for HyDE.

type Option

type Option func(*Generator)

Option configures a Generator instance.

func WithCollector

func WithCollector(collector observability.Collector) Option

WithCollector sets an observability collector.

func WithLogger

func WithLogger(logger logging.Logger) Option

WithLogger sets a structured logger.

func WithPromptTemplate

func WithPromptTemplate(tmpl string) Option

WithPromptTemplate overrides the default generation prompt.

Jump to

Keyboard shortcuts

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