Skip to content

Commit

Permalink
testing repo and owner
Browse files Browse the repository at this point in the history
  • Loading branch information
snehara99 committed Sep 18, 2023
1 parent 8911a52 commit dd3160f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: snehara99/[email protected].12
- uses: snehara99/[email protected].13
with:
token: ${{ github.token }}
api-key: ${{ secrets.API_KEY }}
endpoint: 'https://americasopenai.azure-api.net'
deployment-id: 'gpt-35-turbo-16k'
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ A GitHub Action that can be used to suggest labels for issues.

## Inputs

### `repo`

The name of the repo with the issues that need label suggestions. Default `${{ github.event.repository.name }}`.

### `owner`

The repo owner's username. Default `${{ github.repository_owner }}`.

### `token`

Access token that can access the issues on the repo. Default `'${{ github.token }}'`.
Access token that can access the issues on the repo. Default `${{ github.token }}`.

### `api-key`

Expand All @@ -30,10 +38,12 @@ The issues and their corresponding labels.

```yaml
name: Suggest Labels
- uses: snehara99/[email protected].11
- uses: snehara99/[email protected].13
with:
repo: ${{ github.event.repository.name }}
owner: ${{ github.repository_owner }}
token: ${{ github.token }}
api-key: ${{ secrets.API_KEY }}
api_key: ${{ secrets.API_KEY }}
endpoint: 'https://americasopenai.azure-api.net'
deployment-id: 'gpt-35-turbo-16k'
```
Expand Down
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ branding:
icon: tag
color: purple
inputs:
repo:
description: "The repo with the issues that need label suggestions."
required: false
default: ${{ github.event.repository.name }}
owner:
description: "The repo owner's user ID."
required: false
default: ${{ github.repository_owner }}
token:
description: "Access token that can access the issues on the repo."
required: false
default: '${{ github.token }}'
default: ${{ github.token }}
api-key:
description: "OpenAI API access key."
required: true
Expand Down
21 changes: 5 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ const { OpenAIClient, AzureKeyCredential } = require("@azure/openai");

async function run() {
try {
const { owner, repo } = github.context.repo;
const repo = core.getInput('repo');
const owner = core.getInput('owner');
const token = core.getInput('token');
const octokit = github.getOctokit(token);

// const owner = 'microsoft';
// const repo = 'vscode-cmake-tools';
// const octokit = github.getOctokit(token);


const issues = (
await octokit.paginate(octokit.rest.issues.listForRepo, {
owner: owner,
Expand All @@ -32,23 +28,19 @@ async function run() {
).map((i) => i.name)
.join("', '");


const apiKey = core.getInput('api-key');
const endpoint = core.getInput('endpoint');
const deploymentID = core.getInput('deployment-id');

// const endpoint = 'https://americasopenai.azure-api.net';
// const deploymentID = 'gpt-35-turbo-16k';

const client = new OpenAIClient(
endpoint,
new AzureKeyCredential(apiKey)
);

var issueLabels = {};

// const delayMS = 1000;
// const delay = ms => new Promise(res => setTimeout(res, ms));
const delayMS = 500;
const delay = ms => new Promise(res => setTimeout(res, ms));

// iterate through issues to label
for (const issue of issues) {
Expand All @@ -64,8 +56,6 @@ async function run() {
},
];
messages.push({ role: "user", content: userMessageText });
console.log(deploymentID);
console.log(messages);
const completion = await client.getChatCompletions(
deploymentID,
messages,
Expand All @@ -76,15 +66,14 @@ async function run() {
maxTokens: 20
}
);
console.log(completion);
const choice = completion.choices[0];
issueLabels[
issue.number
] = `[ISSUE ${issue.number}] ${issue.title}\n${issue.html_url}\n${choice.message.content}\n`
console.log(
`[ISSUE ${issue.number}] ${issue.title}\n${issue.html_url}\n${choice.message.content}\n`
);
// await delay(delayMS);
await delay(delayMS);
}
core.setOutput("labels", issueLabels);
} catch (error) {
Expand Down

0 comments on commit dd3160f

Please sign in to comment.