Documentation
¶
Index ¶
- Variables
- type Config
- type MockParaphraser
- type MockParaphraser_Expecter
- type MockParaphraser_Paraphrase_Call
- func (_c *MockParaphraser_Paraphrase_Call) Return(_a0 string, _a1 error) *MockParaphraser_Paraphrase_Call
- func (_c *MockParaphraser_Paraphrase_Call) Run(run func(ctx context.Context, tone string, text string)) *MockParaphraser_Paraphrase_Call
- func (_c *MockParaphraser_Paraphrase_Call) RunAndReturn(run func(context.Context, string, string) (string, error)) *MockParaphraser_Paraphrase_Call
- type Paraphraser
- type Payload
- type Provider
- type Service
- type Tone
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidProvider = errors.New("invalid value for provider") ErrInvalidTone = errors.New("invalid value for tone") ErrInvalidText = errors.New("invalid value for text") )
var AvailableProviders = []Provider{ChatGpt, Gemini}
var AvailableTones = []Tone{Formal, Amicable, Fun, Casual, Sympathetic, Persuasive}
var (
ErrNoConfiguredParaphraser = errors.New("no paraphraser configured for provider")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config contains the configuration for the Paraphrase Service.
func ConfigFromEnv ¶
func ConfigFromEnv() *Config
ConfigFromEnv loads the configuration from the environment variables.
type MockParaphraser ¶
MockParaphraser is an autogenerated mock type for the Paraphraser type
func NewMockParaphraser ¶
func NewMockParaphraser(t interface { mock.TestingT Cleanup(func()) }) *MockParaphraser
NewMockParaphraser creates a new instance of MockParaphraser. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockParaphraser) EXPECT ¶
func (_m *MockParaphraser) EXPECT() *MockParaphraser_Expecter
func (*MockParaphraser) Paraphrase ¶
func (_m *MockParaphraser) Paraphrase(ctx context.Context, tone string, text string) (string, error)
Paraphrase provides a mock function with given fields: ctx, tone, text
type MockParaphraser_Expecter ¶
type MockParaphraser_Expecter struct {
// contains filtered or unexported fields
}
func (*MockParaphraser_Expecter) Paraphrase ¶
func (_e *MockParaphraser_Expecter) Paraphrase(ctx interface{}, tone interface{}, text interface{}) *MockParaphraser_Paraphrase_Call
Paraphrase is a helper method to define mock.On call
- ctx context.Context
- tone string
- text string
type MockParaphraser_Paraphrase_Call ¶
MockParaphraser_Paraphrase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Paraphrase'
func (*MockParaphraser_Paraphrase_Call) Return ¶
func (_c *MockParaphraser_Paraphrase_Call) Return(_a0 string, _a1 error) *MockParaphraser_Paraphrase_Call
func (*MockParaphraser_Paraphrase_Call) Run ¶
func (_c *MockParaphraser_Paraphrase_Call) Run(run func(ctx context.Context, tone string, text string)) *MockParaphraser_Paraphrase_Call
func (*MockParaphraser_Paraphrase_Call) RunAndReturn ¶
func (_c *MockParaphraser_Paraphrase_Call) RunAndReturn(run func(context.Context, string, string) (string, error)) *MockParaphraser_Paraphrase_Call
type Paraphraser ¶
type Paraphraser interface { // Paraphrase rewords the given text to sound more like the given tone. Paraphrase(ctx context.Context, tone string, text string) (string, error) }
Paraphraser is the interface that will be implemented by concrete paraphrasing providers.
type Provider ¶
type Provider string
Provider is the type for representing possible paraphrasing providers.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the service layer containing functionality for paraphrasing.
func NewService ¶
func NewService(cfg *Config, paraphrasers map[Provider]Paraphraser) *Service
func (*Service) Paraphrase ¶
func (s *Service) Paraphrase(ctx context.Context, provider Provider, tone Tone, text string) (string, error)
Paraphrase forwards the paraphrasing request to the configured paraphraser for the given provider. A timeout is set for the request based on the service configuration.