mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-21 01:56:47 +00:00
Fix edge case for json comment
This commit is contained in:
parent
62fdb56591
commit
f238c27c26
1 changed files with 5 additions and 1 deletions
|
@ -156,7 +156,11 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
|||
}
|
||||
|
||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
||||
return JSON.parse(res).reviews;
|
||||
if (res.startsWith("```json")) {
|
||||
return JSON.parse(res.slice(7, -3)).reviews
|
||||
} else {
|
||||
return JSON.parse(res).reviews;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error, response?.choices[0].message?.content);
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue