mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-19 09:06:47 +00:00
Update the package correctly
This commit is contained in:
parent
6d9b91bb76
commit
d1491f0083
3 changed files with 1304 additions and 1310 deletions
2600
dist/index.js
vendored
2600
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
12
src/main.ts
12
src/main.ts
|
@ -140,16 +140,8 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
|||
});
|
||||
|
||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
||||
// Remove lines ```json and ``` from the response
|
||||
const jsonStart = res.indexOf("{");
|
||||
const jsonEnd = res.lastIndexOf("}");
|
||||
if (jsonStart === -1 || jsonEnd === -1) {
|
||||
console.error("Error: JSON not found in response: " + res);
|
||||
return null;
|
||||
}
|
||||
const jsonRes = res.substring(jsonStart, jsonEnd + 1);
|
||||
console.log("AI Response:", jsonRes);
|
||||
return JSON.parse(jsonRes).reviews;
|
||||
console.log("AI Response:", res);
|
||||
return JSON.parse(res).reviews;
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue