mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-21 10:06:47 +00:00
add check for finsih reason
This commit is contained in:
parent
4dc001ac8f
commit
a31be9e5d6
1 changed files with 6 additions and 0 deletions
|
@ -136,6 +136,12 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
|||
],
|
||||
});
|
||||
|
||||
const finish_response = response.choices[0].finish_reason;
|
||||
if (finish_response === 'length') {
|
||||
console.log('The maximum context length has been exceeded. Please reduce the length of the code snippets.');
|
||||
return null;
|
||||
}
|
||||
|
||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
||||
return JSON.parse(res).reviews;
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue