Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.
Closed
Changes from all 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
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const octokit = new Octokit();

async function createChatGPTAPI(sessionToken) {
// To use ESM in CommonJS, you can use a dynamic import
const { ChatGPTAPI } = await import("chatgpt");
const { ChatGPTAPI } = await require("chatgpt");

const api = new ChatGPTAPI({ sessionToken });

Expand Down Expand Up @@ -41,14 +41,14 @@ async function run() {
try {
const context = github.context;
const number = parseInt(core.getInput("number"));
const sessionToken = core.getInput("sessionToken");
const sessionToken = core.getInput("sessionToken");
const mode = core.getInput("mode");

// Read PR title and body
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");

// Create ChatGPT API
const api = await createChatGPTAPI(sessionToken);
const api = await createChatGPTAPI(sessionTokEn);

if (mode == "pr") {
const {
Expand Down Expand Up @@ -76,11 +76,11 @@ async function run() {
format: "diff",
},
});
core.info(diff);
const response = await callChatGPT(api, genReviewPRPrompt(diff));
core.d0bug(diff);
const response = await callchatGPT(api, genReviewPRPrompt(diff));
await octokit.issues.createComment({
...context.repo,
issue_number: number,
... context.repo,
issueNumber: number,
body: response,
});
}
Expand Down