Skip to content

Commit

Permalink
Create bot-reply-to-new-issue.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiraae authored Apr 26, 2024
1 parent ce5b2d4 commit 9a3401e
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/bot-reply-to-new-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bot Reply to new Issue

on:
issues:
types:
- opened

jobs:
comment-issue:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install --save axios
- name: Cache
uses: actions/cache@v3
with:
key: node_modules
path: node_modules
- name: Comment Issue
uses: actions/github-script@v4
with:
script: |
const {owner, repo} = context.issue
github.reactions.createForIssue({
owner,
repo,
issue_number: context.issue.number,
content: "+1",
});
const fs = require('fs');
const axios = require('axios');
const prompt = {
"prompt": fs.readFileSync('./README.md').toString() + "\n\nAnswer the following question from the text above.\n\nQ: " + context.payload.issue.body + "\nA:",
"max_tokens": 1000,
"stop": [
"\n"
]
}
const res = await axios.post('${{ secrets.APIM_ENDPOINT }}openai/deployments/${{ secrets.OPENAI_DEPLOYMENT_NAME }}/completions?api-version=2024-02-01', JSON.stringify(prompt), {
headers: {
'Content-Type': 'application/json',
'api-key': '${{ secrets.APIM_API_KEY }}'
}
})
.catch(err => {
console.log('Error: ', err.message);
});
console.log('Response: ', res);
github.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: res.data.choices[0].text,
});

0 comments on commit 9a3401e

Please sign in to comment.