gpt

package
v0.0.0-...-9bedb10 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SummarizeFileTemplate            = "summarize_file.tmpl"
	SummarizeDiffTemplate            = "summarize_diff.tmpl"
	PrevChunkSummaryTemplate         = "prev_chunk_summary.tmpl"
	SummarizeChangesTemplate         = "summarize_changes.tmpl"
	FinalizeCommitMsgTemplate        = "finalize_commit_msg.tmpl"
	HookPrepareCommitMessageTemplate = "prepare-commit-msg.tmpl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Gpt

type Gpt interface {
	SummarizeFile(ctx context.Context, op git.GitOperation, fileName, fileContent string) (string, error)
	SummarizeDiff(ctx context.Context, fileName, diff string) (string, error)
	SummarizeChanges(ctx context.Context, changes []string) (string, error)
	FinalizeCommitMsg(ctx context.Context, prompt string) (string, error)
	GetStats(ctx context.Context) *Stats
}

func New

func New(opts ...Option) Gpt

type Option

type Option func(*client)

func WithAzureOpenAI

func WithAzureOpenAI(token, endpoint, model, alias string) Option

func WithMaxChunkSize

func WithMaxChunkSize(maxChunkSize int) Option

func WithMaxTokens

func WithMaxTokens(maxTokens int) Option

func WithOpenAI

func WithOpenAI(token, model string) Option

func WithStream

func WithStream(stream bool) Option

func WithTemperature

func WithTemperature(temperature float32) Option

A low temperature makes the model more confident in its top choices, while temperatures greater than 1 decrease confidence in its top choices. An even higher temperature corresponds to more uniform sampling (total randomness). A temperature of 0 is equivalent to argmax/max likelihood, or the highest probability token.

func WithTopP

func WithTopP(topP float32) Option

TopP computes the cumulative probability distribution, and cut off as soon as that distribution exceeds the value of TopP. For example, a TopP of 0.3 means that only the tokens comprising the top 30% probability mass are considered.

type Stats

type Stats struct {
	NumRequests      int
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
	NumFiles         int
}

func (*Stats) String

func (s *Stats) String() string

Jump to

Keyboard shortcuts

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