fake

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fake provides an in-memory adapter for tests: it exercises the gateway end to end without spawning a CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// AdapterID namespaces the models; defaults to "fake".
	AdapterID string
	// Variants are the model variants to advertise.
	Variants []string
	// Reply is returned as the assistant's text, split into a few deltas.
	Reply string
	// Thinking, when set, is emitted as reasoning deltas.
	Thinking string
	// Fail, when set, is emitted instead of a completion.
	Fail *ir.Error
	// ProbeErr is returned by Probe.
	ProbeErr error
	// FirstTokenDelay is slept after the start event and before any text, as a
	// backend that is thinking does.
	FirstTokenDelay time.Duration
	// Delay is slept after the text and before the terminal event, to exercise
	// cancellation and streaming keepalives.
	Delay time.Duration
	// Silent, when set, closes the event channel without a terminal event, as a
	// CLI that dies mid-run does.
	Silent bool
	// Usage, when set, is reported on the done event.
	Usage *ir.Usage
	// Schema, when set, makes the adapter report that it can hold an answer to
	// a JSON Schema, so a frontend accepts one instead of refusing it.
	Schema bool
	// Efforts, when set, are the reasoning-effort levels this backend claims.
	Efforts []ir.Effort

	// Requests records what the gateway asked for.
	Requests []ir.Request
}

Adapter is a scripted adapter.Adapter.

func New

func New(id, reply string, variants ...string) *Adapter

New builds a fake adapter serving one variant with a fixed reply.

func (*Adapter) EffortLevels added in v0.1.5

func (a *Adapter) EffortLevels(context.Context) []ir.Effort

EffortLevels implements adapter.EffortSetter.

func (*Adapter) EnforcesSchema added in v0.1.3

func (a *Adapter) EnforcesSchema(context.Context) bool

EnforcesSchema implements adapter.SchemaEnforcer.

func (*Adapter) ID

func (a *Adapter) ID() string

ID implements adapter.Adapter.

func (*Adapter) Probe

func (a *Adapter) Probe(ctx context.Context) (adapter.Health, error)

Probe implements adapter.Adapter.

func (*Adapter) Run

func (a *Adapter) Run(ctx context.Context, req ir.Request) (<-chan ir.Event, error)

Run implements adapter.Adapter.

Jump to

Keyboard shortcuts

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