mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 04:44:16 +00:00
log the response
This commit is contained in:
parent
77fb26337f
commit
62fdb56591
1 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,7 @@ 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 { parse } from "path";
|
import { parse } from "path";
|
||||||
|
import { APIPromise } from "openai/core";
|
||||||
|
|
||||||
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");
|
||||||
|
@ -132,11 +133,12 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
||||||
presence_penalty: 0,
|
presence_penalty: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let response: OpenAI.Chat.Completions.ChatCompletion | null = null;
|
||||||
try {
|
try {
|
||||||
const response = await openai.chat.completions.create({
|
response = await openai.chat.completions.create({
|
||||||
...queryConfig,
|
...queryConfig,
|
||||||
// return JSON if the model supports it:
|
// return JSON if the model supports it:
|
||||||
response_format: { type: "json_object" },
|
response_format: { type: "json_object" as const },
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: "system",
|
role: "system",
|
||||||
|
@ -156,7 +158,7 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
||||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
const res = response.choices[0].message?.content?.trim() || "{}";
|
||||||
return JSON.parse(res).reviews;
|
return JSON.parse(res).reviews;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error, response?.choices[0].message?.content);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue