Skip to content

Commit 581756b

Browse files
authored
Tyler/add ignore warnings (#100)
* add function to ignore punycode warnings * 1.0.39 * Also increase max tokens
1 parent 55d209f commit 581756b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

node-zerox/src/handleWarnings.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Tesseract relies on node-fetch v2, which has a deprecated version of punycode
2+
// Suppress the warning for now. Check in when teseract updates to node-fetch v3
3+
// https://github.com/naptha/tesseract.js/issues/876
4+
if (process.stderr.write === process.stderr.constructor.prototype.write) {
5+
const stdErrWrite = process.stderr.write;
6+
process.stderr.write = function (chunk: any, ...args: any[]) {
7+
const str = Buffer.isBuffer(chunk) ? chunk.toString() : chunk;
8+
9+
// Filter out the punycode deprecation warning
10+
if (str.includes("punycode")) {
11+
return true;
12+
}
13+
return stdErrWrite.apply(process.stderr, [chunk]);
14+
};
15+
}

node-zerox/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./handleWarnings";
12
import {
23
addWorkersToTesseractScheduler,
34
cleanupImage,

node-zerox/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const convertAsync = promisify(convert);
1616

1717
const defaultLLMParams: LLMParams = {
1818
frequencyPenalty: 0, // OpenAI defaults to 0
19-
maxTokens: 2000,
19+
maxTokens: 4000,
2020
presencePenalty: 0, // OpenAI defaults to 0
2121
temperature: 0,
2222
topP: 1, // OpenAI defaults to 1

0 commit comments

Comments
 (0)