freeedcom / ai-codereviewer

AI Code Reviewer: Enhance your GitHub workflow with AI-powered code review! Get intelligent feedback and suggestions on pull requests using OpenAI's GPT-4 API, improving code quality and saving developers time.
MIT License
479 stars 439 forks source link

Support latest gpt 4 #32

Closed villesau closed 7 months ago

villesau commented 7 months ago

Support gpt-4-1106-preview and json mode

sarons commented 2 months ago

Hey @villesau, thanks for adding this but it doesn't seem to work. I think it worked first time, but later on I get the same error as https://github.com/freeedcom/ai-codereviewer/issues/56

Run freeedcom/ai-codereviewer@v2.7.0

Error: SyntaxError: Unexpected token ` in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/runner/work/_actions/freeedcom/ai-codereviewer/v2.7.0/webpack:/open-ai-reviewer/lib/main.js:151:1
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/freeedcom/ai-codereviewer/v2.7.0/webpack:/open-ai-reviewer/lib/main.js:28:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: SyntaxError: Unexpected token ` in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/runner/work/_actions/freeedcom/ai-codereviewer/v2.7.0/webpack:/open-ai-reviewer/lib/main.js:151:1
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/freeedcom/ai-codereviewer/v2.7.0/webpack:/open-ai-reviewer/lib/main.js:28:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: SyntaxError: Unexpected token ` in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/runner/work/_actions/freeedcom/ai-codereviewer/v2.7.0/webpack:/open-ai-reviewer/lib/main.js:151:1
    at Generator.next (<anonymous>)
sarons commented 2 months ago

@lukehollenback I also tried your branch https://github.com/freeedcom/ai-codereviewer/pull/57, still the same error

Run lukehollenback/ai-codereviewer@issue-56_json-mode-on-more-models

Error: SyntaxError: Unexpected token ` in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/runner/work/_actions/lukehollenback/ai-codereviewer/issue-56_json-mode-on-more-models/webpack:/open-ai-reviewer/lib/main.js:151:1
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/lukehollenback/ai-codereviewer/issue-56_json-mode-on-more-models/webpack:/open-ai-reviewer/lib/main.js:28:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
yagiz2000 commented 2 months ago

@lukehollenback I also tried your branch #57, still the same error

Run lukehollenback/ai-codereviewer@issue-56_json-mode-on-more-models

Error: SyntaxError: Unexpected token ` in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/runner/work/_actions/lukehollenback/ai-codereviewer/issue-56_json-mode-on-more-models/webpack:/open-ai-reviewer/lib/main.js:151:1
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/lukehollenback/ai-codereviewer/issue-56_json-mode-on-more-models/webpack:/open-ai-reviewer/lib/main.js:28:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

If you add this prompt after - Provide the response in following JSON format: {"reviews": [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]} it will send json string without any prefix and json parse wont fail. (You can test it locally)