mock

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider returns scripted responses in order.

func NewProvider

func NewProvider(steps ...Step) *Provider

NewProvider creates a deterministic scripted provider.

func (*Provider) Generate

Generate returns the next scripted result.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider identifier.

func (*Provider) Stream

Stream emits scripted streaming events before returning the final scripted result.

func (*Provider) WithName

func (p *Provider) WithName(name string) *Provider

WithName sets the identifier Name reports (default "mock"), so a test can tell several scripted providers apart, e.g. in a fallback pool.

type Step

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

Step is a deterministic provider script step.

func Error

func Error(err error) Step

Error scripts a provider failure.

func Final

func Final(content string) Step

Final scripts a final model response.

func Stream

func Stream(step Step, events ...api.StreamEvent) Step

Stream attaches streaming events to a scripted step.

func ToolCall

func ToolCall(callID, name string, arguments map[string]any) Step

ToolCall scripts a single tool call response.

type Tool

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

Tool is a deterministic test tool with overridable behavior.

func NewTool

func NewTool(name string, options ...ToolOption) *Tool

NewTool creates a mock tool with a default echo-style handler.

func (*Tool) Description

func (t *Tool) Description() string

Description returns the tool description.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, call api.ToolCall) (*api.ToolResult, error)

Execute runs the configured handler or a default echo-style result.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the dispatch name.

func (*Tool) Schema

func (t *Tool) Schema() api.ToolSchema

Schema returns a stable, provider-neutral tool schema.

type ToolOption

type ToolOption func(*Tool)

ToolOption customizes the default mock tool.

func WithDescription

func WithDescription(description string) ToolOption

WithDescription overrides the mock tool description.

func WithHandler

func WithHandler(handler func(context.Context, api.ToolCall) (*api.ToolResult, error)) ToolOption

WithHandler overrides the mock tool execution behavior.

func WithSchema

func WithSchema(schema map[string]any) ToolOption

WithSchema overrides the mock tool input schema.

Jump to

Keyboard shortcuts

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