Documentation
¶
Overview ¶
Package labels classifies issues.
The categories it uses are stored in static/*-categories.yaml files, one file per project.
Index ¶
- func Categories(db storage.DB, project string, issueNumber int64) ([]string, bool)
- type Category
- func CategoriesForProject(project string) []Category
- func IssueCategory(ctx context.Context, db storage.DB, cgen llm.ContentGenerator, ...) (_ Category, explanation string, err error)
- func IssueCategoryFromLists(ctx context.Context, cgen llm.ContentGenerator, iss *github.Issue, ...) (_ Category, explanation string, err error)
- type Example
- type Labeler
- func (l *Labeler) EnableLabels()
- func (l *Labeler) EnableProject(project string)
- func (l *Labeler) LabelIssue(ctx context.Context, project string, issue int64) error
- func (l *Labeler) Latest() timed.DBTime
- func (l *Labeler) RequireApproval()
- func (l *Labeler) Run(ctx context.Context) error
- func (l *Labeler) SetTimeLimit(t time.Time)
- func (l *Labeler) SkipAuthor(author string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
type Category struct { Name string // internal unique name Label string // issue tracker label Description string // should match issue tracker Extra string // additional description, not in issue tracker }
A Category is a classification for an issue.
func CategoriesForProject ¶
CategoriesForProject returns the categories used for the given project, or nil if there are none.
func IssueCategory ¶
func IssueCategory(ctx context.Context, db storage.DB, cgen llm.ContentGenerator, iss *github.Issue) (_ Category, explanation string, err error)
IssueCategory returns the category chosen by the LLM for the issue, along with an explanation of why it was chosen. It uses the built-in list of categories for the issue's project.
If there are examples associated with the issue's project, they are added to the prompt. The first time this happens for each project, the issues are fetched from the db.
func IssueCategoryFromLists ¶
func IssueCategoryFromLists(ctx context.Context, cgen llm.ContentGenerator, iss *github.Issue, cats []Category, exs []Example) (_ Category, explanation string, err error)
IssueCategoryFromLists is like IssueCategory, but uses the given lists of Categories and examples.
type Labeler ¶
type Labeler struct {
// contains filtered or unexported fields
}
A Labeler labels GitHub issues. It uses the following database keys: - ["labels.Labeler"] for the action log. - ["labels.Categories", Project, Issue] to record the categories assigned to an issue.
func New ¶
func New(lg *slog.Logger, db storage.DB, gh *github.Client, cgen llm.ContentGenerator, name string) *Labeler
New creates and returns a new Labeler. It logs to lg, stores state in db, manipulates GitHub issues using gh, and classifies issues using cgen.
For the purposes of storing its own state, it uses the given name. Future calls to New with the same name will use the same state.
Use the Labeler methods to configure the posting parameters (especially Labeler.EnableProject and Labeler.EnableLabels) before calling Labeler.Run.
func (*Labeler) EnableLabels ¶
func (l *Labeler) EnableLabels()
EnableLabels enables the Labeler to label GitHub issues. If EnableLabels has not been called, Labeler.Run logs what it would post but does not post the messages. See also Labeler.EnableProject, which must also be called to set the projects being considered.
func (*Labeler) EnableProject ¶
EnableProject enables the Labeler to post on issues in the given GitHub project (for example "golang/go"). See also Labeler.EnableLabels, which must also be called to post anything to GitHub.
func (*Labeler) LabelIssue ¶
LabelIssue labels a single issue.
It follows the same logic as Labeler.Run for a single issue, except that it does not rely on or modify the Labeler's watcher. This means that Labeler.LabelIssue can be called on any issue without affecting the starting point of future calls to Labeler.Run.
It requires that there be a database entry for the given issue.
func (*Labeler) RequireApproval ¶
func (l *Labeler) RequireApproval()
RequireApproval configures the Labeler to log actions that require approval.
func (*Labeler) Run ¶
Run runs a single round of labeling to GitHub. It scans all open issues that have been created since the last call to Labeler.Run using a Labeler with the same name (see New). Run skips closed issues, and it also skips pull requests.
func (*Labeler) SetTimeLimit ¶
SetTimeLimit controls how old an issue can be for the Labeler to label it. Issues created before time t will be skipped. The default is not to post to issues that are more than 48 hours old at the time of the call to New.