diff --git a/src/openaiExplainPatch.js b/src/openaiExplainPatch.js index 43ec50e..f72e9e7 100644 --- a/src/openaiExplainPatch.js +++ b/src/openaiExplainPatch.js @@ -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,