Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AiService ¶
type AiService interface {
Chat(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
ListModels(ctx context.Context) *ModelList
}
type AiServiceImpl ¶
type AiServiceImpl struct {
// contains filtered or unexported fields
}
func NewAiService ¶
func NewAiService(cfg *config.Config, clients map[string]client.ChatClient, logger *zap.SugaredLogger) (*AiServiceImpl, error)
func (*AiServiceImpl) Chat ¶
func (ai *AiServiceImpl) Chat(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
func (*AiServiceImpl) ListModels ¶ added in v0.0.3
func (ai *AiServiceImpl) ListModels(ctx context.Context) *ModelList
type AiServiceMock ¶
type AiServiceMock struct {
// ChatFunc mocks the Chat method.
ChatFunc func(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
// ListModelsFunc mocks the ListModels method.
ListModelsFunc func(ctx context.Context) *ModelList
// contains filtered or unexported fields
}
AiServiceMock is a mock implementation of AiService.
func TestSomethingThatUsesAiService(t *testing.T) {
// make and configure a mocked AiService
mockedAiService := &AiServiceMock{
ChatFunc: func(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error) {
panic("mock out the Chat method")
},
ListModelsFunc: func(ctx context.Context) *ModelList {
panic("mock out the ListModels method")
},
}
// use mockedAiService in code that requires AiService
// and then make assertions.
}
func (*AiServiceMock) Chat ¶
func (mock *AiServiceMock) Chat(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
Chat calls ChatFunc.
func (*AiServiceMock) ChatCalls ¶
func (mock *AiServiceMock) ChatCalls() []struct { Ctx context.Context Request *client.ChatRequest }
ChatCalls gets all the calls that were made to Chat. Check the length with:
len(mockedAiService.ChatCalls())
func (*AiServiceMock) ListModels ¶ added in v0.0.3
func (mock *AiServiceMock) ListModels(ctx context.Context) *ModelList
ListModels calls ListModelsFunc.
func (*AiServiceMock) ListModelsCalls ¶ added in v0.0.3
func (mock *AiServiceMock) ListModelsCalls() []struct { Ctx context.Context }
ListModelsCalls gets all the calls that were made to ListModels. Check the length with:
len(mockedAiService.ListModelsCalls())
Click to show internal directories.
Click to hide internal directories.