fake

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Example

Example demonstrates basic usage of the fake provider.

ctx := context.Background()
p := NewProvider()

stream, err := p.CreateStream(ctx, llm.StreamOptions{
	Model: "fake-model",
	Messages: llm.Messages{
		&llm.UserMsg{Content: "Hello!"},
	},
})
if err != nil {
	panic(err)
}

for event := range stream {
	switch event.Type {
	case llm.StreamEventDelta:
		// Handle text response
		_ = event.Delta
	case llm.StreamEventToolCall:
		// Handle tool invocation
		_ = event.ToolCall
	case llm.StreamEventDone:
		// Stream complete
		return
	case llm.StreamEventError:
		panic(event.Error)
	}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvider

func NewProvider() llm.Provider

NewProvider returns a test-only provider.

Types

type Provider

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

Provider is a test-only provider that returns a single tool call on the first request and a text-only response on subsequent requests.

func (*Provider) CreateStream

func (f *Provider) CreateStream(_ context.Context, opts llm.StreamOptions) (<-chan llm.StreamEvent, error)

func (*Provider) Models

func (f *Provider) Models() []llm.Model

func (*Provider) Name

func (f *Provider) Name() string

Jump to

Keyboard shortcuts

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