fakes

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package fakes provides deterministic test doubles for GoLangGraph's external dependencies.

The doubles stand in for a language model only. Everything else in a test using them — the graph engine, the agent loop, tool execution, state handling, the HTTP server — is the real implementation, so the tests exercise the framework rather than a mock of it.

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 is a scriptable llm.Provider.

Replies are returned in order and the last one repeats, so a test can script an agent's reasoning turn by turn without depending on a live model.

func NewProvider

func NewProvider(name, reply string) *Provider

NewProvider creates a provider that always answers with reply.

func (*Provider) Calls

func (p *Provider) Calls() int

Calls returns how many completions have been requested.

func (*Provider) Close

func (p *Provider) Close() error

func (*Provider) Complete

func (*Provider) CompleteStream

func (p *Provider) CompleteStream(ctx context.Context, req llm.CompletionRequest, callback llm.StreamCallback) error

func (*Provider) CompleteStreamWithMode

func (p *Provider) CompleteStreamWithMode(ctx context.Context, req llm.CompletionRequest, callback llm.StreamCallback, mode llm.StreamMode) error

func (*Provider) CompleteWithMode

func (p *Provider) CompleteWithMode(ctx context.Context, req llm.CompletionRequest, mode llm.StreamMode) (*llm.CompletionResponse, error)

func (*Provider) FailWith

func (p *Provider) FailWith(errs ...error) *Provider

FailWith makes the next calls fail with the given errors, in order. A nil entry means that call succeeds.

func (*Provider) GetConfig

func (p *Provider) GetConfig() map[string]interface{}

func (*Provider) GetModels

func (p *Provider) GetModels(ctx context.Context) ([]string, error)

func (*Provider) GetName

func (p *Provider) GetName() string

func (*Provider) GetStreamingConfig

func (p *Provider) GetStreamingConfig() *llm.StreamingConfig

func (*Provider) IsHealthy

func (p *Provider) IsHealthy(ctx context.Context) error

func (*Provider) Prompts

func (p *Provider) Prompts() []string

Prompts returns the content of every user message the provider has received, so a test can assert what the agent actually asked.

func (*Provider) Script

func (p *Provider) Script(replies ...string) *Provider

Script sets the replies returned by successive calls. The final reply repeats once the script is exhausted.

func (*Provider) SetConfig

func (p *Provider) SetConfig(config map[string]interface{}) error

func (*Provider) SetHealthy

func (p *Provider) SetHealthy(healthy bool) *Provider

SetHealthy controls what IsHealthy reports.

func (*Provider) SetStreamingConfig

func (p *Provider) SetStreamingConfig(c *llm.StreamingConfig) error

func (*Provider) SupportsStreaming

func (p *Provider) SupportsStreaming() bool

func (*Provider) WithDelay

func (p *Provider) WithDelay(d time.Duration) *Provider

WithDelay makes every call take at least d, respecting cancellation.

Jump to

Keyboard shortcuts

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