Documentation
¶
Index ¶
- type AiService
- type AiServiceImpl
- func (ai *AiServiceImpl) Chat(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
- func (ai *AiServiceImpl) FunctionCall(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error)
- func (ai *AiServiceImpl) GenerateListOptions(ctx context.Context, req GenerateListOptionsRequest) ([]string, error)
- func (ai *AiServiceImpl) ImageGen(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, error)
- func (ai *AiServiceImpl) ListModels(ctx context.Context) *ModelList
- type AiServiceMock
- func (mock *AiServiceMock) Chat(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
- func (mock *AiServiceMock) ChatCalls() []struct{ ... }
- func (mock *AiServiceMock) FunctionCall(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error)
- func (mock *AiServiceMock) FunctionCallCalls() []struct{ ... }
- func (mock *AiServiceMock) GenerateListOptions(ctx context.Context, req GenerateListOptionsRequest) ([]string, error)
- func (mock *AiServiceMock) GenerateListOptionsCalls() []struct{ ... }
- func (mock *AiServiceMock) ImageGen(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, error)
- func (mock *AiServiceMock) ImageGenCalls() []struct{ ... }
- func (mock *AiServiceMock) ListModels(ctx context.Context) *ModelList
- func (mock *AiServiceMock) ListModelsCalls() []struct{ ... }
- type GenerateListOptionsRequest
- type ModelList
- type ModelListItem
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)
ImageGen(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, error)
ListModels(ctx context.Context) *ModelList
FunctionCall(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error)
GenerateListOptions(ctx context.Context, req GenerateListOptionsRequest) ([]string, error)
}
type AiServiceImpl ¶
type AiServiceImpl struct {
// contains filtered or unexported fields
}
func NewAiService ¶
func NewAiService(cfg *config.Config, providerService provider.ProviderService, logger *zap.SugaredLogger) (*AiServiceImpl, error)
func (*AiServiceImpl) Chat ¶
func (ai *AiServiceImpl) Chat(ctx context.Context, request *client.ChatRequest) (*client.ChatResponse, error)
func (*AiServiceImpl) FunctionCall ¶ added in v0.2.0
func (ai *AiServiceImpl) FunctionCall(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error)
func (*AiServiceImpl) GenerateListOptions ¶ added in v0.5.0
func (ai *AiServiceImpl) GenerateListOptions(ctx context.Context, req GenerateListOptionsRequest) ([]string, error)
func (*AiServiceImpl) ImageGen ¶ added in v0.1.7
func (ai *AiServiceImpl) ImageGen(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, 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)
// FunctionCallFunc mocks the FunctionCall method.
FunctionCallFunc func(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error)
// GenerateListOptionsFunc mocks the GenerateListOptions method.
GenerateListOptionsFunc func(ctx context.Context, req GenerateListOptionsRequest) ([]string, error)
// ImageGenFunc mocks the ImageGen method.
ImageGenFunc func(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, 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")
},
FunctionCallFunc: func(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error) {
panic("mock out the FunctionCall method")
},
GenerateListOptionsFunc: func(ctx context.Context, req GenerateListOptionsRequest) ([]string, error) {
panic("mock out the GenerateListOptions method")
},
ImageGenFunc: func(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, error) {
panic("mock out the ImageGen 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) FunctionCall ¶ added in v0.2.0
func (mock *AiServiceMock) FunctionCall(ctx context.Context, request *client.ChatRequest) (*client.FunctionCallResponse, error)
FunctionCall calls FunctionCallFunc.
func (*AiServiceMock) FunctionCallCalls ¶ added in v0.2.0
func (mock *AiServiceMock) FunctionCallCalls() []struct { Ctx context.Context Request *client.ChatRequest }
FunctionCallCalls gets all the calls that were made to FunctionCall. Check the length with:
len(mockedAiService.FunctionCallCalls())
func (*AiServiceMock) GenerateListOptions ¶ added in v0.5.0
func (mock *AiServiceMock) GenerateListOptions(ctx context.Context, req GenerateListOptionsRequest) ([]string, error)
GenerateListOptions calls GenerateListOptionsFunc.
func (*AiServiceMock) GenerateListOptionsCalls ¶ added in v0.5.0
func (mock *AiServiceMock) GenerateListOptionsCalls() []struct { Ctx context.Context Req GenerateListOptionsRequest }
GenerateListOptionsCalls gets all the calls that were made to GenerateListOptions. Check the length with:
len(mockedAiService.GenerateListOptionsCalls())
func (*AiServiceMock) ImageGen ¶ added in v0.1.7
func (mock *AiServiceMock) ImageGen(ctx context.Context, request *client.ChatRequest) (*client.ImageGenResponse, error)
ImageGen calls ImageGenFunc.
func (*AiServiceMock) ImageGenCalls ¶ added in v0.1.7
func (mock *AiServiceMock) ImageGenCalls() []struct { Ctx context.Context Request *client.ChatRequest }
ImageGenCalls gets all the calls that were made to ImageGen. Check the length with:
len(mockedAiService.ImageGenCalls())
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())
type GenerateListOptionsRequest ¶ added in v0.5.0
type ModelList ¶ added in v0.0.3
type ModelList struct {
Models []ModelListItem `json:"models"`
DefaultModel string `json:"default_model"`
DefaultImageModel string `json:"default_image_model"`
}