Skip to content

Commit

Permalink
openaiExplainPatch.js: exit eagerly if patch length is none
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed Dec 20, 2023
1 parent 73bab51 commit 07bdae2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/openaiExplainPatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ Desired format:
try {
m = realModels[i];
let enc = encoding_for_model(m);
if (enc.encode(patchBody).length < amplification*max_tokens)
let pLen = enc.encode(patchBody).length;
if (pLen == 0)
throw new Error("The patch is empty, cannot summarize!");
if (pLen < amplification*max_tokens)
throw new Error("The patch is trivial, no need for a summarization");
var aiResponse = await openai.chat.completions.create({
model: m,
Expand Down

0 comments on commit 07bdae2

Please sign in to comment.