Skip to content

Commit

Permalink
Tyler/add ignore warnings (#100)
Browse files Browse the repository at this point in the history
* add function to ignore punycode warnings

* 1.0.39

* Also increase max tokens
  • Loading branch information
tylermaran authored Dec 10, 2024
1 parent 55d209f commit 581756b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions node-zerox/src/handleWarnings.ts
Original file line number Diff line number Diff line change
@@ -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]);
};
}
1 change: 1 addition & 0 deletions node-zerox/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./handleWarnings";
import {
addWorkersToTesseractScheduler,
cleanupImage,
Expand Down
2 changes: 1 addition & 1 deletion node-zerox/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 581756b

Please sign in to comment.