Documentation
¶
Index ¶
- Variables
- func BenchmarkAccuracyMetric(expected, actual map[string]interface{}) float64
- func BenchmarkDatasetFromExamples(examples []core.Example) core.Dataset
- func CreateBenchmarkDatasets() map[string]BenchmarkDataset
- func CreateBenchmarkProgram(predictor core.Module) core.Program
- func LogBenchmarkResult(result BenchmarkResult)
- func StandardBenchmarkConfigs() map[string]BenchmarkConfig
- type BenchmarkConfig
- type BenchmarkDataset
- type BenchmarkMetrics
- type BenchmarkResult
- type MockCoreTool
- func (m *MockCoreTool) CanHandle(ctx context.Context, intent string) bool
- func (m *MockCoreTool) Description() string
- func (m *MockCoreTool) Execute(ctx context.Context, args map[string]interface{}) (core.ToolResult, error)
- func (m *MockCoreTool) InputSchema() models.InputSchema
- func (m *MockCoreTool) Metadata() *core.ToolMetadata
- func (m *MockCoreTool) Name() string
- func (m *MockCoreTool) Validate(params map[string]interface{}) error
- type MockDataset
- type MockLLM
- func (m *MockLLM) Capabilities() []core.Capability
- func (m *MockLLM) CreateEmbedding(ctx context.Context, input string, options ...core.EmbeddingOption) (*core.EmbeddingResult, error)
- func (m *MockLLM) CreateEmbeddings(ctx context.Context, inputs []string, options ...core.EmbeddingOption) (*core.BatchEmbeddingResult, error)
- func (m *MockLLM) Generate(ctx context.Context, prompt string, opts ...core.GenerateOption) (*core.LLMResponse, error)
- func (m *MockLLM) GenerateWithContent(ctx context.Context, content []core.ContentBlock, ...) (*core.LLMResponse, error)
- func (m *MockLLM) GenerateWithFunctions(ctx context.Context, prompt string, functions []map[string]interface{}, ...) (map[string]interface{}, error)
- func (m *MockLLM) GenerateWithJSON(ctx context.Context, prompt string, opts ...core.GenerateOption) (map[string]interface{}, error)
- func (m *MockLLM) ModelID() string
- func (m *MockLLM) ProviderName() string
- func (m *MockLLM) StreamGenerate(ctx context.Context, prompt string, opts ...core.GenerateOption) (*core.StreamResponse, error)
- func (m *MockLLM) StreamGenerateWithContent(ctx context.Context, content []core.ContentBlock, ...) (*core.StreamResponse, error)
- type MockMCPClient
- type MockModule
- func (m *MockModule) Clone() core.Module
- func (m *MockModule) GetDisplayName() string
- func (m *MockModule) GetModuleType() string
- func (m *MockModule) GetSignature() core.Signature
- func (m *MockModule) Process(ctx context.Context, inputs map[string]any, opts ...core.Option) (map[string]any, error)
- func (m *MockModule) SetLLM(llm core.LLM)
- func (m *MockModule) SetSignature(signature core.Signature)
- func (m *MockModule) UpdateInstruction(instruction string)
- type MockStreamConfig
- type MockTool
- func (m *MockTool) CanHandle(ctx context.Context, intent string) bool
- func (m *MockTool) Description() string
- func (m *MockTool) Execute(ctx context.Context, params map[string]interface{}) (core.ToolResult, error)
- func (m *MockTool) InputSchema() models.InputSchema
- func (m *MockTool) Metadata() *core.ToolMetadata
- func (m *MockTool) Name() string
- func (m *MockTool) Validate(params map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ConcurrencyTestMu sync.Mutex
ConcurrencyTestMu protects concurrent access to global concurrency settings during benchmark tests to prevent race conditions.
Functions ¶
func BenchmarkAccuracyMetric ¶ added in v0.41.0
BenchmarkAccuracyMetric provides a standard accuracy metric for benchmarking.
func BenchmarkDatasetFromExamples ¶ added in v0.41.0
BenchmarkDatasetFromExamples converts examples to a dataset interface.
func CreateBenchmarkDatasets ¶ added in v0.41.0
func CreateBenchmarkDatasets() map[string]BenchmarkDataset
CreateBenchmarkDatasets creates standardized datasets for benchmarking optimizers.
func CreateBenchmarkProgram ¶ added in v0.41.0
CreateBenchmarkProgram creates a standard program for benchmarking optimizers. The predictor parameter should be a modules.Predict instance to avoid import cycles.
func LogBenchmarkResult ¶ added in v0.41.0
func LogBenchmarkResult(result BenchmarkResult)
LogBenchmarkResult logs benchmark results in a structured format.
func StandardBenchmarkConfigs ¶ added in v0.41.0
func StandardBenchmarkConfigs() map[string]BenchmarkConfig
StandardBenchmarkConfigs provides predefined benchmark configurations.
Types ¶
type BenchmarkConfig ¶ added in v0.41.0
type BenchmarkConfig struct {
DatasetSize int
Breadth int
Depth int
MaxSteps int
BatchSize int
NumTrials int
Temperature float64
Timeout int // seconds
}
BenchmarkConfig represents common benchmark configuration.
type BenchmarkDataset ¶ added in v0.41.0
BenchmarkDataset represents different dataset sizes for benchmarking.
type BenchmarkMetrics ¶ added in v0.41.0
type BenchmarkMetrics struct {
CompilationTime float64
AverageScore float64
TotalExamples int
TokensUsed int
}
BenchmarkMetrics tracks performance metrics during benchmarking.
type BenchmarkResult ¶ added in v0.41.0
type BenchmarkResult struct {
OptimizerName string
Config BenchmarkConfig
CompilationTime float64 // seconds
AverageScore float64
TotalExamples int
Success bool
Error string
}
BenchmarkResult captures the results of a benchmark run.
type MockCoreTool ¶ added in v0.27.0
type MockCoreTool struct {
// contains filtered or unexported fields
}
Copied from pkg/tools/registry_test.go.
func NewMockCoreTool ¶ added in v0.27.0
func NewMockCoreTool(name, description string, executeFunc func(ctx context.Context, args map[string]interface{}) (core.ToolResult, error)) *MockCoreTool
NewMockCoreTool creates a new MockCoreTool instance.
func (*MockCoreTool) CanHandle ¶ added in v0.27.0
func (m *MockCoreTool) CanHandle(ctx context.Context, intent string) bool
func (*MockCoreTool) Description ¶ added in v0.27.0
func (m *MockCoreTool) Description() string
func (*MockCoreTool) Execute ¶ added in v0.27.0
func (m *MockCoreTool) Execute(ctx context.Context, args map[string]interface{}) (core.ToolResult, error)
func (*MockCoreTool) InputSchema ¶ added in v0.27.0
func (m *MockCoreTool) InputSchema() models.InputSchema
func (*MockCoreTool) Metadata ¶ added in v0.27.0
func (m *MockCoreTool) Metadata() *core.ToolMetadata
func (*MockCoreTool) Name ¶ added in v0.27.0
func (m *MockCoreTool) Name() string
func (*MockCoreTool) Validate ¶ added in v0.27.0
func (m *MockCoreTool) Validate(params map[string]interface{}) error
type MockDataset ¶
type MockDataset struct {
mock.Mock
Examples []core.Example
Index int
// contains filtered or unexported fields
}
MockDataset is a mock implementation of core.Dataset.
func NewMockDataset ¶
func NewMockDataset(examples []core.Example) *MockDataset
NewMockDataset creates a new MockDataset with the given examples.
type MockLLM ¶
MockLLM is a mock implementation of core.LLM.
func (*MockLLM) Capabilities ¶ added in v0.14.0
func (m *MockLLM) Capabilities() []core.Capability
func (*MockLLM) CreateEmbedding ¶ added in v0.16.1
func (m *MockLLM) CreateEmbedding(ctx context.Context, input string, options ...core.EmbeddingOption) (*core.EmbeddingResult, error)
CreateEmbedding mocks the single embedding creation following the same pattern as Generate.
func (*MockLLM) CreateEmbeddings ¶ added in v0.16.1
func (m *MockLLM) CreateEmbeddings(ctx context.Context, inputs []string, options ...core.EmbeddingOption) (*core.BatchEmbeddingResult, error)
CreateEmbeddings mocks the batch embedding creation.
func (*MockLLM) Generate ¶
func (m *MockLLM) Generate(ctx context.Context, prompt string, opts ...core.GenerateOption) (*core.LLMResponse, error)
func (*MockLLM) GenerateWithContent ¶ added in v0.38.0
func (m *MockLLM) GenerateWithContent(ctx context.Context, content []core.ContentBlock, options ...core.GenerateOption) (*core.LLMResponse, error)
func (*MockLLM) GenerateWithFunctions ¶ added in v0.20.0
func (*MockLLM) GenerateWithJSON ¶
func (*MockLLM) ModelID ¶ added in v0.14.0
ModelID mocks the GetModelID method from the LLM interface.
func (*MockLLM) ProviderName ¶ added in v0.14.0
GetProviderName mocks the GetProviderName method from the LLM interface.
func (*MockLLM) StreamGenerate ¶ added in v0.23.0
func (m *MockLLM) StreamGenerate(ctx context.Context, prompt string, opts ...core.GenerateOption) (*core.StreamResponse, error)
func (*MockLLM) StreamGenerateWithContent ¶ added in v0.38.0
func (m *MockLLM) StreamGenerateWithContent(ctx context.Context, content []core.ContentBlock, options ...core.GenerateOption) (*core.StreamResponse, error)
type MockMCPClient ¶ added in v0.27.0
type MockMCPClient struct {
ListToolsFunc func(ctx context.Context, cursor *models.Cursor) (*models.ListToolsResult, error)
// Corrected CallToolFunc signature again to match MCPClientInterface
CallToolFunc func(ctx context.Context, toolName string, arguments map[string]interface{}) (*models.CallToolResult, error)
}
MockMCPClient provides a mock implementation of the MCPClient interface (or relevant parts).
func NewMockMCPClientWithTools ¶ added in v0.27.0
func NewMockMCPClientWithTools() *MockMCPClient
NewMockMCPClientWithTools creates a MockMCPClient pre-configured with standard mock tools.
func (*MockMCPClient) CallTool ¶ added in v0.27.0
func (m *MockMCPClient) CallTool(ctx context.Context, toolName string, arguments map[string]interface{}) (*models.CallToolResult, error)
Corrected CallTool signature again to match MCPClientInterface.
func (*MockMCPClient) ListTools ¶ added in v0.27.0
func (m *MockMCPClient) ListTools(ctx context.Context, cursor *models.Cursor) (*models.ListToolsResult, error)
ListTools calls the underlying ListToolsFunc.
type MockModule ¶ added in v0.46.0
MockModule is a mock implementation of core.Module.
func NewMockModule ¶ added in v0.46.0
func NewMockModule(instruction string) *MockModule
NewMockModule creates a new MockModule with the given instruction.
func (*MockModule) Clone ¶ added in v0.46.0
func (m *MockModule) Clone() core.Module
func (*MockModule) GetDisplayName ¶ added in v0.46.0
func (m *MockModule) GetDisplayName() string
func (*MockModule) GetModuleType ¶ added in v0.46.0
func (m *MockModule) GetModuleType() string
func (*MockModule) GetSignature ¶ added in v0.46.0
func (m *MockModule) GetSignature() core.Signature
func (*MockModule) SetLLM ¶ added in v0.46.0
func (m *MockModule) SetLLM(llm core.LLM)
func (*MockModule) SetSignature ¶ added in v0.46.0
func (m *MockModule) SetSignature(signature core.Signature)
func (*MockModule) UpdateInstruction ¶ added in v0.46.0
func (m *MockModule) UpdateInstruction(instruction string)
type MockStreamConfig ¶ added in v0.23.0
type MockStreamConfig struct {
Content string
ChunkSize int
ChunkDelay time.Duration
Error error
ErrorAfter int
TokenCounts *core.TokenInfo
ShouldCancel bool
mock.Mock
}
MockStreamConfig configures how the mock LLM will stream responses during tests.
type MockTool ¶ added in v0.18.0
func NewMockTool ¶ added in v0.18.0
NewMockTool creates a new mock tool with default metadata.
func (*MockTool) Description ¶ added in v0.24.0
func (*MockTool) Execute ¶ added in v0.18.0
func (m *MockTool) Execute(ctx context.Context, params map[string]interface{}) (core.ToolResult, error)
Execute implements the Tool interface.
func (*MockTool) InputSchema ¶ added in v0.24.0
func (m *MockTool) InputSchema() models.InputSchema
func (*MockTool) Metadata ¶ added in v0.18.0
func (m *MockTool) Metadata() *core.ToolMetadata
Metadata implements the Tool interface.