DEV Community

Tatsuya Sato
Tatsuya Sato

Posted on

Labeling by GPT

What I built

I developed a GitHub Action that chooses suitable labels for an opened/edited issue and puts the labels to the issue automatically without predefined rules.

Category Submission:

Maintainer Must-Haves

App Link

Labeling by GPT · Actions · GitHub Marketplace

Screenshots

Image description

You can see this issue and try it by opening new issue!

Description

When an issue is opened/edited, this action reads its title and description, choose suitable labels in the repository and add those labels to the issue.

You don't need to define rules which issue should should have which labels in advance.

Link to Source Code

GitHub logo satoryu / labeling-by-gpt

This action puts labels to an issues in the repository autocratically without pre-defined rule.

Labeling by GPT

When creating new issue, this action puts labels to an issues in the repository autocratically without pre-defined rule. This is powered by OpenAI completion API to choose suitable labels.

Please note that this action supports only issues trigger and the two types: opened and edited.

Inputs

openai-api-key

Required Your OpenAI API Key.

github-token

Optional. GitHub API token to access GitHub API. The default value is secrets.GITHUB_TOKEN, an API token provided for an action. Be sure of that this token has a permission to put labels to an issue. This document would help you.

Example

on:
  issues:
    types: [opened, edited]

jobs:
  test:
    name: test
    runs-on: ubuntu-latest

    steps:
      - uses: satoryu/labeling-by-gpt@main
        with:
          openai-api-key: ${{ secrets.OPENAI_API_KEY }}
Enter fullscreen mode Exit fullscreen mode



Permissive License

MIT License

Background

In maintaining OSS projects, triage is an important activity. GitHub provides 'labeling issues' feature to help maintainers triage their repositories' issues. But triage is boring! As new issue is opened, maintainers have to read its title and description then choose suitable labels and add the labels to it. As issues in a repository increases, the workload of triage increases too. If there were few maintainers of the repo, triage would be impossible.
GitHub Action has the possibility to reduce this workload. But maintainers would define rules in advance in which condition and labels the action should choose and add to an issue.

On the other hand, NLP is getting popular by ChatGPT, OpenAI APIs. OpenAI completion API processes several tasks to a given text 'prompt'. I came up with the idea that this API would help maintainers triage their issues.

This is my motivation to develop this GitHub action.

How I built it

First, I had to confirm that OpenAI completion API works as I want: choose suitable labels from available labels in a repository.
In order to do it, I used ChatGPT:

Image description

Next, I implemented and test it on its repository.
This is quite simple and easy: define a YAML file under .github/workflows.

on:
  issues:
    types: [opened, edited]

jobs:
  test:
    name: test
    runs-on: ubuntu-latest

    steps:
      - uses: satoryu/labeling-by-gpt@main
        with:
          openai-api-key: ${{ secrets.OPENAI_API_KEY }}
Enter fullscreen mode Exit fullscreen mode

Specifying the main branch like satoryu/labeling-by-gpt@main not version (e.g. v0.0.1) always refers to the latest version of this action. This configuration is good for testing on GitHub.

Additional Resources/Info

Top comments (0)