🎩 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
352
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
4.0.16
to
4.0.17
+10
-0
CHANGELOG.md
# @ai-sdk/groq
## 4.0.17
### Patch Changes
- d2d8744: fix(groq): map word timestamps to transcription segments when segment timestamps are unavailable
- 817910d: Support plain-text responses from Groq transcription models when `responseFormat` is set to `text`.
- Updated dependencies [d8210b6]
- Updated dependencies [b192878]
- @ai-sdk/provider-utils@5.0.16
## 4.0.16

@@ -4,0 +14,0 @@

+33
-10

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

convertBase64ToUint8Array,
createBinaryResponseHandler,
createJsonResponseHandler as createJsonResponseHandler2,

@@ -876,2 +877,3 @@ mediaTypeToExtension,

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

@@ -881,5 +883,6 @@ };

async doGenerate(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
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 {

@@ -897,5 +900,3 @@ value: response,

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

@@ -906,9 +907,13 @@ fetch: this.config.fetch

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

@@ -946,4 +951,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
};
};

@@ -969,3 +992,3 @@ // src/tool/browser-search.ts

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

@@ -972,0 +995,0 @@ // src/groq-provider.ts

{
"name": "@ai-sdk/groq",
"version": "4.0.16",
"version": "4.0.17",
"type": "module",

@@ -33,3 +33,3 @@ "license": "Apache-2.0",

"@ai-sdk/provider": "4.0.4",
"@ai-sdk/provider-utils": "5.0.15"
"@ai-sdk/provider-utils": "5.0.16"
},

@@ -41,3 +41,3 @@ "devDependencies": {

"zod": "3.25.76",
"@ai-sdk/test-server": "2.0.0",
"@ai-sdk/test-server": "2.0.1",
"@vercel/ai-tsconfig": "0.0.0"

@@ -44,0 +44,0 @@ },

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

convertBase64ToUint8Array,
createBinaryResponseHandler,
createJsonResponseHandler,

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

serializeModelOptions,
type ResponseHandler,
WORKFLOW_SERIALIZE,

@@ -118,2 +120,3 @@ WORKFLOW_DESERIALIZE,

formData,
responseFormat: groqOptions?.responseFormat,
warnings,

@@ -127,4 +130,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 {

@@ -142,5 +150,3 @@ value: response,

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

@@ -157,3 +163,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,

@@ -197,2 +209,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