Help us shape the future of Go! Take the 2026 Go Developer Survey

modelcall

package
v0.2.7 Latest Latest
Warning

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

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

Documentation

Overview

Package modelcall makes one logical model call: iteration timeout, streaming with an idle-chunk watchdog, and retries on transient failure.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyResponse = errors.New("steerloop: empty LLM response")

ErrEmptyResponse marks a reply with no text and no tool call, so a classifier can recognise it with errors.Is.

Functions

This section is empty.

Types

type Caller

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

func New

func New(timing Timing, temperature TemperatureSource, options OptionsBuilder, classifier ErrorClassifier, logger *slog.Logger, usage UsageRecorder) *Caller

func (*Caller) Call

func (c *Caller) Call(runCtx context.Context, m model.ToolCallingChatModel, msgs []*schema.Message, extra ...model.Option) (*schema.Message, error)

Call returns a complete assistant message or an error. It retries transient failures with a short backoff. It does not change msgs.

type ErrorClassifier

type ErrorClassifier interface {
	IsTransient(err error) bool
}

ErrorClassifier decides whether a failed call is worth retrying. → the caller's loop.ErrorClassifier, or defaults.Classifier

type OptionsBuilder

type OptionsBuilder interface {
	Build(temperature float32) []model.Option
}

OptionsBuilder builds the per-call model options. → the caller's loop.CallOptionsBuilder, or defaults.TemperatureOnly

type TemperatureSource

type TemperatureSource interface {
	Temperature() float64
}

TemperatureSource gives the temperature for the next call. → state.Run

type Timing

type Timing struct {
	IterationTimeout         time.Duration // zero: no per-call bound
	DecoupleIterationTimeout bool          // a call gets the full IterationTimeout even near the run's deadline
	IdleChunkTimeout         time.Duration
	RetryAttempts            int // extra attempts after a transient failure
	Streaming                bool
}

Timing is how long calls may take and how often they are retried.

type UsageRecorder

type UsageRecorder interface {
	AddUsage(msg *schema.Message)
}

add after TemperatureSource UsageRecorder records the tokens each call spent. → state.Run

Jump to

Keyboard shortcuts

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