ai

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 10 Imported by: 0

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 (*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())

type ModelList added in v0.0.3

type ModelList struct {
	Models  []string `json:"models"`
	Default string   `json:"default"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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