Skip to content

Commit

Permalink
Added extra debug logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehollenback committed Apr 16, 2024
1 parent b975b08 commit 0c1ad65
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ function analyzeCode(parsedDiff, prDetails, customPrompts) {
for (const chunk of file.chunks) {
const prompt = createPrompt(file, chunk, prDetails, customPrompts);
const aiResponse = yield getAIResponse(prompt);
console.log(`Prompt = ${prompt}`);
console.log(`Response: ${aiResponse}`);
console.log("---------");
if (aiResponse) {
const newComments = createComment(file, chunk, aiResponse);
if (newComments) {
Expand Down Expand Up @@ -157,7 +160,6 @@ function getAIResponse(prompt) {
},
] }));
const res = ((_b = (_a = response.choices[0].message) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.trim()) || "{}";
console.log(`Trimmed Response: ${res}`);
return JSON.parse(res).reviews;
}
catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ async function analyzeCode(
for (const chunk of file.chunks) {
const prompt = createPrompt(file, chunk, prDetails, customPrompts);
const aiResponse = await getAIResponse(prompt);

console.log(`Prompt = ${prompt}`)
console.log(`Response: ${aiResponse}`)
console.log("---------")

if (aiResponse) {
const newComments = createComment(file, chunk, aiResponse);
if (newComments) {
Expand Down Expand Up @@ -143,8 +148,6 @@ async function getAIResponse(prompt: string): Promise<Array<{

const res = response.choices[0].message?.content?.trim() || "{}";

console.log(`Trimmed Response: ${res}`);

return JSON.parse(res).reviews;
} catch (error) {
console.error("Error:", error);
Expand Down

0 comments on commit 0c1ad65

Please sign in to comment.