-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (44 loc) · 2.02 KB
/
index.js
File metadata and controls
49 lines (44 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const {Configuration, OpenAIApi} = require("openai");
module.exports = (app) => {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
app.on("issues.opened", async (context) => {
try {
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{
role: "user",
content: "Is following text is a github feature request, please tell me yes or no?" + context.payload.issue.body
}],
});
const completion_text = completion.data.choices[0].message.content;
console.log("gpt:" + completion_text)
if (completion_text.includes("Yes")) {
const issueComment = context.issue({
body: "The [feature] request seems to be beyond the scope of [license]. Maintainer time is a scarce resource." +
" [employee] can you check with [organization] to see if they can fund their open source dependency tree using thanks.dev.\n" +
"Your funding helps us continue to deliver the service you've come to love from [project] & [ecosystem].\n" +
"[feature]=xxx\n" +
"[license]=MIT\n" +
"[organisation]=xx\n" +
"[project]=xx\n" +
"[ecosystem]=xx"
});
return context.octokit.issues.createComment(issueComment);
}
} catch (error) {
if (error.response) {
console.log(error.response.status);
console.log(error.response.data);
} else {
console.log(error.message);
}
}
});
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
};