mock

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockTool

func NewMockTool(name, description string) ToolDefinitionInterface

func SetRunError added in v0.5.0

func SetRunError(toolDef ToolDefinitionInterface, err error)

SetRunError sets an error for a mock tool within a ToolDef

func SetRunResult added in v0.5.0

func SetRunResult(toolDef ToolDefinitionInterface, result string)

SetRunResult sets the result for a mock tool within a ToolDef

Types

type MockOpenAIClient

type MockOpenAIClient struct {
	AskResponses                  []Fragment
	AskResponseIndex              int
	CreateChatCompletionResponses []openai.ChatCompletionResponse
	CreateChatCompletionIndex     int
	AskError                      error
	CreateChatCompletionError     error
	FragmentHistory               []Fragment
}

MockOpenAIClient implements the OpenAIClient for testing

func NewMockOpenAIClient

func NewMockOpenAIClient() *MockOpenAIClient

func (*MockOpenAIClient) AddCreateChatCompletionFunction

func (m *MockOpenAIClient) AddCreateChatCompletionFunction(name, args string)

func (*MockOpenAIClient) Ask

func (m *MockOpenAIClient) Ask(ctx context.Context, f Fragment) (Fragment, error)

func (*MockOpenAIClient) CreateChatCompletion

func (*MockOpenAIClient) SetAskError

func (m *MockOpenAIClient) SetAskError(err error)

func (*MockOpenAIClient) SetAskResponse

func (m *MockOpenAIClient) SetAskResponse(content string)

Helper methods for setting up mock responses

func (*MockOpenAIClient) SetCreateChatCompletionError

func (m *MockOpenAIClient) SetCreateChatCompletionError(err error)

func (*MockOpenAIClient) SetCreateChatCompletionResponse

func (m *MockOpenAIClient) SetCreateChatCompletionResponse(response openai.ChatCompletionResponse)

type MockTool

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

MockTool implements the Tool interface for testing

func GetMockTool added in v0.5.0

func GetMockTool(toolDef ToolDefinitionInterface) *MockTool

GetMockTool extracts the MockTool from a ToolDef (if it contains one)

func (*MockTool) NewArgs added in v0.5.0

func (m *MockTool) NewArgs() *map[string]any

func (*MockTool) Run

func (m *MockTool) Run(args map[string]any) (string, any, error)

func (*MockTool) SetRunError

func (m *MockTool) SetRunError(err error)

func (*MockTool) SetRunResult

func (m *MockTool) SetRunResult(result string)

func (*MockTool) Status

func (m *MockTool) Status() *ToolStatus

Jump to

Keyboard shortcuts

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