Documentation
¶
Index ¶
- func NewClients(cfg *config.Config, logger *zap.SugaredLogger) (map[string]ChatClient, error)
- func NewOpenAIChatCompletionService(config *config.OpenAI) *openai.ChatCompletionService
- type ChatClient
- type ChatClientMock
- func (mock *ChatClientMock) Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
- func (mock *ChatClientMock) ChatCalls() []struct{ ... }
- func (mock *ChatClientMock) ImageGen(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error)
- func (mock *ChatClientMock) ImageGenCalls() []struct{ ... }
- type ChatRequest
- type ChatResponse
- type Content
- type ContentType
- type GeminiClient
- type GenaiModelService
- type GenaiModelServiceMock
- type ImageGenResponse
- type ImageGenerateRequest
- type ImageResponse
- type Message
- type OpenAIClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClients ¶
func NewClients(cfg *config.Config, logger *zap.SugaredLogger) (map[string]ChatClient, error)
func NewOpenAIChatCompletionService ¶
func NewOpenAIChatCompletionService(config *config.OpenAI) *openai.ChatCompletionService
Types ¶
type ChatClient ¶
type ChatClient interface {
Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
ImageGen(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error)
}
type ChatClientMock ¶ added in v0.1.7
type ChatClientMock struct {
// ChatFunc mocks the Chat method.
ChatFunc func(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
// ImageGenFunc mocks the ImageGen method.
ImageGenFunc func(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error)
// contains filtered or unexported fields
}
ChatClientMock is a mock implementation of ChatClient.
func TestSomethingThatUsesChatClient(t *testing.T) {
// make and configure a mocked ChatClient
mockedChatClient := &ChatClientMock{
ChatFunc: func(ctx context.Context, request *ChatRequest) (*ChatResponse, error) {
panic("mock out the Chat method")
},
ImageGenFunc: func(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error) {
panic("mock out the ImageGen method")
},
}
// use mockedChatClient in code that requires ChatClient
// and then make assertions.
}
func (*ChatClientMock) Chat ¶ added in v0.1.7
func (mock *ChatClientMock) Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
Chat calls ChatFunc.
func (*ChatClientMock) ChatCalls ¶ added in v0.1.7
func (mock *ChatClientMock) ChatCalls() []struct { Ctx context.Context Request *ChatRequest }
ChatCalls gets all the calls that were made to Chat. Check the length with:
len(mockedChatClient.ChatCalls())
func (*ChatClientMock) ImageGen ¶ added in v0.1.7
func (mock *ChatClientMock) ImageGen(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error)
ImageGen calls ImageGenFunc.
func (*ChatClientMock) ImageGenCalls ¶ added in v0.1.7
func (mock *ChatClientMock) ImageGenCalls() []struct { Ctx context.Context Request *ChatRequest }
ImageGenCalls gets all the calls that were made to ImageGen. Check the length with:
len(mockedChatClient.ImageGenCalls())
type ChatRequest ¶
type ChatResponse ¶
type Content ¶ added in v0.1.5
type Content struct {
Type ContentType
Data string
}
type ContentType ¶ added in v0.1.5
type ContentType string
const ( ContentTypeText ContentType = "text" ContentTypeImage ContentType = "image" )
type GeminiClient ¶ added in v0.1.7
type GeminiClient struct {
// contains filtered or unexported fields
}
func NewGeminiClient ¶ added in v0.1.7
func NewGeminiClient(config *config.Gemini, logger *zap.SugaredLogger) (*GeminiClient, error)
func (*GeminiClient) Chat ¶ added in v0.1.7
func (c *GeminiClient) Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
func (*GeminiClient) ImageGen ¶ added in v0.1.7
func (c *GeminiClient) ImageGen(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error)
type GenaiModelService ¶ added in v0.1.7
type GenaiModelService interface {
GenerateContent(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)
}
type GenaiModelServiceMock ¶ added in v0.1.7
type GenaiModelServiceMock struct {
// GenerateContentFunc mocks the GenerateContent method.
GenerateContentFunc func(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)
// contains filtered or unexported fields
}
GenaiModelServiceMock is a mock implementation of GenaiModelService.
func TestSomethingThatUsesGenaiModelService(t *testing.T) {
// make and configure a mocked GenaiModelService
mockedGenaiModelService := &GenaiModelServiceMock{
GenerateContentFunc: func(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error) {
panic("mock out the GenerateContent method")
},
}
// use mockedGenaiModelService in code that requires GenaiModelService
// and then make assertions.
}
func (*GenaiModelServiceMock) GenerateContent ¶ added in v0.1.7
func (mock *GenaiModelServiceMock) GenerateContent(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)
GenerateContent calls GenerateContentFunc.
func (*GenaiModelServiceMock) GenerateContentCalls ¶ added in v0.1.7
func (mock *GenaiModelServiceMock) GenerateContentCalls() []struct { Ctx context.Context Model string Contents []*genai.Content Config *genai.GenerateContentConfig }
GenerateContentCalls gets all the calls that were made to GenerateContent. Check the length with:
len(mockedGenaiModelService.GenerateContentCalls())
type ImageGenResponse ¶ added in v0.1.7
type ImageGenerateRequest ¶
type ImageResponse ¶
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
func NewOpenAIClient ¶
func NewOpenAIClient(completionService oaiChatCompletionService, logger *zap.SugaredLogger) *OpenAIClient
func (*OpenAIClient) Chat ¶
func (c *OpenAIClient) Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
func (*OpenAIClient) ImageGen ¶ added in v0.1.7
func (c *OpenAIClient) ImageGen(ctx context.Context, request *ChatRequest) (*ImageGenResponse, error)
Click to show internal directories.
Click to hide internal directories.