Skip to content

Commit f238c27

Browse files
committed
Fix edge case for json comment
1 parent 62fdb56 commit f238c27

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ async function getAIResponse(prompt: string): Promise<Array<{
156156
}
157157

158158
const res = response.choices[0].message?.content?.trim() || "{}";
159-
return JSON.parse(res).reviews;
159+
if (res.startsWith("```json")) {
160+
return JSON.parse(res.slice(7, -3)).reviews
161+
} else {
162+
return JSON.parse(res).reviews;
163+
}
160164
} catch (error) {
161165
console.error("Error:", error, response?.choices[0].message?.content);
162166
return null;

0 commit comments

Comments
 (0)