ai

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRateLimitedProvider

func GetRateLimitedProvider(base Provider, enableRetries bool) *rateLimitedProvider

expose rateLimitedProvider for testing

Types

type AnthropicProvider

type AnthropicProvider struct {
	// contains filtered or unexported fields
}

func NewAnthropicProvider

func NewAnthropicProvider(options Options) (*AnthropicProvider, error)

func (*AnthropicProvider) Generate

func (p *AnthropicProvider) Generate(ctx context.Context, prompt string, opts GenerateOptions) ([]string, error)

type CommitMessageGenerator

type CommitMessageGenerator struct {
	// contains filtered or unexported fields
}

CommitMessageGenerator handles generating commit messages using AI providers

func NewCommitMessageGenerator

func NewCommitMessageGenerator(provider Provider, repo *git.Repository) *CommitMessageGenerator

NewCommitMessageGenerator creates a new generator instance

func (*CommitMessageGenerator) GenerateStagedCommitMessage

func (g *CommitMessageGenerator) GenerateStagedCommitMessage(ctx context.Context, opts GenerateOptions) ([]string, error)

GenerateStagedCommitMessage creates a commit message for the current staged changes

type GeminiProvider

type GeminiProvider struct {
	// contains filtered or unexported fields
}

func NewGeminiProvider

func NewGeminiProvider(options Options) (*GeminiProvider, error)

func (*GeminiProvider) Generate

func (p *GeminiProvider) Generate(ctx context.Context, prompt string, opts GenerateOptions) ([]string, error)

type GenerateOptions

type GenerateOptions struct {
	MaxCandidates int      // Number of variations to generate (max 3)
	MaxTokens     int      // Override default max tokens if needed
	Temperature   *float32 // Override default temperature if needed
}

GenerateOptions contains options for a single generation request

type OllamaProvider

type OllamaProvider struct {
	// contains filtered or unexported fields
}

func NewOllamaProvider

func NewOllamaProvider(options Options) (*OllamaProvider, error)

func (*OllamaProvider) Generate

func (p *OllamaProvider) Generate(ctx context.Context, prompt string, opts GenerateOptions) ([]string, error)

type OpenAIProvider

type OpenAIProvider struct {
	// contains filtered or unexported fields
}

func NewOpenAIProvider

func NewOpenAIProvider(options Options) (*OpenAIProvider, error)

func (*OpenAIProvider) Generate

func (p *OpenAIProvider) Generate(ctx context.Context, prompt string, opts GenerateOptions) ([]string, error)

type Options

type Options struct {
	Model          string
	MaxTokens      int
	Temperature    float32
	APIKey         string
	EnableRetries  bool
	CandidateCount int
}

Options contains common configuration options for AI providers

func ConfigToOptions

func ConfigToOptions(cfg *config.Config, providerName string) (Options, error)

ConfigToOptions converts a provider config to Options

type Provider

type Provider interface {
	Generate(ctx context.Context, prompt string, opts GenerateOptions) ([]string, error)
}

Provider defines the interface for AI providers

func NewProvider

func NewProvider(name string, cfg *config.Config) (Provider, error)

Jump to

Keyboard shortcuts

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