Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made maximum number of output tokens configurable, and added debug output. #61

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: "OpenAI API model."
required: false
default: "gpt-4"
max_tokens:
description: "Maximum number of tokens that can be generated per analysis."
required: false
default: "700"
exclude:
description: "Glob patterns to exclude files from the diff analysis"
required: false
Expand Down
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import minimatch from "minimatch";
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
const MAX_TOKENS: number = Number(core.getInput("max_tokens"));

const octokit = new Octokit({ auth: GITHUB_TOKEN });

Expand Down Expand Up @@ -117,7 +118,7 @@ async function getAIResponse(prompt: string): Promise<Array<{
const queryConfig = {
model: OPENAI_API_MODEL,
temperature: 0.2,
max_tokens: 700,
max_tokens: MAX_TOKENS,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
Expand All @@ -139,6 +140,9 @@ async function getAIResponse(prompt: string): Promise<Array<{
});

const res = response.choices[0].message?.content?.trim() || "{}";

console.log(`Trimmed Response: ${res}`);

return JSON.parse(res).reviews;
} catch (error) {
console.error("Error:", error);
Expand Down