mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-28 20:14:14 +00:00
Comment out OpenAI code and add dummy response
This commit is contained in:
parent
087d6085e2
commit
65a6125de1
1 changed files with 24 additions and 14 deletions
38
src/main.ts
38
src/main.ts
|
@ -11,9 +11,9 @@ const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
||||||
|
|
||||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||||
|
|
||||||
const openai = new OpenAI({
|
// const openai = new OpenAI({
|
||||||
apiKey: OPENAI_API_KEY,
|
// apiKey: OPENAI_API_KEY,
|
||||||
});
|
// });
|
||||||
|
|
||||||
interface PRDetails {
|
interface PRDetails {
|
||||||
owner: string;
|
owner: string;
|
||||||
|
@ -124,20 +124,30 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
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-4-1106-preview"
|
||||||
? { response_format: { type: "json_object" } }
|
// ? { response_format: { type: "json_object" } }
|
||||||
: {}),
|
// : {}),
|
||||||
messages: [
|
// messages: [
|
||||||
|
// {
|
||||||
|
// role: "system",
|
||||||
|
// content: prompt,
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// });
|
||||||
|
|
||||||
|
//create a dummy response
|
||||||
|
const response = {
|
||||||
|
choices: [
|
||||||
{
|
{
|
||||||
role: "system",
|
message: {
|
||||||
content: prompt,
|
content: `{"reviews": [{"lineNumber": "1", "reviewComment": "This is a dummy comment"}]}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
};
|
||||||
|
|
||||||
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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue