provider

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 4 Imported by: 10

Documentation

Index

Constants

View Source
const (
	ErrBadRequest = faults.Type("bad request")
	ErrServiceIO  = faults.Type("service IO error")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder[B any] interface {
	Decode(B) (*chatter.Reply, error)
}

LLM response decoder.

type Encoder

type Encoder[A any] interface {
	WithInferrer(Inferrer)
	WithCommand(chatter.Cmd)

	AsStratum(chatter.Stratum) error
	AsText(chatter.Text) error
	AsPrompt(*chatter.Prompt) error
	AsAnswer(*chatter.Answer) error
	AsReply(*chatter.Reply) error

	Build() A
}

LLM request encoder.

type Factory

type Factory[A any] func() (Encoder[A], error)

Encoder Factory is a function that creates an instance of LLM request.

type Inferrer

type Inferrer struct {
	Temperature   float64
	TopP          float64
	TopK          float64
	MaxTokens     int
	StopSequences []string
}

Inferrer is a set of parameters that influence the LLM's inference behavior.

type Provider

type Provider[A, B any] struct {
	// contains filtered or unexported fields
}

Provider is a generic implementation of Chatter interface.

func New

func New[A, B any](
	factory Factory[A],
	decoder Decoder[B],
	service Service[A, B],
) *Provider[A, B]

func (*Provider[A, B]) Prompt

func (p *Provider[A, B]) Prompt(ctx context.Context, prompt []chatter.Message, opts ...chatter.Opt) (*chatter.Reply, error)

func (*Provider[A, B]) Usage

func (p *Provider[A, B]) Usage() chatter.Usage

type Service

type Service[A, B any] interface {
	Invoke(context.Context, A) (B, error)
}

Service is a generic I/O for LLMs provider.

Jump to

Keyboard shortcuts

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