mock

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResponse = errors.New("mock llm: no response queued")

ErrNoResponse indicates the mock gateway has no queued response for a profile.

Functions

This section is empty.

Types

type FallbackGateway

type FallbackGateway struct {
	*Gateway
}

FallbackGateway wraps a mock gateway and returns a deterministic assistant reply when no queued response is available. This makes local development usable without manually seeding mock responses.

func NewFallbackGateway

func NewFallbackGateway() *FallbackGateway

NewFallbackGateway creates a mock gateway with echo-style fallbacks.

func (*FallbackGateway) Chat

func (g *FallbackGateway) Chat(ctx context.Context, profile string, req llm.ChatRequest) (llm.ChatResponse, error)

func (*FallbackGateway) ChatWithTools

func (g *FallbackGateway) ChatWithTools(ctx context.Context, profile string, req llm.ToolCallRequest) (llm.ToolCallResponse, error)

func (*FallbackGateway) StructuredChat

func (g *FallbackGateway) StructuredChat(ctx context.Context, profile string, schema json.RawMessage, req llm.ChatRequest) (json.RawMessage, error)

type Gateway

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

Gateway is a test double for llm.Gateway with queued responses.

func NewGateway

func NewGateway() *Gateway

NewGateway creates a mock LLM gateway for tests and local development.

func (*Gateway) Chat

func (g *Gateway) Chat(ctx context.Context, profile string, req llm.ChatRequest) (llm.ChatResponse, error)

Chat returns the next queued chat response for a profile.

func (*Gateway) ChatWithTools

func (g *Gateway) ChatWithTools(ctx context.Context, profile string, req llm.ToolCallRequest) (llm.ToolCallResponse, error)

ChatWithTools returns the next queued tool-call response for a profile.

func (*Gateway) Embed

func (g *Gateway) Embed(ctx context.Context, profile string, input []string) ([][]float32, error)

Embed returns the next queued embedding response for a profile.

func (*Gateway) QueueChat

func (g *Gateway) QueueChat(profile string, response llm.ChatResponse)

QueueChat appends a chat response for a profile.

func (*Gateway) QueueEmbedding

func (g *Gateway) QueueEmbedding(profile string, response [][]float32)

QueueEmbedding appends an embedding response for a profile.

func (*Gateway) QueueStructured

func (g *Gateway) QueueStructured(profile string, response json.RawMessage)

QueueStructured appends a structured response for a profile.

func (*Gateway) QueueToolCall

func (g *Gateway) QueueToolCall(profile string, response llm.ToolCallResponse)

QueueToolCall appends a tool-call response for a profile.

func (*Gateway) SetCapabilities

func (g *Gateway) SetCapabilities(profile string, caps ...llm.Capability)

SetCapabilities registers supported capabilities for a profile.

func (*Gateway) StreamChat

func (g *Gateway) StreamChat(ctx context.Context, profile string, req llm.ChatRequest) (<-chan llm.ChatChunk, error)

StreamChat streams a single chunk from the queued chat response.

func (*Gateway) StructuredChat

func (g *Gateway) StructuredChat(ctx context.Context, profile string, schema json.RawMessage, req llm.ChatRequest) (json.RawMessage, error)

StructuredChat returns the next queued structured response for a profile.

func (*Gateway) Supports

func (g *Gateway) Supports(profile string, cap llm.Capability) bool

Supports reports whether a profile supports a capability.

func (*Gateway) ToolRequests

func (g *Gateway) ToolRequests(profile string) []llm.ToolCallRequest

ToolRequests returns tool-call requests recorded for a profile.

Jump to

Keyboard shortcuts

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