llm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeChangeRequest

type CodeChangeRequest struct {
	Files       []File
	Subject     string
	Body        string
	IssueNumber int
	BaseBranch  string
}

CodeChangeRequest contains all necessary information for generating a prompt for a LLM.

func (CodeChangeRequest) GetPrompt

func (req CodeChangeRequest) GetPrompt() (string, error)

GetPrompt converts the information in the request to a prompt for an LLM.

func (CodeChangeRequest) MustGetPrompt

func (req CodeChangeRequest) MustGetPrompt() string

MustGetPrompt only returns the prompt, but panics if the data in the request cannot populate the template.

func (CodeChangeRequest) String

func (req CodeChangeRequest) String() string

String is the string representation of a CodeChangeRequest. Functionally, it contains the LLM prompt.

type CodeChangeResponse

type CodeChangeResponse struct {
	Files []File `yaml:"files"`
	Notes string `yaml:"notes"`
}

CodeChangeResponse contains data derived from an LLM response to a prompt generated via a CodeChangeRequest.

func ParseCodeChangeResponse

func ParseCodeChangeResponse(llmResponse string) (CodeChangeResponse, error)

ParseCodeChangeResponse parses the LLM's response to CodeChangeRequest (string) into a CodeChangeResponse.

func (CodeChangeResponse) String

func (res CodeChangeResponse) String() string

String is a string representation of CodeChangeResponse.

type DiffCommentRequest

type DiffCommentRequest struct {
	File     File
	Contents string
	Diff     string
	PRNumber int
}

TODO support threads

func (DiffCommentRequest) GetPrompt

func (req DiffCommentRequest) GetPrompt() (string, error)

GetPrompt converts the information in the request to a prompt for an LLM.

func (DiffCommentRequest) MustGetPrompt

func (req DiffCommentRequest) MustGetPrompt() string

MustGetPrompt only returns the prompt, but panics if the data in the request cannot populate the template.

func (DiffCommentRequest) String

func (req DiffCommentRequest) String() string

type DiffCommentResponse

type DiffCommentResponse struct {
	Type     ResponseType `yaml:"responseType"`
	Response string       `yaml:"response"`
	File     File         `yaml:"file"`
}

func ParseDiffCommentResponse

func ParseDiffCommentResponse(llmResponse string) (DiffCommentResponse, error)

func (DiffCommentResponse) String

func (res DiffCommentResponse) String() string

String is a string representation of DiffCommentResponse.

type File

type File struct {
	Path     string `yaml:"path"`
	Contents string `yaml:"contents"`
}

File represents a file in a git repository.

type OpenAIClient

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

func NewOpenAIClient

func NewOpenAIClient(log *zap.Logger, defaultModel, token, debugDir string) *OpenAIClient

func (*OpenAIClient) EvaluateCCR

func (oc *OpenAIClient) EvaluateCCR(ctx context.Context, model string, req CodeChangeRequest) (res CodeChangeResponse, err error)

func (*OpenAIClient) EvaluateDiffComment

func (oc *OpenAIClient) EvaluateDiffComment(ctx context.Context, model string, req DiffCommentRequest) (res DiffCommentResponse, err error)

type ResponseType

type ResponseType int
const (
	ResponseAnswer ResponseType = iota
	ResponseCodeChange
)

Jump to

Keyboard shortcuts

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