🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ai-sdk/groq

Package Overview
Dependencies
Maintainers
3
Versions
349
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/groq - npm Package Compare versions

Comparing version
3.0.54
to
3.0.55
+7
-0
CHANGELOG.md
# @ai-sdk/groq
## 3.0.55
### Patch Changes
- ae2812a: fix(groq): map word timestamps to transcription segments when segment timestamps are unavailable
- cc3269f: Support plain-text responses from Groq transcription models when `responseFormat` is set to `text`.
## 3.0.54

@@ -4,0 +11,0 @@

+32
-10

@@ -896,2 +896,3 @@ "use strict";

formData,
responseFormat: groqOptions == null ? void 0 : groqOptions.responseFormat,
warnings

@@ -901,5 +902,6 @@ };

async doGenerate(options) {
var _a, _b, _c, _d, _e, _f, _g;
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
const { formData, warnings } = await this.getArgs(options);
const { formData, responseFormat, warnings } = await this.getArgs(options);
const successfulResponseHandler = responseFormat === "text" ? groqTextTranscriptionResponseHandler : (0, import_provider_utils5.createJsonResponseHandler)(groqTranscriptionResponseSchema);
const {

@@ -917,5 +919,3 @@ value: response,

failedResponseHandler: groqFailedResponseHandler,
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
groqTranscriptionResponseSchema
),
successfulResponseHandler,
abortSignal: options.abortSignal,

@@ -926,9 +926,13 @@ fetch: this.config.fetch

text: response.text,
segments: (_e = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
segments: (_g = (_f = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
text: segment.text,
startSecond: segment.start,
endSecond: segment.end
}))) != null ? _e : [],
language: (_f = response.language) != null ? _f : void 0,
durationInSeconds: (_g = response.duration) != null ? _g : void 0,
}))) != null ? _f : (_e = response.words) == null ? void 0 : _e.map((word) => ({
text: word.word,
startSecond: word.start,
endSecond: word.end
}))) != null ? _g : [],
language: (_h = response.language) != null ? _h : void 0,
durationInSeconds: (_i = response.duration) != null ? _i : void 0,
warnings,

@@ -966,4 +970,22 @@ response: {

})
).nullish(),
words: import_v45.z.array(
import_v45.z.object({
word: import_v45.z.string(),
start: import_v45.z.number(),
end: import_v45.z.number()
})
).nullish()
});
var binaryResponseHandler = (0, import_provider_utils5.createBinaryResponseHandler)();
var textDecoder = new TextDecoder();
var groqTextTranscriptionResponseHandler = async (options) => {
const { value, responseHeaders } = await binaryResponseHandler(options);
const text = textDecoder.decode(value);
return {
value: { text },
rawValue: text,
responseHeaders
};
};

@@ -984,3 +1006,3 @@ // src/tool/browser-search.ts

// src/version.ts
var VERSION = true ? "3.0.54" : "0.0.0-test";
var VERSION = true ? "3.0.55" : "0.0.0-test";

@@ -987,0 +1009,0 @@ // src/groq-provider.ts

@@ -817,2 +817,3 @@ // src/groq-provider.ts

convertBase64ToUint8Array,
createBinaryResponseHandler,
createJsonResponseHandler as createJsonResponseHandler2,

@@ -897,2 +898,3 @@ mediaTypeToExtension,

formData,
responseFormat: groqOptions == null ? void 0 : groqOptions.responseFormat,
warnings

@@ -902,5 +904,6 @@ };

async doGenerate(options) {
var _a, _b, _c, _d, _e, _f, _g;
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
const { formData, warnings } = await this.getArgs(options);
const { formData, responseFormat, warnings } = await this.getArgs(options);
const successfulResponseHandler = responseFormat === "text" ? groqTextTranscriptionResponseHandler : createJsonResponseHandler2(groqTranscriptionResponseSchema);
const {

@@ -918,5 +921,3 @@ value: response,

failedResponseHandler: groqFailedResponseHandler,
successfulResponseHandler: createJsonResponseHandler2(
groqTranscriptionResponseSchema
),
successfulResponseHandler,
abortSignal: options.abortSignal,

@@ -927,9 +928,13 @@ fetch: this.config.fetch

text: response.text,
segments: (_e = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
segments: (_g = (_f = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
text: segment.text,
startSecond: segment.start,
endSecond: segment.end
}))) != null ? _e : [],
language: (_f = response.language) != null ? _f : void 0,
durationInSeconds: (_g = response.duration) != null ? _g : void 0,
}))) != null ? _f : (_e = response.words) == null ? void 0 : _e.map((word) => ({
text: word.word,
startSecond: word.start,
endSecond: word.end
}))) != null ? _g : [],
language: (_h = response.language) != null ? _h : void 0,
durationInSeconds: (_i = response.duration) != null ? _i : void 0,
warnings,

@@ -967,4 +972,22 @@ response: {

})
).nullish(),
words: z5.array(
z5.object({
word: z5.string(),
start: z5.number(),
end: z5.number()
})
).nullish()
});
var binaryResponseHandler = createBinaryResponseHandler();
var textDecoder = new TextDecoder();
var groqTextTranscriptionResponseHandler = async (options) => {
const { value, responseHeaders } = await binaryResponseHandler(options);
const text = textDecoder.decode(value);
return {
value: { text },
rawValue: text,
responseHeaders
};
};

@@ -985,3 +1008,3 @@ // src/tool/browser-search.ts

// src/version.ts
var VERSION = true ? "3.0.54" : "0.0.0-test";
var VERSION = true ? "3.0.55" : "0.0.0-test";

@@ -988,0 +1011,0 @@ // src/groq-provider.ts

{
"name": "@ai-sdk/groq",
"version": "3.0.54",
"version": "3.0.55",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -5,2 +5,3 @@ import type { TranscriptionModelV3, SharedV3Warning } from '@ai-sdk/provider';

convertBase64ToUint8Array,
createBinaryResponseHandler,
createJsonResponseHandler,

@@ -10,2 +11,3 @@ mediaTypeToExtension,

postFormDataToApi,
type ResponseHandler,
} from '@ai-sdk/provider-utils';

@@ -101,2 +103,3 @@ import { z } from 'zod/v4';

formData,
responseFormat: groqOptions?.responseFormat,
warnings,

@@ -110,4 +113,9 @@ };

const currentDate = this.config._internal?.currentDate?.() ?? new Date();
const { formData, warnings } = await this.getArgs(options);
const { formData, responseFormat, warnings } = await this.getArgs(options);
const successfulResponseHandler: ResponseHandler<GroqTranscriptionResponse> =
responseFormat === 'text'
? groqTextTranscriptionResponseHandler
: createJsonResponseHandler(groqTranscriptionResponseSchema);
const {

@@ -125,5 +133,3 @@ value: response,

failedResponseHandler: groqFailedResponseHandler,
successfulResponseHandler: createJsonResponseHandler(
groqTranscriptionResponseSchema,
),
successfulResponseHandler,
abortSignal: options.abortSignal,

@@ -140,3 +146,9 @@ fetch: this.config.fetch,

endSecond: segment.end,
})) ?? [],
})) ??
response.words?.map(word => ({
text: word.word,
startSecond: word.start,
endSecond: word.end,
})) ??
[],
language: response.language ?? undefined,

@@ -180,2 +192,33 @@ durationInSeconds: response.duration ?? undefined,

.nullish(),
words: z
.array(
z.object({
word: z.string(),
start: z.number(),
end: z.number(),
}),
)
.nullish(),
});
type GroqTranscriptionResponse = Partial<
Omit<z.infer<typeof groqTranscriptionResponseSchema>, 'text'>
> & {
text: string;
};
const binaryResponseHandler = createBinaryResponseHandler();
const textDecoder = new TextDecoder();
const groqTextTranscriptionResponseHandler: ResponseHandler<
GroqTranscriptionResponse
> = async options => {
const { value, responseHeaders } = await binaryResponseHandler(options);
const text = textDecoder.decode(value);
return {
value: { text },
rawValue: text,
responseHeaders,
};
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display