From 7cbf66ea87a1f7352f5f7ec00c255243c77f41fa Mon Sep 17 00:00:00 2001 From: Rahul Johny Date: Mon, 8 Jun 2026 17:54:40 +0530 Subject: [PATCH 1/3] feat: add word_confidence_threshold param to whisper Adds the wordConfidenceThreshold option (default 0.3) to the whisper API, mirroring the Python client and docs changes. Words with an OCR confidence below the threshold are excluded from the extracted text. Works with form, high_quality and table modes. Co-Authored-By: Claude Opus 4.8 (1M context) --- index.js | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9f6f0f9..3aba438 100644 --- a/index.js +++ b/index.js @@ -184,6 +184,11 @@ class LLMWhispererClientV2 { * @param {boolean} [options.addLineNos=false] - If true, adds line numbers to the extracted text * and saves line metadata, which can be queried later * using the highlights API. + * @param {number} [options.wordConfidenceThreshold=0.3] - The minimum OCR confidence score a word must + * have to be included in the extracted text. Any text whose confidence + * value falls below the configured threshold is ignored and excluded + * from the final output. This parameter works only with "form", + * "high_quality" and "table" modes. * @returns {Promise} The response from the whisper API. * @throws {LLMWhispererClientException} If there is an error in the request. @@ -210,6 +215,7 @@ class LLMWhispererClientV2 { waitForCompletion = false, waitTimeout = 180, addLineNos = false, + wordConfidenceThreshold = 0.3, } = {}) { this.logger.debug("whisper called"); const apiUrl = `${this.baseUrl}/whisper`; @@ -234,6 +240,7 @@ class LLMWhispererClientV2 { wait_for_completion: waitForCompletion, wait_timeout: waitTimeout, add_line_nos: addLineNos, + word_confidence_threshold: wordConfidenceThreshold, }; this.logger.debug(`api_url: ${apiUrl}`); diff --git a/package-lock.json b/package-lock.json index 272c683..02b01cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "llmwhisperer-client", - "version": "2.5.1", + "version": "2.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "llmwhisperer-client", - "version": "2.5.1", + "version": "2.6.0", "license": "MIT", "dependencies": { "axios": "~1.17.0", diff --git a/package.json b/package.json index e6e6d85..02207fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "llmwhisperer-client", - "version": "2.5.1", + "version": "2.6.0", "description": "LLMWhisper JS Client", "main": "index.js", "scripts": { From 9a5d34b99718e95ea39bc8cbc2d16d261323cbd9 Mon Sep 17 00:00:00 2001 From: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> Date: Mon, 8 Jun 2026 17:58:47 +0530 Subject: [PATCH 2/3] Update index.js Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3aba438..ac38364 100644 --- a/index.js +++ b/index.js @@ -189,7 +189,7 @@ class LLMWhispererClientV2 { * value falls below the configured threshold is ignored and excluded * from the final output. This parameter works only with "form", * "high_quality" and "table" modes. - + * * @returns {Promise} The response from the whisper API. * @throws {LLMWhispererClientException} If there is an error in the request. */ From 11cc51424e3dc5deaa00a9416ccef68a1d99106d Mon Sep 17 00:00:00 2001 From: Rahul Johny Date: Tue, 9 Jun 2026 16:25:47 +0530 Subject: [PATCH 3/3] test: add word_confidence_threshold forwarding tests; fix JSDoc - Fix missing leading ' *' on the blank JSDoc line before @returns. - Add tests asserting wordConfidenceThreshold is forwarded as word_confidence_threshold (custom value and the 0.3 default). Co-Authored-By: Claude Opus 4.8 (1M context) --- test/retry.test.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/retry.test.js b/test/retry.test.js index 89d2497..eff4f40 100644 --- a/test/retry.test.js +++ b/test/retry.test.js @@ -328,3 +328,42 @@ describe("Logging on retries", () => { expect(warnCall).toMatch(/503/); }); }); + +describe("whisper word_confidence_threshold param", () => { + test("forwards a custom wordConfidenceThreshold as word_confidence_threshold", async () => { + const client = createV2Client(); + let capturedConfig; + client.client.defaults.adapter = (config) => { + capturedConfig = config; + return Promise.resolve({ + status: 202, + data: { whisper_hash: "h" }, + headers: {}, + config, + }); + }; + + await client.whisper({ + url: "https://example.com/doc.pdf", + wordConfidenceThreshold: 0.7, + }); + expect(capturedConfig.params.word_confidence_threshold).toBe(0.7); + }); + + test("sends the default word_confidence_threshold of 0.3 when omitted", async () => { + const client = createV2Client(); + let capturedConfig; + client.client.defaults.adapter = (config) => { + capturedConfig = config; + return Promise.resolve({ + status: 202, + data: { whisper_hash: "h" }, + headers: {}, + config, + }); + }; + + await client.whisper({ url: "https://example.com/doc.pdf" }); + expect(capturedConfig.params.word_confidence_threshold).toBe(0.3); + }); +});