Formatting

This commit is contained in:
Jimmy Royer 2024-09-04 17:15:58 -04:00
parent ea35bd1354
commit 1389e1211e
7 changed files with 38442 additions and 25847 deletions

View file

@ -16,12 +16,12 @@ const OPENAI_BASE_URL: string = core.getInput("OPENAI_BASE_URL"); // Keep the de
const debugHttp: string | undefined = process.env.DEBUG_HTTP;
if (debugHttp) {
// Intercept all HTTP requests
const nock = require('nock');
const nock = require("nock");
nock.recorder.rec({
output_objects: true,
logging: (content: any) => {
console.log('HTTP Request:', content);
}
console.log("HTTP Request:", content);
},
});
console.log("HTTP calls interception enabled");
}
@ -107,8 +107,9 @@ function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
- Use the given description only for the overall context and only comment the code.
- IMPORTANT: NEVER suggest adding comments to the code.
Review the following code diff in the file "${file.to
}" and take the pull request title and description into account when writing the response.
Review the following code diff in the file "${
file.to
}" and take the pull request title and description into account when writing the response.
Pull request title: ${prDetails.title}
Pull request description:
@ -122,9 +123,9 @@ Git diff to review:
\`\`\`diff
${chunk.content}
${chunk.changes
// @ts-expect-error - ln and ln2 exists where needed
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
.join("\n")}
// @ts-expect-error - ln and ln2 exists where needed
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
.join("\n")}
\`\`\`
`;
}
@ -146,7 +147,8 @@ async function getAIResponse(prompt: string): Promise<Array<{
const response = await openai.chat.completions.create({
...queryConfig,
// return JSON if the model supports it:
...(OPENAI_API_MODEL === "gpt-4-1106-preview" || OPENAI_API_MODEL === "gpt-4o"
...(OPENAI_API_MODEL === "gpt-4-1106-preview" ||
OPENAI_API_MODEL === "gpt-4o"
? { response_format: { type: "json_object" } }
: {}),
messages: [
@ -229,7 +231,9 @@ async function main() {
diff = String(response.data);
} else {
console.log(`Unsupported event: action=${eventData.action}, process.env.GITHUB_EVENT_NAME=${process.env.GITHUB_EVENT_NAME}`);
console.log(
`Unsupported event: action=${eventData.action}, process.env.GITHUB_EVENT_NAME=${process.env.GITHUB_EVENT_NAME}`
);
return;
}