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

@ -1,7 +1,5 @@
# Summary | Résumé # Summary | Résumé
> 1-3 sentence description of the changed you're proposing, including a link to > 1-3 sentence description of the changed you're proposing, including a link to
> a GitHub Issue # or Trello card if applicable. > a GitHub Issue # or Trello card if applicable.

View file

@ -1,10 +1,10 @@
{ {
"action": "opened", "action": "opened",
"repository": { "repository": {
"owner": { "owner": {
"login": "cds-snc" "login": "cds-snc"
},
"name": "cds-ai-codereviewer"
}, },
"number": 3 "name": "cds-ai-codereviewer"
},
"number": 3
} }

61881
dist/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,4 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "extends": ["local>cds-snc/renovate-config"]
"local>cds-snc/renovate-config" }
]
}

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