Skip to content

Commit

Permalink
test action
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviuscdinu committed Mar 24, 2023
1 parent c4ad267 commit ae3bb60
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ae3bb60

Please sign in to comment.