@juspay/neurolink 12.31.1 → 12.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -3
- package/dist/browser/neurolink.min.js +393 -390
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/core/modules/MessageBuilder.js +8 -0
- package/dist/neurolink.js +4 -0
- package/dist/processors/media/AudioProcessor.d.ts +87 -10
- package/dist/processors/media/AudioProcessor.js +341 -47
- package/dist/types/file.d.ts +69 -1
- package/dist/types/generate.d.ts +51 -0
- package/dist/types/processor.d.ts +19 -0
- package/dist/types/stream.d.ts +17 -0
- package/dist/utils/fileDetector.js +40 -18
- package/dist/utils/messageBuilder.js +66 -5
- package/docs-site/static/search-index.json +4323 -4311
- package/package.json +3 -1
|
@@ -4,4 +4,4 @@ import type { OptionSchema, TextGenerationOptions } from "../../types/index.js";
|
|
|
4
4
|
* This object provides metadata for validation and help text in the CLI loop.
|
|
5
5
|
* It is derived from the main TextGenerationOptions interface to ensure consistency.
|
|
6
6
|
*/
|
|
7
|
-
export declare const textGenerationOptionsSchema: Record<keyof Omit<TextGenerationOptions, "prompt" | "input" | "schema" | "tools" | "context" | "conversationHistory" | "conversationMessages" | "conversationMemoryConfig" | "originalPrompt" | "middleware" | "expectedOutcome" | "evaluationCriteria" | "region" | "csvOptions" | "pdfOptions" | "imageOptions" | "videoOptions" | "officeOptions" | "tts" | "stt" | "thinkingConfig" | "requestId" | "fileRegistry" | "abortSignal" | "toolFilter" | "excludeTools" | "toolChoice" | "prepareStep" | "credentials" | "onFinish" | "onError" | "processors" | "piiDetection" | "responseValidation" | "inputValidation" | "toolExecutionCapture" | "toolExecutionRecorder" | "toolRoots">, OptionSchema>;
|
|
7
|
+
export declare const textGenerationOptionsSchema: Record<keyof Omit<TextGenerationOptions, "prompt" | "input" | "schema" | "tools" | "context" | "conversationHistory" | "conversationMessages" | "conversationMemoryConfig" | "originalPrompt" | "middleware" | "expectedOutcome" | "evaluationCriteria" | "region" | "csvOptions" | "pdfOptions" | "imageOptions" | "audioOptions" | "videoOptions" | "officeOptions" | "tts" | "stt" | "thinkingConfig" | "requestId" | "fileRegistry" | "abortSignal" | "toolFilter" | "excludeTools" | "toolChoice" | "prepareStep" | "credentials" | "onFinish" | "onError" | "processors" | "piiDetection" | "responseValidation" | "inputValidation" | "toolExecutionCapture" | "toolExecutionRecorder" | "toolRoots">, OptionSchema>;
|
|
@@ -105,6 +105,10 @@ export class MessageBuilder {
|
|
|
105
105
|
csvOptions: options.csvOptions,
|
|
106
106
|
pdfOptions: options.pdfOptions,
|
|
107
107
|
imageOptions: options.imageOptions,
|
|
108
|
+
// The audio option bag is carried the same way: omitted here, a
|
|
109
|
+
// caller's transcription backend, model and language never reach
|
|
110
|
+
// AudioProcessor and it silently falls back to auto-selection.
|
|
111
|
+
audioOptions: options.audioOptions,
|
|
108
112
|
// Same reason as csvOptions: the keyframe budget and the
|
|
109
113
|
// transcription flag are read downstream by the detector, and
|
|
110
114
|
// a reconstruction that omits them silently restores defaults.
|
|
@@ -245,6 +249,10 @@ export class MessageBuilder {
|
|
|
245
249
|
csvOptions: options.csvOptions,
|
|
246
250
|
pdfOptions: options.pdfOptions,
|
|
247
251
|
imageOptions: options.imageOptions,
|
|
252
|
+
// The audio option bag is carried the same way: omitted here, a
|
|
253
|
+
// caller's transcription backend, model and language never reach
|
|
254
|
+
// AudioProcessor and it silently falls back to auto-selection.
|
|
255
|
+
audioOptions: options.audioOptions,
|
|
248
256
|
// Same reason as csvOptions: the keyframe budget and the
|
|
249
257
|
// transcription flag are read downstream by the detector, and
|
|
250
258
|
// a reconstruction that omits them silently restores defaults.
|
package/dist/neurolink.js
CHANGED
|
@@ -4280,6 +4280,10 @@ Current user's request: ${currentInput}`;
|
|
|
4280
4280
|
csvOptions: options.csvOptions,
|
|
4281
4281
|
pdfOptions: options.pdfOptions,
|
|
4282
4282
|
imageOptions: options.imageOptions,
|
|
4283
|
+
// #413/#440: the audio option bag belongs in the same list. Left out
|
|
4284
|
+
// here it was accepted by the public type and then silently discarded
|
|
4285
|
+
// before the message builder, like every field above.
|
|
4286
|
+
audioOptions: options.audioOptions,
|
|
4283
4287
|
// videoOptions belongs in that same list and was never in it, so no SDK
|
|
4284
4288
|
// caller's video settings have ever reached a provider -- frames and
|
|
4285
4289
|
// quality included, not just the native-video flags added alongside.
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
import { BaseFileProcessor } from "../base/BaseFileProcessor.js";
|
|
40
|
-
import type { FileInfo, ProcessedAudio, ProcessorFileProcessingResult, ProcessOptions } from "../../types/index.js";
|
|
40
|
+
import type { AudioProcessorOptions, FileInfo, ProcessedAudio, ProcessorFileProcessingResult, ProcessOptions } from "../../types/index.js";
|
|
41
41
|
/**
|
|
42
42
|
* Audio Processor - extracts metadata and tags from audio files for LLM consumption.
|
|
43
43
|
*
|
|
@@ -83,17 +83,46 @@ export declare class AudioProcessor extends BaseFileProcessor<ProcessedAudio> {
|
|
|
83
83
|
*
|
|
84
84
|
* @param fileInfo - File information (can include URL or buffer)
|
|
85
85
|
* @param options - Optional processing options (auth headers, timeout, etc.)
|
|
86
|
+
* widened with the transcription knobs (#413/#440) so a caller-chosen
|
|
87
|
+
* backend, language or prompt reaches the transcriber instead of being
|
|
88
|
+
* discarded at the detector boundary.
|
|
86
89
|
* @returns Processing result with audio metadata or error
|
|
87
90
|
*/
|
|
88
|
-
processFile(fileInfo: FileInfo, options?: ProcessOptions): Promise<ProcessorFileProcessingResult<ProcessedAudio>>;
|
|
91
|
+
processFile(fileInfo: FileInfo, options?: ProcessOptions & AudioProcessorOptions): Promise<ProcessorFileProcessingResult<ProcessedAudio>>;
|
|
89
92
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
93
|
+
* Whether a transcription backend has the credentials it needs (#413).
|
|
94
|
+
*
|
|
95
|
+
* Availability is decided from the environment only — no network call — so
|
|
96
|
+
* selection stays cheap and cannot itself fail. A key that is present but
|
|
97
|
+
* rejected upstream surfaces later, as a transcription failure with the
|
|
98
|
+
* provider's own message, not as "unavailable".
|
|
99
|
+
*
|
|
100
|
+
* @param provider - Backend to check
|
|
101
|
+
* @returns True when at least one of the backend's credential vars is set
|
|
102
|
+
*/
|
|
103
|
+
private isProviderAvailable;
|
|
104
|
+
/**
|
|
105
|
+
* Choose the transcription backend for this file (#413).
|
|
106
|
+
*
|
|
107
|
+
* With no `requested` backend, the first configured entry of
|
|
108
|
+
* {@link TRANSCRIPTION_PROVIDER_ORDER} wins (OpenAI, then Google, then
|
|
109
|
+
* Azure). With one, it is normalised through the alias table and validated
|
|
110
|
+
* for availability — a backend the caller explicitly asked for is never
|
|
111
|
+
* silently swapped for a different one, because a caller who pinned Azure
|
|
112
|
+
* for a data-residency reason would not want OpenAI chosen behind their
|
|
113
|
+
* back. The mismatch is reported instead.
|
|
114
|
+
*
|
|
115
|
+
* @param requested - Caller's `AudioProcessorOptions.provider`, if any
|
|
116
|
+
* @returns The chosen backend, or the reason no backend could be chosen
|
|
117
|
+
*/
|
|
118
|
+
private selectProvider;
|
|
119
|
+
/**
|
|
120
|
+
* Attempt to transcribe audio with whichever backend is configured (#413).
|
|
92
121
|
*
|
|
93
122
|
* Transcription is attempted when:
|
|
94
|
-
* 1.
|
|
95
|
-
* 2. File size is within
|
|
96
|
-
* 3.
|
|
123
|
+
* 1. A backend's credentials are present (see {@link selectProvider})
|
|
124
|
+
* 2. File size is within the 25MB ceiling
|
|
125
|
+
* 3. The file format is one the backend accepts
|
|
97
126
|
*
|
|
98
127
|
* Gracefully degrades: if transcription fails for any reason, metadata-only
|
|
99
128
|
* output is returned (transcription is additive, never blocks processing).
|
|
@@ -101,9 +130,49 @@ export declare class AudioProcessor extends BaseFileProcessor<ProcessedAudio> {
|
|
|
101
130
|
* @param buffer - Audio file content
|
|
102
131
|
* @param filename - Original filename (used for format detection)
|
|
103
132
|
* @param mimetype - MIME type of the audio file
|
|
104
|
-
* @
|
|
133
|
+
* @param options - Caller's transcription knobs (provider, language, prompt)
|
|
134
|
+
* @returns Transcription result with transcript text, or the reason there is none
|
|
105
135
|
*/
|
|
106
136
|
private attemptTranscription;
|
|
137
|
+
/**
|
|
138
|
+
* Transcribe via OpenAI Whisper (#416).
|
|
139
|
+
*
|
|
140
|
+
* A native multipart POST to OpenAI's transcription endpoint. This used to
|
|
141
|
+
* go through @ai-sdk/openai's createOpenAI().transcription() plus the ai
|
|
142
|
+
* package's experimental_transcribe; both were dropped, and this is the
|
|
143
|
+
* only wire behaviour of theirs the processor ever depended on. The same
|
|
144
|
+
* request is already made natively by voice/providers/OpenAISTT.ts.
|
|
145
|
+
*
|
|
146
|
+
* `verbose_json` is requested for `language` and `duration` alongside the
|
|
147
|
+
* text — the response was previously parsed for `text` alone, so both were
|
|
148
|
+
* received and discarded, and `FileProcessingResult.metadata.language` had
|
|
149
|
+
* nothing to report (#409).
|
|
150
|
+
*
|
|
151
|
+
* @param buffer - Audio file content
|
|
152
|
+
* @param filename - Original filename, sent as the multipart part name
|
|
153
|
+
* @param mimetype - MIME type used for the upload blob
|
|
154
|
+
* @param options - Caller's language / model / prompt overrides
|
|
155
|
+
* @param skipped - Builds the "no transcript, and here is why" outcome
|
|
156
|
+
* @returns Transcription result, or the reason there is none
|
|
157
|
+
*/
|
|
158
|
+
private transcribeWithOpenAI;
|
|
159
|
+
/**
|
|
160
|
+
* Transcribe via one of the non-OpenAI STT handlers (#413).
|
|
161
|
+
*
|
|
162
|
+
* Google and Azure already have working, tested implementations under
|
|
163
|
+
* `src/lib/voice/providers/`, reached here through a dynamic import so a
|
|
164
|
+
* file-processing run that never transcribes does not pay to load them —
|
|
165
|
+
* the same reason `music-metadata` is loaded lazily above.
|
|
166
|
+
*
|
|
167
|
+
* @param chosen - Backend and display label from {@link selectProvider}
|
|
168
|
+
* @param buffer - Audio file content
|
|
169
|
+
* @param filename - Original filename; its extension picks the wire format
|
|
170
|
+
* @param mimetype - MIME type, used as the fallback format signal
|
|
171
|
+
* @param options - Caller's language / model overrides
|
|
172
|
+
* @param skipped - Builds the "no transcript, and here is why" outcome
|
|
173
|
+
* @returns Transcription result, or the reason there is none
|
|
174
|
+
*/
|
|
175
|
+
private transcribeWithHandler;
|
|
107
176
|
/**
|
|
108
177
|
* Stub implementation required by BaseFileProcessor.
|
|
109
178
|
* Not used because processFile is fully overridden.
|
|
@@ -161,6 +230,11 @@ export declare class AudioProcessor extends BaseFileProcessor<ProcessedAudio> {
|
|
|
161
230
|
* @param metadata - Extracted audio metadata
|
|
162
231
|
* @param tags - Extracted audio tags
|
|
163
232
|
* @param transcript - Optional transcribed text from Whisper
|
|
233
|
+
* @param skippedReason - When `transcript` is absent, why transcription was
|
|
234
|
+
* skipped (no backend configured, unavailable pinned backend, format/size
|
|
235
|
+
* limit, or a backend call that failed) — inlined so the model is told the
|
|
236
|
+
* reason instead of silently receiving metadata with no transcript, which
|
|
237
|
+
* `AUDIO_TRANSCRIPTION_INSTRUCTIONS` (messageBuilder.ts) tells it to expect.
|
|
164
238
|
* @returns Formatted text content string
|
|
165
239
|
*
|
|
166
240
|
* @example Output:
|
|
@@ -239,7 +313,10 @@ export declare function isAudioFile(mimetype: string, filename: string): boolean
|
|
|
239
313
|
* Convenience function that uses the singleton processor.
|
|
240
314
|
*
|
|
241
315
|
* @param fileInfo - File information (can include URL or buffer)
|
|
242
|
-
* @param options - Optional processing options (auth headers, timeout, etc.)
|
|
316
|
+
* @param options - Optional processing options (auth headers, timeout, etc.),
|
|
317
|
+
* widened with the transcription knobs (#413/#440, matching
|
|
318
|
+
* {@link AudioProcessor.processFile}) so a caller can pin a provider,
|
|
319
|
+
* language, model or prompt through this convenience export too.
|
|
243
320
|
* @returns Processing result with audio metadata or error
|
|
244
321
|
*
|
|
245
322
|
* @example
|
|
@@ -263,4 +340,4 @@ export declare function isAudioFile(mimetype: string, filename: string): boolean
|
|
|
263
340
|
* }
|
|
264
341
|
* ```
|
|
265
342
|
*/
|
|
266
|
-
export declare function processAudio(fileInfo: FileInfo, options?: ProcessOptions): Promise<ProcessorFileProcessingResult<ProcessedAudio>>;
|
|
343
|
+
export declare function processAudio(fileInfo: FileInfo, options?: ProcessOptions & AudioProcessorOptions): Promise<ProcessorFileProcessingResult<ProcessedAudio>>;
|