Merge pull request #6 from lukehollenback/output-model-response

Got rid of useless debug output and made output token count configurable.
This commit is contained in:
Luke Hollenback 2024-04-02 15:39:40 -06:00 committed by GitHub
commit e31563c690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

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

View file

@ -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 });
@ -119,7 +120,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,
@ -140,11 +141,9 @@ async function getAIResponse(prompt: string): Promise<Array<{
],
});
console.log(`Completions Response Object: ${response}`);
const res = response.choices[0].message?.content?.trim() || "{}";
console.log(`Trimmed Response Message: ${res}`);
console.log(`Trimmed Response: ${res}`);
return JSON.parse(res).reviews;
} catch (error) {