Documentation
¶
Index ¶
- type LLMClientMock
- func (mock *LLMClientMock) GenerateEmbedding(ctx context.Context, dimension int, input []string) ([][]float64, error)
- func (mock *LLMClientMock) GenerateEmbeddingCalls() []struct{ ... }
- func (mock *LLMClientMock) NewSession(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error)
- func (mock *LLMClientMock) NewSessionCalls() []struct{ ... }
- type SessionMock
- func (mock *SessionMock) AppendHistory(history *gollem.History) error
- func (mock *SessionMock) AppendHistoryCalls() []struct{ ... }
- func (mock *SessionMock) CountToken(ctx context.Context, input ...gollem.Input) (int, error)
- func (mock *SessionMock) CountTokenCalls() []struct{ ... }
- func (mock *SessionMock) Generate(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error)
- func (mock *SessionMock) GenerateCalls() []struct{ ... }
- func (mock *SessionMock) GenerateContent(ctx context.Context, input ...gollem.Input) (*gollem.Response, error)deprecated
- func (mock *SessionMock) GenerateStream(ctx context.Context, input ...gollem.Input) (<-chan *gollem.Response, error)deprecated
- func (mock *SessionMock) History() (*gollem.History, error)
- func (mock *SessionMock) HistoryCalls() []struct{}
- func (mock *SessionMock) Stream(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error)
- func (mock *SessionMock) StreamCalls() []struct{ ... }
- type StrategyMock
- func (mock *StrategyMock) Handle(ctx context.Context, state *gollem.StrategyState) ([]gollem.Input, *gollem.ExecuteResponse, error)
- func (mock *StrategyMock) HandleCalls() []struct{ ... }
- func (mock *StrategyMock) Init(ctx context.Context, inputs []gollem.Input) error
- func (mock *StrategyMock) InitCalls() []struct{ ... }
- func (mock *StrategyMock) Tools(ctx context.Context) ([]gollem.Tool, error)
- func (mock *StrategyMock) ToolsCalls() []struct{ ... }
- type ToolMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LLMClientMock ¶
type LLMClientMock struct {
// GenerateEmbeddingFunc mocks the GenerateEmbedding method.
GenerateEmbeddingFunc func(ctx context.Context, dimension int, input []string) ([][]float64, error)
// NewSessionFunc mocks the NewSession method.
NewSessionFunc func(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error)
// contains filtered or unexported fields
}
LLMClientMock is a mock implementation of gollem.LLMClient.
func TestSomethingThatUsesLLMClient(t *testing.T) {
// make and configure a mocked gollem.LLMClient
mockedLLMClient := &LLMClientMock{
GenerateEmbeddingFunc: func(ctx context.Context, dimension int, input []string) ([][]float64, error) {
panic("mock out the GenerateEmbedding method")
},
NewSessionFunc: func(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error) {
panic("mock out the NewSession method")
},
}
// use mockedLLMClient in code that requires gollem.LLMClient
// and then make assertions.
}
func (*LLMClientMock) GenerateEmbedding ¶
func (mock *LLMClientMock) GenerateEmbedding(ctx context.Context, dimension int, input []string) ([][]float64, error)
GenerateEmbedding calls GenerateEmbeddingFunc.
func (*LLMClientMock) GenerateEmbeddingCalls ¶
func (mock *LLMClientMock) GenerateEmbeddingCalls() []struct { Ctx context.Context Dimension int Input []string }
GenerateEmbeddingCalls gets all the calls that were made to GenerateEmbedding. Check the length with:
len(mockedLLMClient.GenerateEmbeddingCalls())
func (*LLMClientMock) NewSession ¶
func (mock *LLMClientMock) NewSession(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error)
NewSession calls NewSessionFunc.
func (*LLMClientMock) NewSessionCalls ¶
func (mock *LLMClientMock) NewSessionCalls() []struct { Ctx context.Context Options []gollem.SessionOption }
NewSessionCalls gets all the calls that were made to NewSession. Check the length with:
len(mockedLLMClient.NewSessionCalls())
type SessionMock ¶
type SessionMock struct {
// AppendHistoryFunc mocks the AppendHistory method.
AppendHistoryFunc func(history *gollem.History) error
// CountTokenFunc mocks the CountToken method.
CountTokenFunc func(ctx context.Context, input ...gollem.Input) (int, error)
// GenerateFunc mocks the Generate method.
GenerateFunc func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error)
// StreamFunc mocks the Stream method.
StreamFunc func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error)
// HistoryFunc mocks the History method.
HistoryFunc func() (*gollem.History, error)
// contains filtered or unexported fields
}
SessionMock is a mock implementation of gollem.Session.
func TestSomethingThatUsesSession(t *testing.T) {
// make and configure a mocked gollem.Session
mockedSession := &SessionMock{
AppendHistoryFunc: func(history *gollem.History) error {
panic("mock out the AppendHistory method")
},
CountTokenFunc: func(ctx context.Context, input ...gollem.Input) (int, error) {
panic("mock out the CountToken method")
},
GenerateFunc: func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error) {
panic("mock out the Generate method")
},
StreamFunc: func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error) {
panic("mock out the Stream method")
},
HistoryFunc: func() (*gollem.History, error) {
panic("mock out the History method")
},
}
// use mockedSession in code that requires gollem.Session
// and then make assertions.
}
func (*SessionMock) AppendHistory ¶
func (mock *SessionMock) AppendHistory(history *gollem.History) error
AppendHistory calls AppendHistoryFunc.
func (*SessionMock) AppendHistoryCalls ¶
func (mock *SessionMock) AppendHistoryCalls() []struct { History *gollem.History }
AppendHistoryCalls gets all the calls that were made to AppendHistory. Check the length with:
len(mockedSession.AppendHistoryCalls())
func (*SessionMock) CountToken ¶
CountToken calls CountTokenFunc.
func (*SessionMock) CountTokenCalls ¶
func (mock *SessionMock) CountTokenCalls() []struct { Ctx context.Context Input []gollem.Input }
CountTokenCalls gets all the calls that were made to CountToken. Check the length with:
len(mockedSession.CountTokenCalls())
func (*SessionMock) Generate ¶
func (mock *SessionMock) Generate(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error)
Generate calls GenerateFunc.
func (*SessionMock) GenerateCalls ¶
func (mock *SessionMock) GenerateCalls() []struct { Ctx context.Context Input []gollem.Input Opts []gollem.GenerateOption }
GenerateCalls gets all the calls that were made to Generate. Check the length with:
len(mockedSession.GenerateCalls())
func (*SessionMock) GenerateContent
deprecated
func (*SessionMock) GenerateStream
deprecated
func (*SessionMock) History ¶
func (mock *SessionMock) History() (*gollem.History, error)
History calls HistoryFunc.
func (*SessionMock) HistoryCalls ¶
func (mock *SessionMock) HistoryCalls() []struct { }
HistoryCalls gets all the calls that were made to History. Check the length with:
len(mockedSession.HistoryCalls())
func (*SessionMock) Stream ¶
func (mock *SessionMock) Stream(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error)
Stream calls StreamFunc.
func (*SessionMock) StreamCalls ¶
func (mock *SessionMock) StreamCalls() []struct { Ctx context.Context Input []gollem.Input Opts []gollem.GenerateOption }
StreamCalls gets all the calls that were made to Stream. Check the length with:
len(mockedSession.StreamCalls())
type StrategyMock ¶
type StrategyMock struct {
// HandleFunc mocks the Handle method.
HandleFunc func(ctx context.Context, state *gollem.StrategyState) ([]gollem.Input, *gollem.ExecuteResponse, error)
// InitFunc mocks the Init method.
InitFunc func(ctx context.Context, inputs []gollem.Input) error
// ToolsFunc mocks the Tools method.
ToolsFunc func(ctx context.Context) ([]gollem.Tool, error)
// contains filtered or unexported fields
}
StrategyMock is a mock implementation of gollem.Strategy.
func TestSomethingThatUsesStrategy(t *testing.T) {
// make and configure a mocked gollem.Strategy
mockedStrategy := &StrategyMock{
HandleFunc: func(ctx context.Context, state *gollem.StrategyState) ([]gollem.Input, *gollem.ExecuteResponse, error) {
panic("mock out the Handle method")
},
InitFunc: func(ctx context.Context, inputs []gollem.Input) error {
panic("mock out the Init method")
},
ToolsFunc: func(ctx context.Context) ([]gollem.Tool, error) {
panic("mock out the Tools method")
},
}
// use mockedStrategy in code that requires gollem.Strategy
// and then make assertions.
}
func (*StrategyMock) Handle ¶
func (mock *StrategyMock) Handle(ctx context.Context, state *gollem.StrategyState) ([]gollem.Input, *gollem.ExecuteResponse, error)
Handle calls HandleFunc.
func (*StrategyMock) HandleCalls ¶
func (mock *StrategyMock) HandleCalls() []struct { Ctx context.Context State *gollem.StrategyState }
HandleCalls gets all the calls that were made to Handle. Check the length with:
len(mockedStrategy.HandleCalls())
func (*StrategyMock) InitCalls ¶
func (mock *StrategyMock) InitCalls() []struct { Ctx context.Context Inputs []gollem.Input }
InitCalls gets all the calls that were made to Init. Check the length with:
len(mockedStrategy.InitCalls())
func (*StrategyMock) ToolsCalls ¶
func (mock *StrategyMock) ToolsCalls() []struct { Ctx context.Context }
ToolsCalls gets all the calls that were made to Tools. Check the length with:
len(mockedStrategy.ToolsCalls())
type ToolMock ¶
type ToolMock struct {
// RunFunc mocks the Run method.
RunFunc func(ctx context.Context, args map[string]any) (map[string]any, error)
// SpecFunc mocks the Spec method.
SpecFunc func() gollem.ToolSpec
// contains filtered or unexported fields
}
ToolMock is a mock implementation of gollem.Tool.
func TestSomethingThatUsesTool(t *testing.T) {
// make and configure a mocked gollem.Tool
mockedTool := &ToolMock{
RunFunc: func(ctx context.Context, args map[string]any) (map[string]any, error) {
panic("mock out the Run method")
},
SpecFunc: func() gollem.ToolSpec {
panic("mock out the Spec method")
},
}
// use mockedTool in code that requires gollem.Tool
// and then make assertions.
}