Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON failure w/gpt-4-0125-preview. #56

Open
lukehollenback opened this issue Mar 29, 2024 · 8 comments
Open

JSON failure w/gpt-4-0125-preview. #56

lukehollenback opened this issue Mar 29, 2024 · 8 comments

Comments

@lukehollenback
Copy link

When I configure AI Code Reviewer to run against gpt-4-0125-preview (a turbo model), I get the following failure (sometimes on repeat, sometimes only once) in the AI Code Reviewer step every single time it runs →

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

This failure results in no comments being made on the pull request.

Making it run against gpt-4-1106-preview instead resolves the issue and the action works well.

@villesau
Copy link
Contributor

I think that's probably an issue on OpenAI end generating valid JSON unfortunately. If you have insight on what is the actual return value, that would help!

@lukehollenback
Copy link
Author

lukehollenback commented Apr 2, 2024

It looks like the action forces JSON Mode for the gpt-4-1106-preview model, but not for the gpt-4-0125-preview one. I bet the simplest fix would be to add || OPENAI_API_MODEL === "gpt-4-0125-preview" || OPENAI_API_MODEL === "gpt-4-turbo-preview" to → https://github.com/freeedcom/ai-codereviewer/blob/a9a064dfa1db8c83f40ef63f6e247fa09c935ed6/src/main.ts#L130.

@lukehollenback
Copy link
Author

As an aside, what is the simplest way to debug and tell you what the actual return value is?

@lukehollenback
Copy link
Author

I just put up #57, which seems likely to fix this issue. Very simple enhancement.

@SvenBunge
Copy link

Used gpt-4-turbo-preview that points to gpt-4-0125-preview and still receive a bunch of errors:

Error: SyntaxError: Unexpected token ` in JSON at position 0
at JSON.parse ()
at /home/runner/work/_actions/SvenBunge/ai-codereviewer/main/webpack:/open-ai-reviewer/lib/main.js:151:1
at Generator.next ()
at fulfilled (/home/runner/work/_actions/SvenBunge/ai-codereviewer/main/webpack:/open-ai-reviewer/lib/main.js:28:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

@lukehollenback
Copy link
Author

lukehollenback commented Apr 2, 2024

Used gpt-4-turbo-preview that points to gpt-4-0125-preview and still receive a bunch of errors:

Error: SyntaxError: Unexpected token ` in JSON at position 0
at JSON.parse ()
at /home/runner/work/_actions/SvenBunge/ai-codereviewer/main/webpack:/open-ai-reviewer/lib/main.js:151:1
at Generator.next ()
at fulfilled (/home/runner/work/_actions/SvenBunge/ai-codereviewer/main/webpack:/open-ai-reviewer/lib/main.js:28:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Yeah, because until #57 gets merged, this action only forces JSON mode with the 1106 model - not with any other models.

Even with #57, I get occasional errors with 0125 - but nowhere near as many. I suspect this is happens on larger diffs because of a large number of tokens that are being generated and cutoff - so I also submitted #61 to make max generated tokens configurable.

@SALESBMB
Copy link

SALESBMB commented May 16, 2024

I am seeing this on gpt-3.5-turbo. Is it even supported? The workflow stage is marked as a success.

image

@Wzixiao
Copy link

Wzixiao commented May 18, 2024

Perhaps we can also extract the first "{" and its last "}" and parse it? (In the past, when there was no json_object parameter, this was my solution. the common situation is that the parsing fails due to the existence of "code blocks".)

Additionally, there might be situations where there are not enough tokens. We could possibly use a retry mechanism where the output from the current request is used as input for a new request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants