diff --git a/node-zerox/src/handleWarnings.ts b/node-zerox/src/handleWarnings.ts new file mode 100644 index 0000000..42ea710 --- /dev/null +++ b/node-zerox/src/handleWarnings.ts @@ -0,0 +1,15 @@ +// Tesseract relies on node-fetch v2, which has a deprecated version of punycode +// Suppress the warning for now. Check in when teseract updates to node-fetch v3 +// https://github.com/naptha/tesseract.js/issues/876 +if (process.stderr.write === process.stderr.constructor.prototype.write) { + const stdErrWrite = process.stderr.write; + process.stderr.write = function (chunk: any, ...args: any[]) { + const str = Buffer.isBuffer(chunk) ? chunk.toString() : chunk; + + // Filter out the punycode deprecation warning + if (str.includes("punycode")) { + return true; + } + return stdErrWrite.apply(process.stderr, [chunk]); + }; +} diff --git a/node-zerox/src/index.ts b/node-zerox/src/index.ts index a7d59b0..b36c771 100644 --- a/node-zerox/src/index.ts +++ b/node-zerox/src/index.ts @@ -1,3 +1,4 @@ +import "./handleWarnings"; import { addWorkersToTesseractScheduler, cleanupImage, diff --git a/node-zerox/src/utils.ts b/node-zerox/src/utils.ts index 7ac774d..1007022 100644 --- a/node-zerox/src/utils.ts +++ b/node-zerox/src/utils.ts @@ -16,7 +16,7 @@ const convertAsync = promisify(convert); const defaultLLMParams: LLMParams = { frequencyPenalty: 0, // OpenAI defaults to 0 - maxTokens: 2000, + maxTokens: 4000, presencePenalty: 0, // OpenAI defaults to 0 temperature: 0, topP: 1, // OpenAI defaults to 1