Skip to content

Commit 62fdb56

Browse files
committed
log the response
1 parent 77fb263 commit 62fdb56

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Octokit } from "@octokit/rest";
55
import parseDiff, { Chunk, File } from "parse-diff";
66
import minimatch from "minimatch";
77
import { parse } from "path";
8+
import { APIPromise } from "openai/core";
89

910
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
1011
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
@@ -132,11 +133,12 @@ async function getAIResponse(prompt: string): Promise<Array<{
132133
presence_penalty: 0,
133134
};
134135

136+
let response: OpenAI.Chat.Completions.ChatCompletion | null = null;
135137
try {
136-
const response = await openai.chat.completions.create({
138+
response = await openai.chat.completions.create({
137139
...queryConfig,
138140
// return JSON if the model supports it:
139-
response_format: { type: "json_object" },
141+
response_format: { type: "json_object" as const },
140142
messages: [
141143
{
142144
role: "system",
@@ -156,7 +158,7 @@ async function getAIResponse(prompt: string): Promise<Array<{
156158
const res = response.choices[0].message?.content?.trim() || "{}";
157159
return JSON.parse(res).reviews;
158160
} catch (error) {
159-
console.error("Error:", error);
161+
console.error("Error:", error, response?.choices[0].message?.content);
160162
return null;
161163
}
162164
}

0 commit comments

Comments
 (0)