Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Feature/wm 153 business logic summary #164

Merged
merged 15 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"next-auth": "^4.10.3",
"nodemailer": "^6.7.8",
"octokit": "^2.0.9",
"openai": "^3.1.0",
"openai": "^3.2.1",
EstebanDalelR marked this conversation as resolved.
Show resolved Hide resolved
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-select": "^4.3.0",
Expand Down
19 changes: 18 additions & 1 deletion pages/api/actions/getContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import executeRequest from "../../../utils/db/azuredb";
import getGitHub from "../../../utils/actions/getGitHub";
import getSlack from "../../../utils/actions/getSlack";
import getJira from "../../../utils/actions/getJira";
const { Configuration, OpenAIApi } = require("openai");

const configuration = new Configuration({
apiKey: process.env.OPEN_AI_KEY,
});
const openai = new OpenAIApi(configuration);

export default async function handler(req, res) {
const { user, title, body, repo, owner, number, commitList } = req.body;
Expand Down Expand Up @@ -256,5 +262,16 @@ export default async function handler(req, res) {
}),
getSlack({ title, body, slack_token, randomWords }),
]);
return res.send({ ghValue, jiraValue, slackValue });

const businessLogicSummary = await openai
.createCompletion({
model: "text-davinci-003",
prompt: `PR 1 title: ${ghValue[0].title || ""} \n PR 1 body: ${ghValue[0].body || ""} \n PR 2 title: ${ghValue[1].title || ""} \n PR 2 body: ${ghValue[1].body || ""} \n PR 3 title: ${ghValue[2].title || ""} \n PR 3 body: ${ghValue[2].body || ""} \n ${commitList || ""} \n Summarize what the 3 PRs and the commit list are about. What are these 3 PRs and the commit list tell us about the business logic? Don't summarize each PR and commit separately, combine them. Don't say "these PRs", instead say "related PRs".`,
baristaGeek marked this conversation as resolved.
Show resolved Hide resolved
max_tokens: 512,
temperature: 0.7,
})
.then((res) => res.data.choices[0].text.trim())
.catch((err) => res.send("error: ", err.message));

return res.send({ ghValue, jiraValue, slackValue, businessLogicSummary});
}