@ai-sdk/groq 2.0.0-canary.9 → 2.0.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 +445 -0
- package/README.md +2 -2
- package/dist/index.d.mts +19 -35
- package/dist/index.d.ts +19 -35
- package/dist/index.js +209 -149
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
parseProviderOptions,
|
|
21
21
|
postJsonToApi
|
|
22
22
|
} from "@ai-sdk/provider-utils";
|
|
23
|
-
import { z as z3 } from "zod";
|
|
23
|
+
import { z as z3 } from "zod/v4";
|
|
24
24
|
|
|
25
25
|
// src/convert-to-groq-chat-messages.ts
|
|
26
26
|
import {
|
|
@@ -80,7 +80,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
80
80
|
type: "function",
|
|
81
81
|
function: {
|
|
82
82
|
name: part.toolName,
|
|
83
|
-
arguments: JSON.stringify(part.
|
|
83
|
+
arguments: JSON.stringify(part.input)
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
break;
|
|
@@ -96,10 +96,23 @@ function convertToGroqChatMessages(prompt) {
|
|
|
96
96
|
}
|
|
97
97
|
case "tool": {
|
|
98
98
|
for (const toolResponse of content) {
|
|
99
|
+
const output = toolResponse.output;
|
|
100
|
+
let contentValue;
|
|
101
|
+
switch (output.type) {
|
|
102
|
+
case "text":
|
|
103
|
+
case "error-text":
|
|
104
|
+
contentValue = output.value;
|
|
105
|
+
break;
|
|
106
|
+
case "content":
|
|
107
|
+
case "json":
|
|
108
|
+
case "error-json":
|
|
109
|
+
contentValue = JSON.stringify(output.value);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
99
112
|
messages.push({
|
|
100
113
|
role: "tool",
|
|
101
114
|
tool_call_id: toolResponse.toolCallId,
|
|
102
|
-
content:
|
|
115
|
+
content: contentValue
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
break;
|
|
@@ -127,22 +140,29 @@ function getResponseMetadata({
|
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
// src/groq-chat-options.ts
|
|
130
|
-
import { z } from "zod";
|
|
143
|
+
import { z } from "zod/v4";
|
|
131
144
|
var groqProviderOptions = z.object({
|
|
132
|
-
reasoningFormat: z.enum(["parsed", "raw", "hidden"]).
|
|
145
|
+
reasoningFormat: z.enum(["parsed", "raw", "hidden"]).optional(),
|
|
146
|
+
reasoningEffort: z.enum(["none", "default"]).optional(),
|
|
133
147
|
/**
|
|
134
148
|
* Whether to enable parallel function calling during tool use. Default to true.
|
|
135
149
|
*/
|
|
136
|
-
parallelToolCalls: z.boolean().
|
|
150
|
+
parallelToolCalls: z.boolean().optional(),
|
|
137
151
|
/**
|
|
138
152
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
139
153
|
* monitor and detect abuse. Learn more.
|
|
140
154
|
*/
|
|
141
|
-
user: z.string().
|
|
155
|
+
user: z.string().optional(),
|
|
156
|
+
/**
|
|
157
|
+
* Whether to use structured outputs.
|
|
158
|
+
*
|
|
159
|
+
* @default true
|
|
160
|
+
*/
|
|
161
|
+
structuredOutputs: z.boolean().optional()
|
|
142
162
|
});
|
|
143
163
|
|
|
144
164
|
// src/groq-error.ts
|
|
145
|
-
import { z as z2 } from "zod";
|
|
165
|
+
import { z as z2 } from "zod/v4";
|
|
146
166
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
147
167
|
var groqErrorDataSchema = z2.object({
|
|
148
168
|
error: z2.object({
|
|
@@ -178,7 +198,7 @@ function prepareTools({
|
|
|
178
198
|
function: {
|
|
179
199
|
name: tool.name,
|
|
180
200
|
description: tool.description,
|
|
181
|
-
parameters: tool.
|
|
201
|
+
parameters: tool.inputSchema
|
|
182
202
|
}
|
|
183
203
|
});
|
|
184
204
|
}
|
|
@@ -231,21 +251,18 @@ function mapGroqFinishReason(finishReason) {
|
|
|
231
251
|
|
|
232
252
|
// src/groq-chat-language-model.ts
|
|
233
253
|
var GroqChatLanguageModel = class {
|
|
234
|
-
constructor(modelId,
|
|
254
|
+
constructor(modelId, config) {
|
|
235
255
|
this.specificationVersion = "v2";
|
|
236
|
-
this.
|
|
237
|
-
|
|
256
|
+
this.supportedUrls = {
|
|
257
|
+
"image/*": [/^https?:\/\/.*$/]
|
|
258
|
+
};
|
|
238
259
|
this.modelId = modelId;
|
|
239
|
-
this.settings = settings;
|
|
240
260
|
this.config = config;
|
|
241
261
|
}
|
|
242
262
|
get provider() {
|
|
243
263
|
return this.config.provider;
|
|
244
264
|
}
|
|
245
|
-
|
|
246
|
-
return !this.settings.downloadImages;
|
|
247
|
-
}
|
|
248
|
-
getArgs({
|
|
265
|
+
async getArgs({
|
|
249
266
|
prompt,
|
|
250
267
|
maxOutputTokens,
|
|
251
268
|
temperature,
|
|
@@ -261,25 +278,27 @@ var GroqChatLanguageModel = class {
|
|
|
261
278
|
toolChoice,
|
|
262
279
|
providerOptions
|
|
263
280
|
}) {
|
|
281
|
+
var _a, _b;
|
|
264
282
|
const warnings = [];
|
|
283
|
+
const groqOptions = await parseProviderOptions({
|
|
284
|
+
provider: "groq",
|
|
285
|
+
providerOptions,
|
|
286
|
+
schema: groqProviderOptions
|
|
287
|
+
});
|
|
288
|
+
const structuredOutputs = (_a = groqOptions == null ? void 0 : groqOptions.structuredOutputs) != null ? _a : true;
|
|
265
289
|
if (topK != null) {
|
|
266
290
|
warnings.push({
|
|
267
291
|
type: "unsupported-setting",
|
|
268
292
|
setting: "topK"
|
|
269
293
|
});
|
|
270
294
|
}
|
|
271
|
-
if (responseFormat
|
|
295
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !structuredOutputs) {
|
|
272
296
|
warnings.push({
|
|
273
297
|
type: "unsupported-setting",
|
|
274
298
|
setting: "responseFormat",
|
|
275
|
-
details: "JSON response format schema is
|
|
299
|
+
details: "JSON response format schema is only supported with structuredOutputs"
|
|
276
300
|
});
|
|
277
301
|
}
|
|
278
|
-
const groqOptions = parseProviderOptions({
|
|
279
|
-
provider: "groq",
|
|
280
|
-
providerOptions,
|
|
281
|
-
schema: groqProviderOptions
|
|
282
|
-
});
|
|
283
302
|
const {
|
|
284
303
|
tools: groqTools,
|
|
285
304
|
toolChoice: groqToolChoice,
|
|
@@ -301,12 +320,17 @@ var GroqChatLanguageModel = class {
|
|
|
301
320
|
stop: stopSequences,
|
|
302
321
|
seed,
|
|
303
322
|
// response format:
|
|
304
|
-
response_format: (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
323
|
+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
|
|
324
|
+
type: "json_schema",
|
|
325
|
+
json_schema: {
|
|
326
|
+
schema: responseFormat.schema,
|
|
327
|
+
name: (_b = responseFormat.name) != null ? _b : "response",
|
|
328
|
+
description: responseFormat.description
|
|
329
|
+
}
|
|
330
|
+
} : { type: "json_object" } : void 0,
|
|
308
331
|
// provider options:
|
|
309
332
|
reasoning_format: groqOptions == null ? void 0 : groqOptions.reasoningFormat,
|
|
333
|
+
reasoning_effort: groqOptions == null ? void 0 : groqOptions.reasoningEffort,
|
|
310
334
|
// messages:
|
|
311
335
|
messages: convertToGroqChatMessages(prompt),
|
|
312
336
|
// tools:
|
|
@@ -317,8 +341,11 @@ var GroqChatLanguageModel = class {
|
|
|
317
341
|
};
|
|
318
342
|
}
|
|
319
343
|
async doGenerate(options) {
|
|
320
|
-
var _a, _b, _c, _d, _e;
|
|
321
|
-
const { args, warnings } = this.getArgs({
|
|
344
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
345
|
+
const { args, warnings } = await this.getArgs({
|
|
346
|
+
...options,
|
|
347
|
+
stream: false
|
|
348
|
+
});
|
|
322
349
|
const body = JSON.stringify(args);
|
|
323
350
|
const {
|
|
324
351
|
responseHeaders,
|
|
@@ -348,7 +375,6 @@ var GroqChatLanguageModel = class {
|
|
|
348
375
|
if (reasoning != null && reasoning.length > 0) {
|
|
349
376
|
content.push({
|
|
350
377
|
type: "reasoning",
|
|
351
|
-
reasoningType: "text",
|
|
352
378
|
text: reasoning
|
|
353
379
|
});
|
|
354
380
|
}
|
|
@@ -356,10 +382,9 @@ var GroqChatLanguageModel = class {
|
|
|
356
382
|
for (const toolCall of choice.message.tool_calls) {
|
|
357
383
|
content.push({
|
|
358
384
|
type: "tool-call",
|
|
359
|
-
toolCallType: "function",
|
|
360
385
|
toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
|
|
361
386
|
toolName: toolCall.function.name,
|
|
362
|
-
|
|
387
|
+
input: toolCall.function.arguments
|
|
363
388
|
});
|
|
364
389
|
}
|
|
365
390
|
}
|
|
@@ -368,7 +393,8 @@ var GroqChatLanguageModel = class {
|
|
|
368
393
|
finishReason: mapGroqFinishReason(choice.finish_reason),
|
|
369
394
|
usage: {
|
|
370
395
|
inputTokens: (_c = (_b = response.usage) == null ? void 0 : _b.prompt_tokens) != null ? _c : void 0,
|
|
371
|
-
outputTokens: (_e = (_d = response.usage) == null ? void 0 : _d.completion_tokens) != null ? _e : void 0
|
|
396
|
+
outputTokens: (_e = (_d = response.usage) == null ? void 0 : _d.completion_tokens) != null ? _e : void 0,
|
|
397
|
+
totalTokens: (_g = (_f = response.usage) == null ? void 0 : _f.total_tokens) != null ? _g : void 0
|
|
372
398
|
},
|
|
373
399
|
response: {
|
|
374
400
|
...getResponseMetadata(response),
|
|
@@ -380,7 +406,7 @@ var GroqChatLanguageModel = class {
|
|
|
380
406
|
};
|
|
381
407
|
}
|
|
382
408
|
async doStream(options) {
|
|
383
|
-
const { args, warnings } = this.getArgs({ ...options, stream: true });
|
|
409
|
+
const { args, warnings } = await this.getArgs({ ...options, stream: true });
|
|
384
410
|
const body = JSON.stringify({ ...args, stream: true });
|
|
385
411
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
386
412
|
url: this.config.url({
|
|
@@ -401,9 +427,12 @@ var GroqChatLanguageModel = class {
|
|
|
401
427
|
let finishReason = "unknown";
|
|
402
428
|
const usage = {
|
|
403
429
|
inputTokens: void 0,
|
|
404
|
-
outputTokens: void 0
|
|
430
|
+
outputTokens: void 0,
|
|
431
|
+
totalTokens: void 0
|
|
405
432
|
};
|
|
406
433
|
let isFirstChunk = true;
|
|
434
|
+
let isActiveText = false;
|
|
435
|
+
let isActiveReasoning = false;
|
|
407
436
|
let providerMetadata;
|
|
408
437
|
return {
|
|
409
438
|
stream: response.pipeThrough(
|
|
@@ -412,7 +441,10 @@ var GroqChatLanguageModel = class {
|
|
|
412
441
|
controller.enqueue({ type: "stream-start", warnings });
|
|
413
442
|
},
|
|
414
443
|
transform(chunk, controller) {
|
|
415
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
444
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
445
|
+
if (options.includeRawChunks) {
|
|
446
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
447
|
+
}
|
|
416
448
|
if (!chunk.success) {
|
|
417
449
|
finishReason = "error";
|
|
418
450
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -434,6 +466,7 @@ var GroqChatLanguageModel = class {
|
|
|
434
466
|
if (((_a = value.x_groq) == null ? void 0 : _a.usage) != null) {
|
|
435
467
|
usage.inputTokens = (_b = value.x_groq.usage.prompt_tokens) != null ? _b : void 0;
|
|
436
468
|
usage.outputTokens = (_c = value.x_groq.usage.completion_tokens) != null ? _c : void 0;
|
|
469
|
+
usage.totalTokens = (_d = value.x_groq.usage.total_tokens) != null ? _d : void 0;
|
|
437
470
|
}
|
|
438
471
|
const choice = value.choices[0];
|
|
439
472
|
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
@@ -444,16 +477,28 @@ var GroqChatLanguageModel = class {
|
|
|
444
477
|
}
|
|
445
478
|
const delta = choice.delta;
|
|
446
479
|
if (delta.reasoning != null && delta.reasoning.length > 0) {
|
|
480
|
+
if (!isActiveReasoning) {
|
|
481
|
+
controller.enqueue({
|
|
482
|
+
type: "reasoning-start",
|
|
483
|
+
id: "reasoning-0"
|
|
484
|
+
});
|
|
485
|
+
isActiveReasoning = true;
|
|
486
|
+
}
|
|
447
487
|
controller.enqueue({
|
|
448
|
-
type: "reasoning",
|
|
449
|
-
|
|
450
|
-
|
|
488
|
+
type: "reasoning-delta",
|
|
489
|
+
id: "reasoning-0",
|
|
490
|
+
delta: delta.reasoning
|
|
451
491
|
});
|
|
452
492
|
}
|
|
453
493
|
if (delta.content != null && delta.content.length > 0) {
|
|
494
|
+
if (!isActiveText) {
|
|
495
|
+
controller.enqueue({ type: "text-start", id: "txt-0" });
|
|
496
|
+
isActiveText = true;
|
|
497
|
+
}
|
|
454
498
|
controller.enqueue({
|
|
455
|
-
type: "text",
|
|
456
|
-
|
|
499
|
+
type: "text-delta",
|
|
500
|
+
id: "txt-0",
|
|
501
|
+
delta: delta.content
|
|
457
502
|
});
|
|
458
503
|
}
|
|
459
504
|
if (delta.tool_calls != null) {
|
|
@@ -472,39 +517,45 @@ var GroqChatLanguageModel = class {
|
|
|
472
517
|
message: `Expected 'id' to be a string.`
|
|
473
518
|
});
|
|
474
519
|
}
|
|
475
|
-
if (((
|
|
520
|
+
if (((_e = toolCallDelta.function) == null ? void 0 : _e.name) == null) {
|
|
476
521
|
throw new InvalidResponseDataError({
|
|
477
522
|
data: toolCallDelta,
|
|
478
523
|
message: `Expected 'function.name' to be a string.`
|
|
479
524
|
});
|
|
480
525
|
}
|
|
526
|
+
controller.enqueue({
|
|
527
|
+
type: "tool-input-start",
|
|
528
|
+
id: toolCallDelta.id,
|
|
529
|
+
toolName: toolCallDelta.function.name
|
|
530
|
+
});
|
|
481
531
|
toolCalls[index] = {
|
|
482
532
|
id: toolCallDelta.id,
|
|
483
533
|
type: "function",
|
|
484
534
|
function: {
|
|
485
535
|
name: toolCallDelta.function.name,
|
|
486
|
-
arguments: (
|
|
536
|
+
arguments: (_f = toolCallDelta.function.arguments) != null ? _f : ""
|
|
487
537
|
},
|
|
488
538
|
hasFinished: false
|
|
489
539
|
};
|
|
490
540
|
const toolCall2 = toolCalls[index];
|
|
491
|
-
if (((
|
|
541
|
+
if (((_g = toolCall2.function) == null ? void 0 : _g.name) != null && ((_h = toolCall2.function) == null ? void 0 : _h.arguments) != null) {
|
|
492
542
|
if (toolCall2.function.arguments.length > 0) {
|
|
493
543
|
controller.enqueue({
|
|
494
|
-
type: "tool-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
toolName: toolCall2.function.name,
|
|
498
|
-
argsTextDelta: toolCall2.function.arguments
|
|
544
|
+
type: "tool-input-delta",
|
|
545
|
+
id: toolCall2.id,
|
|
546
|
+
delta: toolCall2.function.arguments
|
|
499
547
|
});
|
|
500
548
|
}
|
|
501
549
|
if (isParsableJson(toolCall2.function.arguments)) {
|
|
550
|
+
controller.enqueue({
|
|
551
|
+
type: "tool-input-end",
|
|
552
|
+
id: toolCall2.id
|
|
553
|
+
});
|
|
502
554
|
controller.enqueue({
|
|
503
555
|
type: "tool-call",
|
|
504
|
-
|
|
505
|
-
toolCallId: (_h = toolCall2.id) != null ? _h : generateId(),
|
|
556
|
+
toolCallId: (_i = toolCall2.id) != null ? _i : generateId(),
|
|
506
557
|
toolName: toolCall2.function.name,
|
|
507
|
-
|
|
558
|
+
input: toolCall2.function.arguments
|
|
508
559
|
});
|
|
509
560
|
toolCall2.hasFinished = true;
|
|
510
561
|
}
|
|
@@ -515,23 +566,24 @@ var GroqChatLanguageModel = class {
|
|
|
515
566
|
if (toolCall.hasFinished) {
|
|
516
567
|
continue;
|
|
517
568
|
}
|
|
518
|
-
if (((
|
|
519
|
-
toolCall.function.arguments += (
|
|
569
|
+
if (((_j = toolCallDelta.function) == null ? void 0 : _j.arguments) != null) {
|
|
570
|
+
toolCall.function.arguments += (_l = (_k = toolCallDelta.function) == null ? void 0 : _k.arguments) != null ? _l : "";
|
|
520
571
|
}
|
|
521
572
|
controller.enqueue({
|
|
522
|
-
type: "tool-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
toolName: toolCall.function.name,
|
|
526
|
-
argsTextDelta: (_l = toolCallDelta.function.arguments) != null ? _l : ""
|
|
573
|
+
type: "tool-input-delta",
|
|
574
|
+
id: toolCall.id,
|
|
575
|
+
delta: (_m = toolCallDelta.function.arguments) != null ? _m : ""
|
|
527
576
|
});
|
|
528
|
-
if (((
|
|
577
|
+
if (((_n = toolCall.function) == null ? void 0 : _n.name) != null && ((_o = toolCall.function) == null ? void 0 : _o.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
578
|
+
controller.enqueue({
|
|
579
|
+
type: "tool-input-end",
|
|
580
|
+
id: toolCall.id
|
|
581
|
+
});
|
|
529
582
|
controller.enqueue({
|
|
530
583
|
type: "tool-call",
|
|
531
|
-
|
|
532
|
-
toolCallId: (_o = toolCall.id) != null ? _o : generateId(),
|
|
584
|
+
toolCallId: (_p = toolCall.id) != null ? _p : generateId(),
|
|
533
585
|
toolName: toolCall.function.name,
|
|
534
|
-
|
|
586
|
+
input: toolCall.function.arguments
|
|
535
587
|
});
|
|
536
588
|
toolCall.hasFinished = true;
|
|
537
589
|
}
|
|
@@ -539,6 +591,12 @@ var GroqChatLanguageModel = class {
|
|
|
539
591
|
}
|
|
540
592
|
},
|
|
541
593
|
flush(controller) {
|
|
594
|
+
if (isActiveReasoning) {
|
|
595
|
+
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
596
|
+
}
|
|
597
|
+
if (isActiveText) {
|
|
598
|
+
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
599
|
+
}
|
|
542
600
|
controller.enqueue({
|
|
543
601
|
type: "finish",
|
|
544
602
|
finishReason,
|
|
@@ -579,7 +637,8 @@ var groqChatResponseSchema = z3.object({
|
|
|
579
637
|
),
|
|
580
638
|
usage: z3.object({
|
|
581
639
|
prompt_tokens: z3.number().nullish(),
|
|
582
|
-
completion_tokens: z3.number().nullish()
|
|
640
|
+
completion_tokens: z3.number().nullish(),
|
|
641
|
+
total_tokens: z3.number().nullish()
|
|
583
642
|
}).nullish()
|
|
584
643
|
});
|
|
585
644
|
var groqChatChunkSchema = z3.union([
|
|
@@ -611,7 +670,8 @@ var groqChatChunkSchema = z3.union([
|
|
|
611
670
|
x_groq: z3.object({
|
|
612
671
|
usage: z3.object({
|
|
613
672
|
prompt_tokens: z3.number().nullish(),
|
|
614
|
-
completion_tokens: z3.number().nullish()
|
|
673
|
+
completion_tokens: z3.number().nullish(),
|
|
674
|
+
total_tokens: z3.number().nullish()
|
|
615
675
|
}).nullish()
|
|
616
676
|
}).nullish()
|
|
617
677
|
}),
|
|
@@ -626,7 +686,7 @@ import {
|
|
|
626
686
|
parseProviderOptions as parseProviderOptions2,
|
|
627
687
|
postFormDataToApi
|
|
628
688
|
} from "@ai-sdk/provider-utils";
|
|
629
|
-
import { z as z4 } from "zod";
|
|
689
|
+
import { z as z4 } from "zod/v4";
|
|
630
690
|
var groqProviderOptionsSchema = z4.object({
|
|
631
691
|
language: z4.string().nullish(),
|
|
632
692
|
prompt: z4.string().nullish(),
|
|
@@ -638,19 +698,19 @@ var GroqTranscriptionModel = class {
|
|
|
638
698
|
constructor(modelId, config) {
|
|
639
699
|
this.modelId = modelId;
|
|
640
700
|
this.config = config;
|
|
641
|
-
this.specificationVersion = "
|
|
701
|
+
this.specificationVersion = "v2";
|
|
642
702
|
}
|
|
643
703
|
get provider() {
|
|
644
704
|
return this.config.provider;
|
|
645
705
|
}
|
|
646
|
-
getArgs({
|
|
706
|
+
async getArgs({
|
|
647
707
|
audio,
|
|
648
708
|
mediaType,
|
|
649
709
|
providerOptions
|
|
650
710
|
}) {
|
|
651
711
|
var _a, _b, _c, _d, _e;
|
|
652
712
|
const warnings = [];
|
|
653
|
-
const groqOptions = parseProviderOptions2({
|
|
713
|
+
const groqOptions = await parseProviderOptions2({
|
|
654
714
|
provider: "groq",
|
|
655
715
|
providerOptions,
|
|
656
716
|
schema: groqProviderOptionsSchema
|
|
@@ -682,7 +742,7 @@ var GroqTranscriptionModel = class {
|
|
|
682
742
|
async doGenerate(options) {
|
|
683
743
|
var _a, _b, _c, _d, _e;
|
|
684
744
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
685
|
-
const { formData, warnings } = this.getArgs(options);
|
|
745
|
+
const { formData, warnings } = await this.getArgs(options);
|
|
686
746
|
const {
|
|
687
747
|
value: response,
|
|
688
748
|
responseHeaders,
|
|
@@ -756,19 +816,19 @@ function createGroq(options = {}) {
|
|
|
756
816
|
})}`,
|
|
757
817
|
...options.headers
|
|
758
818
|
});
|
|
759
|
-
const createChatModel = (modelId
|
|
819
|
+
const createChatModel = (modelId) => new GroqChatLanguageModel(modelId, {
|
|
760
820
|
provider: "groq.chat",
|
|
761
821
|
url: ({ path }) => `${baseURL}${path}`,
|
|
762
822
|
headers: getHeaders,
|
|
763
823
|
fetch: options.fetch
|
|
764
824
|
});
|
|
765
|
-
const createLanguageModel = (modelId
|
|
825
|
+
const createLanguageModel = (modelId) => {
|
|
766
826
|
if (new.target) {
|
|
767
827
|
throw new Error(
|
|
768
828
|
"The Groq model function cannot be called with the new keyword."
|
|
769
829
|
);
|
|
770
830
|
}
|
|
771
|
-
return createChatModel(modelId
|
|
831
|
+
return createChatModel(modelId);
|
|
772
832
|
};
|
|
773
833
|
const createTranscriptionModel = (modelId) => {
|
|
774
834
|
return new GroqTranscriptionModel(modelId, {
|
|
@@ -778,8 +838,8 @@ function createGroq(options = {}) {
|
|
|
778
838
|
fetch: options.fetch
|
|
779
839
|
});
|
|
780
840
|
};
|
|
781
|
-
const provider = function(modelId
|
|
782
|
-
return createLanguageModel(modelId
|
|
841
|
+
const provider = function(modelId) {
|
|
842
|
+
return createLanguageModel(modelId);
|
|
783
843
|
};
|
|
784
844
|
provider.languageModel = createLanguageModel;
|
|
785
845
|
provider.chat = createChatModel;
|