-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1st
40 lines (32 loc) · 1.3 KB
/
1st
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
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
app.post('/create-issues', async (req, res) => {
const userText = req.body.text;
// Send the user's text to the GPT-3 API
const gptResponse = await axios.post('https://api.openai.com/v1/engines/davinci-codex/completions', {
prompt: userText,
max_tokens: 60,
}, {
headers: {
'Authorization': `Bearer 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`,
},
});
// Transform the GPT-3 response into the format required by the ZenHub API
const zenhubData = transformGptResponse(gptResponse.data);
// Send a POST request to the ZenHub API to create the issues
const zenhubResponse = await axios.post('https://api.zenhub.io/p1/repositories/483562652/issues', zenhubData, {
headers: {
'X-Authentication-Token': zh_d185e9724bd7be9e422032cc6b3d05314a282c77c660e530ec8847f87eb47cd8,
},
});
res.json(zenhubResponse.data);
});
function transformGptResponse(gptResponse) {
// This function should transform the GPT-3 response into the format required by the ZenHub API
// The exact implementation will depend on the structure of the GPT-3 response and the ZenHub API requirements
}
app.listen(3000, () => {
console.log('Server is running on port 3000');
});