fake

package
v0.36.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fake provides mock LLM implementations for testing.

Use the LLM type to create a fake model that returns predefined responses in sequence. Useful for unit tests that need predictable LLM behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLM

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

func NewFakeLLM

func NewFakeLLM(responses []string) *LLM

func (*LLM) AddResponse

func (f *LLM) AddResponse(response string)

AddResponse appends a new response to the list.

func (*LLM) Call

func (f *LLM) Call(
	ctx context.Context,
	prompt string,
	options ...llms.CallOption,
) (string, error)

Call is a simplified interface for generating responses from a string prompt.

func (*LLM) GenerateContent

func (f *LLM) GenerateContent(
	_ context.Context,
	messages []schema.MessageContent,
	_ ...llms.CallOption,
) (*schema.ContentResponse, error)

GenerateContent returns the next predefined response in the cycle.

func (*LLM) GetCallCount added in v0.2.0

func (f *LLM) GetCallCount() int

GetCallCount returns the number of times the LLM was called.

func (*LLM) LastPrompt added in v0.2.0

func (f *LLM) LastPrompt() (string, bool)

LastPrompt returns the last prompt sent to the LLM.

func (*LLM) Reset

func (f *LLM) Reset()

Reset resets the response index and call count.

Jump to

Keyboard shortcuts

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