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 openai = new OpenAI({
|
||||
apiKey: OPENAI_API_KEY,
|
||||
});
|
||||
// const openai = new OpenAI({
|
||||
// apiKey: OPENAI_API_KEY,
|
||||
// });
|
||||
|
||||
interface PRDetails {
|
||||
owner: string;
|
||||
|
@ -124,20 +124,30 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
|||
};
|
||||
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
...queryConfig,
|
||||
// return JSON if the model supports it:
|
||||
...(OPENAI_API_MODEL === "gpt-4-1106-preview"
|
||||
? { response_format: { type: "json_object" } }
|
||||
: {}),
|
||||
messages: [
|
||||
// const response = await openai.chat.completions.create({
|
||||
// ...queryConfig,
|
||||
// // return JSON if the model supports it:
|
||||
// ...(OPENAI_API_MODEL === "gpt-4-1106-preview"
|
||||
// ? { response_format: { type: "json_object" } }
|
||||
// : {}),
|
||||
// messages: [
|
||||
// {
|
||||
// role: "system",
|
||||
// content: prompt,
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
|
||||
//create a dummy response
|
||||
const response = {
|
||||
choices: [
|
||||
{
|
||||
role: "system",
|
||||
content: prompt,
|
||||
message: {
|
||||
content: `{"reviews": [{"lineNumber": "1", "reviewComment": "This is a dummy comment"}]}`,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
};
|
||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
||||
return JSON.parse(res).reviews;
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue