Comment out OpenAI code and add dummy response

This commit is contained in:
Uday Girhepunje 2024-04-07 19:54:56 +05:30
commit 65a6125de1

View file

@ -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) {