testutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectEvents

func CollectEvents(stream iter.Seq2[*session.Event, error]) ([]*session.Event, error)

CollectEvents collects all event from the llm response until encountering an error. It returns all collected events and the last error.

func CollectParts

func CollectParts(stream iter.Seq2[*session.Event, error]) ([]*genai.Part, error)

CollectParts collects all parts from the llm response until encountering an error. It returns all collected parts and the last error.

func CollectTextParts

func CollectTextParts(stream iter.Seq2[*session.Event, error]) ([]string, error)

CollectTextParts collects all text parts from the llm response until encountering an error. It returns all collected text parts and the last error.

func NewGeminiTransport

func NewGeminiTransport(rrfile string) (http.RoundTripper, error)

NewGeminiTransport returns the genai.ClientConfig configured for record and replay.

Types

type MockModel

type MockModel struct {
	Requests             []*model.LLMRequest
	Responses            []*genai.Content
	StreamResponsesCount int
}

func (*MockModel) Generate

func (m *MockModel) Generate(ctx context.Context, req *model.LLMRequest) (*model.LLMResponse, error)

GenerateContent implements llm.Model.

func (*MockModel) GenerateContent

func (m *MockModel) GenerateContent(ctx context.Context, req *model.LLMRequest, stream bool) iter.Seq2[*model.LLMResponse, error]

func (*MockModel) GenerateStream

func (m *MockModel) GenerateStream(ctx context.Context, req *model.LLMRequest) iter.Seq2[*model.LLMResponse, error]

func (*MockModel) Name

func (m *MockModel) Name() string

Name implements llm.Model.

type TestAgentRunner

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

func NewTestAgentRunner

func NewTestAgentRunner(t *testing.T, agent agent.Agent) *TestAgentRunner

NewTestAgentRunner creates a new TestAgentRunner for the given agent as root initSessionState will be used to init all sessions created by this runner.

func NewTestAgentRunnerWithPluginManager

func NewTestAgentRunnerWithPluginManager(t *testing.T, agent agent.Agent, pluginConfig runner.PluginConfig) *TestAgentRunner

NewTestAgentRunner creates a new TestAgentRunner for the given agent as root initSessionState will be used to init all sessions created by this runner.

func (*TestAgentRunner) Run

func (r *TestAgentRunner) Run(t *testing.T, sessionID, newMessage string) iter.Seq2[*session.Event, error]

func (*TestAgentRunner) RunContent

func (r *TestAgentRunner) RunContent(t *testing.T, sessionID string, content *genai.Content) iter.Seq2[*session.Event, error]

func (*TestAgentRunner) RunContentWithConfig

func (r *TestAgentRunner) RunContentWithConfig(t *testing.T, sessionID string, content *genai.Content, cfg agent.RunConfig) iter.Seq2[*session.Event, error]

func (*TestAgentRunner) SetInitSessionState

func (r *TestAgentRunner) SetInitSessionState(state map[string]any)

Jump to

Keyboard shortcuts

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