diff --git a/README.md b/README.md index 53faaf4..71c2d1c 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Review code - uses: flavius-dinu/chatgpt-pr-comment@0.6.0 + uses: flavius-dinu/chatgpt-pr-comment@1.0.0 with: github-token: ${{ secrets.GIT_TOKEN }} openai-token: ${{ secrets.OPENAI_TOKEN }} - model: 'gpt-4' + chatgptmodel: "gpt-4" ``` \ No newline at end of file diff --git a/action.yaml b/action.yaml index 0683d37..dcb09c5 100644 --- a/action.yaml +++ b/action.yaml @@ -7,7 +7,7 @@ inputs: openai-token: description: "OpenAI API token" required: true - model: + chatgptmodel: description: "ChatGPT Model" required: false default: "gpt-3.5-turbo" diff --git a/src/index.js b/src/index.js index 55e2b44..79c610f 100644 --- a/src/index.js +++ b/src/index.js @@ -13,12 +13,12 @@ async function getDiff(prNumber, octokit, repo) { } -async function getExplanation(diff, openaiToken, model) { +async function getExplanation(diff, openaiToken, chatgptmodel) { const chatGptApiUrl = 'https://api.openai.com/v1/chat/completions'; const prompt = `Explain the following code changes with as few words as possible:\n\n${diff}`; try { const response = await axios.post(chatGptApiUrl, { - model: model, + model: chatgptmodel, messages: [ { role: "system", @@ -63,12 +63,12 @@ async function run() { try { const token = core.getInput('github-token', { required: true }); const openaiToken = core.getInput('openai-token', { required: true }); - const model = core.getInput('model') + const chatgptmodel = core.getInput('chatgptmodel') const octokit = github.getOctokit(token); const prNumber = github.context.payload.pull_request.number; const repo = github.context.repo; const diff = await getDiff(prNumber, octokit, repo); - const explanation = await getExplanation(diff, openaiToken, model); + const explanation = await getExplanation(diff, openaiToken, chatgptmodel); await commentOnPr(prNumber, explanation, octokit, repo); } catch (error) { core.setFailed(error.message);