fix: use JSON.parse instead of jsonic to parse response in main.ts

This commit fixes an issue where the jsonic library was being used to parse a response in the main.ts file. The jsonic library has been replaced with JSON.parse for more reliable JSON parsing.
This commit is contained in:
Will Hohyon Ryu 2024-03-07 19:12:30 -08:00
commit 1cc4cd48bc

View file

@ -4,7 +4,6 @@ import OpenAI from "openai";
import {Octokit} from "@octokit/rest"; import {Octokit} from "@octokit/rest";
import parseDiff, {Chunk, File} from "parse-diff"; import parseDiff, {Chunk, File} from "parse-diff";
import minimatch from "minimatch"; import minimatch from "minimatch";
import jsonic from "jsonic";
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN"); const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY"); const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
@ -152,7 +151,7 @@ async function getAIResponse(prompt: string): Promise<Array<{
.replace(/```json/g, "") .replace(/```json/g, "")
.replace(/```/g, ""); .replace(/```/g, "");
return jsonic(cleanupResponse).reviews; return JSON.parse(cleanupResponse).reviews;
} }
function createComment( function createComment(