@ai-sdk/groq 4.0.0-beta.5 → 4.0.0-beta.55
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 +414 -4
- package/README.md +3 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +266 -292
- package/dist/index.js.map +1 -1
- package/docs/09-groq.mdx +15 -14
- package/package.json +14 -14
- package/src/convert-groq-usage.ts +1 -1
- package/src/convert-to-groq-chat-messages.ts +37 -21
- package/src/groq-browser-search-models.ts +1 -1
- package/src/{groq-chat-options.ts → groq-chat-language-model-options.ts} +6 -3
- package/src/groq-chat-language-model.ts +61 -149
- package/src/groq-config.ts +2 -2
- package/src/groq-prepare-tools.ts +3 -3
- package/src/groq-provider.ts +6 -6
- package/src/{groq-transcription-options.ts → groq-transcription-model-options.ts} +5 -1
- package/src/groq-transcription-model.ts +23 -6
- package/src/index.ts +7 -5
- package/src/map-groq-finish-reason.ts +1 -1
- package/src/tool/browser-search.ts +11 -3
- package/dist/index.d.mts +0 -112
- package/dist/index.mjs +0 -1049
- package/dist/index.mjs.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InvalidResponseDataError,
|
|
1
|
+
import type {
|
|
3
2
|
LanguageModelV4,
|
|
4
3
|
LanguageModelV4CallOptions,
|
|
5
4
|
LanguageModelV4Content,
|
|
@@ -11,28 +10,36 @@ import {
|
|
|
11
10
|
SharedV4Warning,
|
|
12
11
|
} from '@ai-sdk/provider';
|
|
13
12
|
import {
|
|
14
|
-
|
|
15
|
-
ParseResult,
|
|
13
|
+
StreamingToolCallTracker,
|
|
16
14
|
combineHeaders,
|
|
17
15
|
createEventSourceResponseHandler,
|
|
18
16
|
createJsonResponseHandler,
|
|
19
17
|
generateId,
|
|
20
|
-
|
|
18
|
+
isCustomReasoning,
|
|
19
|
+
mapReasoningToProviderEffort,
|
|
21
20
|
parseProviderOptions,
|
|
22
21
|
postJsonToApi,
|
|
22
|
+
serializeModelOptions,
|
|
23
|
+
WORKFLOW_SERIALIZE,
|
|
24
|
+
WORKFLOW_DESERIALIZE,
|
|
25
|
+
type FetchFunction,
|
|
26
|
+
type ParseResult,
|
|
23
27
|
} from '@ai-sdk/provider-utils';
|
|
24
28
|
import { z } from 'zod/v4';
|
|
25
29
|
import { convertGroqUsage } from './convert-groq-usage';
|
|
26
30
|
import { convertToGroqChatMessages } from './convert-to-groq-chat-messages';
|
|
27
31
|
import { getResponseMetadata } from './get-response-metadata';
|
|
28
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
groqLanguageModelChatOptions,
|
|
34
|
+
type GroqChatModelId,
|
|
35
|
+
} from './groq-chat-language-model-options';
|
|
29
36
|
import { groqErrorDataSchema, groqFailedResponseHandler } from './groq-error';
|
|
30
37
|
import { prepareTools } from './groq-prepare-tools';
|
|
31
38
|
import { mapGroqFinishReason } from './map-groq-finish-reason';
|
|
32
39
|
|
|
33
40
|
type GroqChatConfig = {
|
|
34
41
|
provider: string;
|
|
35
|
-
headers
|
|
42
|
+
headers?: () => Record<string, string | undefined>;
|
|
36
43
|
url: (options: { modelId: string; path: string }) => string;
|
|
37
44
|
fetch?: FetchFunction;
|
|
38
45
|
};
|
|
@@ -48,6 +55,20 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
48
55
|
|
|
49
56
|
private readonly config: GroqChatConfig;
|
|
50
57
|
|
|
58
|
+
static [WORKFLOW_SERIALIZE](model: GroqChatLanguageModel) {
|
|
59
|
+
return serializeModelOptions({
|
|
60
|
+
modelId: model.modelId,
|
|
61
|
+
config: model.config,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
66
|
+
modelId: GroqChatModelId;
|
|
67
|
+
config: GroqChatConfig;
|
|
68
|
+
}) {
|
|
69
|
+
return new GroqChatLanguageModel(options.modelId, options.config);
|
|
70
|
+
}
|
|
71
|
+
|
|
51
72
|
constructor(modelId: GroqChatModelId, config: GroqChatConfig) {
|
|
52
73
|
this.modelId = modelId;
|
|
53
74
|
this.config = config;
|
|
@@ -68,19 +89,17 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
68
89
|
stopSequences,
|
|
69
90
|
responseFormat,
|
|
70
91
|
seed,
|
|
71
|
-
|
|
92
|
+
reasoning,
|
|
72
93
|
tools,
|
|
73
94
|
toolChoice,
|
|
74
95
|
providerOptions,
|
|
75
|
-
}: LanguageModelV4CallOptions
|
|
76
|
-
stream: boolean;
|
|
77
|
-
}) {
|
|
96
|
+
}: LanguageModelV4CallOptions) {
|
|
78
97
|
const warnings: SharedV4Warning[] = [];
|
|
79
98
|
|
|
80
99
|
const groqOptions = await parseProviderOptions({
|
|
81
100
|
provider: 'groq',
|
|
82
101
|
providerOptions,
|
|
83
|
-
schema:
|
|
102
|
+
schema: groqLanguageModelChatOptions,
|
|
84
103
|
});
|
|
85
104
|
|
|
86
105
|
const structuredOutputs = groqOptions?.structuredOutputs ?? true;
|
|
@@ -145,7 +164,21 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
145
164
|
|
|
146
165
|
// provider options:
|
|
147
166
|
reasoning_format: groqOptions?.reasoningFormat,
|
|
148
|
-
reasoning_effort:
|
|
167
|
+
reasoning_effort:
|
|
168
|
+
groqOptions?.reasoningEffort ??
|
|
169
|
+
(isCustomReasoning(reasoning) && reasoning !== 'none'
|
|
170
|
+
? mapReasoningToProviderEffort({
|
|
171
|
+
reasoning,
|
|
172
|
+
effortMap: {
|
|
173
|
+
minimal: 'low',
|
|
174
|
+
low: 'low',
|
|
175
|
+
medium: 'medium',
|
|
176
|
+
high: 'high',
|
|
177
|
+
xhigh: 'high',
|
|
178
|
+
},
|
|
179
|
+
warnings,
|
|
180
|
+
})
|
|
181
|
+
: undefined),
|
|
149
182
|
service_tier: groqOptions?.serviceTier,
|
|
150
183
|
|
|
151
184
|
// messages:
|
|
@@ -162,10 +195,7 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
162
195
|
async doGenerate(
|
|
163
196
|
options: LanguageModelV4CallOptions,
|
|
164
197
|
): Promise<LanguageModelV4GenerateResult> {
|
|
165
|
-
const { args, warnings } = await this.getArgs(
|
|
166
|
-
...options,
|
|
167
|
-
stream: false,
|
|
168
|
-
});
|
|
198
|
+
const { args, warnings } = await this.getArgs(options);
|
|
169
199
|
|
|
170
200
|
const body = JSON.stringify(args);
|
|
171
201
|
|
|
@@ -178,7 +208,7 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
178
208
|
path: '/chat/completions',
|
|
179
209
|
modelId: this.modelId,
|
|
180
210
|
}),
|
|
181
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
211
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
182
212
|
body: args,
|
|
183
213
|
failedResponseHandler: groqFailedResponseHandler,
|
|
184
214
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -238,20 +268,17 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
238
268
|
async doStream(
|
|
239
269
|
options: LanguageModelV4CallOptions,
|
|
240
270
|
): Promise<LanguageModelV4StreamResult> {
|
|
241
|
-
const { args, warnings } = await this.getArgs(
|
|
271
|
+
const { args, warnings } = await this.getArgs(options);
|
|
242
272
|
|
|
243
|
-
const body =
|
|
273
|
+
const body = { ...args, stream: true };
|
|
244
274
|
|
|
245
275
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
246
276
|
url: this.config.url({
|
|
247
277
|
path: '/chat/completions',
|
|
248
278
|
modelId: this.modelId,
|
|
249
279
|
}),
|
|
250
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
251
|
-
body
|
|
252
|
-
...args,
|
|
253
|
-
stream: true,
|
|
254
|
-
},
|
|
280
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
281
|
+
body,
|
|
255
282
|
failedResponseHandler: groqFailedResponseHandler,
|
|
256
283
|
successfulResponseHandler:
|
|
257
284
|
createEventSourceResponseHandler(groqChatChunkSchema),
|
|
@@ -259,15 +286,7 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
259
286
|
fetch: this.config.fetch,
|
|
260
287
|
});
|
|
261
288
|
|
|
262
|
-
|
|
263
|
-
id: string;
|
|
264
|
-
type: 'function';
|
|
265
|
-
function: {
|
|
266
|
-
name: string;
|
|
267
|
-
arguments: string;
|
|
268
|
-
};
|
|
269
|
-
hasFinished: boolean;
|
|
270
|
-
}> = [];
|
|
289
|
+
let toolCallTracker: StreamingToolCallTracker;
|
|
271
290
|
|
|
272
291
|
let finishReason: LanguageModelV4FinishReason = {
|
|
273
292
|
unified: 'other',
|
|
@@ -303,6 +322,10 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
303
322
|
LanguageModelV4StreamPart
|
|
304
323
|
>({
|
|
305
324
|
start(controller) {
|
|
325
|
+
toolCallTracker = new StreamingToolCallTracker(controller, {
|
|
326
|
+
generateId,
|
|
327
|
+
typeValidation: 'required',
|
|
328
|
+
});
|
|
306
329
|
controller.enqueue({ type: 'stream-start', warnings });
|
|
307
330
|
},
|
|
308
331
|
|
|
@@ -411,120 +434,7 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
411
434
|
}
|
|
412
435
|
|
|
413
436
|
for (const toolCallDelta of delta.tool_calls) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (toolCalls[index] == null) {
|
|
417
|
-
if (toolCallDelta.type !== 'function') {
|
|
418
|
-
throw new InvalidResponseDataError({
|
|
419
|
-
data: toolCallDelta,
|
|
420
|
-
message: `Expected 'function' type.`,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (toolCallDelta.id == null) {
|
|
425
|
-
throw new InvalidResponseDataError({
|
|
426
|
-
data: toolCallDelta,
|
|
427
|
-
message: `Expected 'id' to be a string.`,
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (toolCallDelta.function?.name == null) {
|
|
432
|
-
throw new InvalidResponseDataError({
|
|
433
|
-
data: toolCallDelta,
|
|
434
|
-
message: `Expected 'function.name' to be a string.`,
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
controller.enqueue({
|
|
439
|
-
type: 'tool-input-start',
|
|
440
|
-
id: toolCallDelta.id,
|
|
441
|
-
toolName: toolCallDelta.function.name,
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
toolCalls[index] = {
|
|
445
|
-
id: toolCallDelta.id,
|
|
446
|
-
type: 'function',
|
|
447
|
-
function: {
|
|
448
|
-
name: toolCallDelta.function.name,
|
|
449
|
-
arguments: toolCallDelta.function.arguments ?? '',
|
|
450
|
-
},
|
|
451
|
-
hasFinished: false,
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
const toolCall = toolCalls[index];
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
toolCall.function?.name != null &&
|
|
458
|
-
toolCall.function?.arguments != null
|
|
459
|
-
) {
|
|
460
|
-
// send delta if the argument text has already started:
|
|
461
|
-
if (toolCall.function.arguments.length > 0) {
|
|
462
|
-
controller.enqueue({
|
|
463
|
-
type: 'tool-input-delta',
|
|
464
|
-
id: toolCall.id,
|
|
465
|
-
delta: toolCall.function.arguments,
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// check if tool call is complete
|
|
470
|
-
// (some providers send the full tool call in one chunk):
|
|
471
|
-
if (isParsableJson(toolCall.function.arguments)) {
|
|
472
|
-
controller.enqueue({
|
|
473
|
-
type: 'tool-input-end',
|
|
474
|
-
id: toolCall.id,
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
controller.enqueue({
|
|
478
|
-
type: 'tool-call',
|
|
479
|
-
toolCallId: toolCall.id ?? generateId(),
|
|
480
|
-
toolName: toolCall.function.name,
|
|
481
|
-
input: toolCall.function.arguments,
|
|
482
|
-
});
|
|
483
|
-
toolCall.hasFinished = true;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// existing tool call, merge if not finished
|
|
491
|
-
const toolCall = toolCalls[index];
|
|
492
|
-
|
|
493
|
-
if (toolCall.hasFinished) {
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
if (toolCallDelta.function?.arguments != null) {
|
|
498
|
-
toolCall.function!.arguments +=
|
|
499
|
-
toolCallDelta.function?.arguments ?? '';
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// send delta
|
|
503
|
-
controller.enqueue({
|
|
504
|
-
type: 'tool-input-delta',
|
|
505
|
-
id: toolCall.id,
|
|
506
|
-
delta: toolCallDelta.function.arguments ?? '',
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
// check if tool call is complete
|
|
510
|
-
if (
|
|
511
|
-
toolCall.function?.name != null &&
|
|
512
|
-
toolCall.function?.arguments != null &&
|
|
513
|
-
isParsableJson(toolCall.function.arguments)
|
|
514
|
-
) {
|
|
515
|
-
controller.enqueue({
|
|
516
|
-
type: 'tool-input-end',
|
|
517
|
-
id: toolCall.id,
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
controller.enqueue({
|
|
521
|
-
type: 'tool-call',
|
|
522
|
-
toolCallId: toolCall.id ?? generateId(),
|
|
523
|
-
toolName: toolCall.function.name,
|
|
524
|
-
input: toolCall.function.arguments,
|
|
525
|
-
});
|
|
526
|
-
toolCall.hasFinished = true;
|
|
527
|
-
}
|
|
437
|
+
toolCallTracker.processDelta(toolCallDelta);
|
|
528
438
|
}
|
|
529
439
|
}
|
|
530
440
|
},
|
|
@@ -538,6 +448,8 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
538
448
|
controller.enqueue({ type: 'text-end', id: 'txt-0' });
|
|
539
449
|
}
|
|
540
450
|
|
|
451
|
+
toolCallTracker.flush();
|
|
452
|
+
|
|
541
453
|
controller.enqueue({
|
|
542
454
|
type: 'finish',
|
|
543
455
|
finishReason,
|
|
@@ -547,7 +459,7 @@ export class GroqChatLanguageModel implements LanguageModelV4 {
|
|
|
547
459
|
},
|
|
548
460
|
}),
|
|
549
461
|
),
|
|
550
|
-
request: { body },
|
|
462
|
+
request: { body: JSON.stringify(body) },
|
|
551
463
|
response: { headers: responseHeaders },
|
|
552
464
|
};
|
|
553
465
|
}
|
package/src/groq-config.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
1
|
+
import type { FetchFunction } from '@ai-sdk/provider-utils';
|
|
2
2
|
|
|
3
3
|
export type GroqConfig = {
|
|
4
4
|
provider: string;
|
|
5
5
|
url: (options: { modelId: string; path: string }) => string;
|
|
6
|
-
headers
|
|
6
|
+
headers?: () => Record<string, string | undefined>;
|
|
7
7
|
fetch?: FetchFunction;
|
|
8
8
|
generateId?: () => string;
|
|
9
9
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LanguageModelV4CallOptions,
|
|
3
|
-
SharedV4Warning,
|
|
4
2
|
UnsupportedFunctionalityError,
|
|
3
|
+
type LanguageModelV4CallOptions,
|
|
4
|
+
type SharedV4Warning,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import {
|
|
7
7
|
getSupportedModelsString,
|
|
8
8
|
isBrowserSearchSupportedModel,
|
|
9
9
|
} from './groq-browser-search-models';
|
|
10
|
-
import { GroqChatModelId } from './groq-chat-options';
|
|
10
|
+
import type { GroqChatModelId } from './groq-chat-language-model-options';
|
|
11
11
|
|
|
12
12
|
export function prepareTools({
|
|
13
13
|
tools,
|
package/src/groq-provider.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LanguageModelV4,
|
|
3
2
|
NoSuchModelError,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type LanguageModelV4,
|
|
4
|
+
type ProviderV4,
|
|
5
|
+
type TranscriptionModelV4,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
|
-
FetchFunction,
|
|
9
8
|
loadApiKey,
|
|
10
9
|
withoutTrailingSlash,
|
|
11
10
|
withUserAgentSuffix,
|
|
11
|
+
type FetchFunction,
|
|
12
12
|
} from '@ai-sdk/provider-utils';
|
|
13
13
|
import { GroqChatLanguageModel } from './groq-chat-language-model';
|
|
14
|
-
import { GroqChatModelId } from './groq-chat-options';
|
|
15
|
-
import { GroqTranscriptionModelId } from './groq-transcription-options';
|
|
14
|
+
import type { GroqChatModelId } from './groq-chat-language-model-options';
|
|
15
|
+
import type { GroqTranscriptionModelId } from './groq-transcription-model-options';
|
|
16
16
|
import { GroqTranscriptionModel } from './groq-transcription-model';
|
|
17
17
|
|
|
18
18
|
import { groqTools } from './groq-tools';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranscriptionModelV4, SharedV4Warning } from '@ai-sdk/provider';
|
|
1
|
+
import type { TranscriptionModelV4, SharedV4Warning } from '@ai-sdk/provider';
|
|
2
2
|
import {
|
|
3
3
|
combineHeaders,
|
|
4
4
|
convertBase64ToUint8Array,
|
|
@@ -6,15 +6,18 @@ import {
|
|
|
6
6
|
mediaTypeToExtension,
|
|
7
7
|
parseProviderOptions,
|
|
8
8
|
postFormDataToApi,
|
|
9
|
+
serializeModelOptions,
|
|
10
|
+
WORKFLOW_SERIALIZE,
|
|
11
|
+
WORKFLOW_DESERIALIZE,
|
|
9
12
|
} from '@ai-sdk/provider-utils';
|
|
10
13
|
import { z } from 'zod/v4';
|
|
11
|
-
import { GroqConfig } from './groq-config';
|
|
14
|
+
import type { GroqConfig } from './groq-config';
|
|
12
15
|
import { groqFailedResponseHandler } from './groq-error';
|
|
13
16
|
import {
|
|
14
|
-
GroqTranscriptionModelId,
|
|
15
17
|
groqTranscriptionModelOptions,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
type GroqTranscriptionModelId,
|
|
19
|
+
} from './groq-transcription-model-options';
|
|
20
|
+
import type { GroqTranscriptionAPITypes } from './groq-api-types';
|
|
18
21
|
|
|
19
22
|
interface GroqTranscriptionModelConfig extends GroqConfig {
|
|
20
23
|
_internal?: {
|
|
@@ -29,6 +32,20 @@ export class GroqTranscriptionModel implements TranscriptionModelV4 {
|
|
|
29
32
|
return this.config.provider;
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
static [WORKFLOW_SERIALIZE](model: GroqTranscriptionModel) {
|
|
36
|
+
return serializeModelOptions({
|
|
37
|
+
modelId: model.modelId,
|
|
38
|
+
config: model.config,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
43
|
+
modelId: GroqTranscriptionModelId;
|
|
44
|
+
config: GroqTranscriptionModelConfig;
|
|
45
|
+
}) {
|
|
46
|
+
return new GroqTranscriptionModel(options.modelId, options.config);
|
|
47
|
+
}
|
|
48
|
+
|
|
32
49
|
constructor(
|
|
33
50
|
readonly modelId: GroqTranscriptionModelId,
|
|
34
51
|
private readonly config: GroqTranscriptionModelConfig,
|
|
@@ -115,7 +132,7 @@ export class GroqTranscriptionModel implements TranscriptionModelV4 {
|
|
|
115
132
|
path: '/audio/transcriptions',
|
|
116
133
|
modelId: this.modelId,
|
|
117
134
|
}),
|
|
118
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
135
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
119
136
|
formData,
|
|
120
137
|
failedResponseHandler: groqFailedResponseHandler,
|
|
121
138
|
successfulResponseHandler: createJsonResponseHandler(
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { createGroq, groq } from './groq-provider';
|
|
2
2
|
export type { GroqProvider, GroqProviderSettings } from './groq-provider';
|
|
3
3
|
export type {
|
|
4
|
-
|
|
5
|
-
/** @deprecated Use `
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
GroqLanguageModelChatOptions,
|
|
5
|
+
/** @deprecated Use `GroqLanguageModelChatOptions` instead. */
|
|
6
|
+
GroqLanguageModelChatOptions as GroqLanguageModelOptions,
|
|
7
|
+
/** @deprecated Use `GroqLanguageModelChatOptions` instead. */
|
|
8
|
+
GroqLanguageModelChatOptions as GroqProviderOptions,
|
|
9
|
+
} from './groq-chat-language-model-options';
|
|
10
|
+
export type { GroqTranscriptionModelOptions } from './groq-transcription-model-options';
|
|
9
11
|
export { browserSearch } from './tool/browser-search';
|
|
10
12
|
export { VERSION } from './version';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
2
6
|
import { z } from 'zod/v4';
|
|
3
7
|
|
|
4
8
|
/**
|
|
@@ -13,16 +17,20 @@ import { z } from 'zod/v4';
|
|
|
13
17
|
*
|
|
14
18
|
* @see https://console.groq.com/docs/browser-search
|
|
15
19
|
*/
|
|
16
|
-
export const browserSearch =
|
|
20
|
+
export const browserSearch = createProviderExecutedToolFactory<
|
|
17
21
|
{
|
|
18
22
|
// Browser search doesn't take input parameters - it's controlled by the prompt
|
|
19
23
|
// The tool is activated automatically when included in the tools array
|
|
20
24
|
},
|
|
25
|
+
{
|
|
26
|
+
// Browser search doesn't have any output parameters
|
|
27
|
+
},
|
|
21
28
|
{
|
|
22
29
|
// No configuration options needed - the tool works automatically
|
|
23
30
|
// when included in the tools array for supported models
|
|
24
31
|
}
|
|
25
32
|
>({
|
|
26
33
|
id: 'groq.browser_search',
|
|
27
|
-
inputSchema: z.object({}),
|
|
34
|
+
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
35
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
28
36
|
});
|
package/dist/index.d.mts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { ProviderV4, LanguageModelV4, TranscriptionModelV4 } from '@ai-sdk/provider';
|
|
2
|
-
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
-
import { z } from 'zod/v4';
|
|
5
|
-
|
|
6
|
-
type GroqChatModelId = 'gemma2-9b-it' | 'llama-3.1-8b-instant' | 'llama-3.3-70b-versatile' | 'meta-llama/llama-guard-4-12b' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'deepseek-r1-distill-llama-70b' | 'meta-llama/llama-4-maverick-17b-128e-instruct' | 'meta-llama/llama-4-scout-17b-16e-instruct' | 'meta-llama/llama-prompt-guard-2-22m' | 'meta-llama/llama-prompt-guard-2-86m' | 'moonshotai/kimi-k2-instruct-0905' | 'qwen/qwen3-32b' | 'llama-guard-3-8b' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | 'qwen-qwq-32b' | 'qwen-2.5-32b' | 'deepseek-r1-distill-qwen-32b' | (string & {});
|
|
7
|
-
declare const groqLanguageModelOptions: z.ZodObject<{
|
|
8
|
-
reasoningFormat: z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
parsed: "parsed";
|
|
10
|
-
raw: "raw";
|
|
11
|
-
hidden: "hidden";
|
|
12
|
-
}>>;
|
|
13
|
-
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
14
|
-
none: "none";
|
|
15
|
-
default: "default";
|
|
16
|
-
low: "low";
|
|
17
|
-
medium: "medium";
|
|
18
|
-
high: "high";
|
|
19
|
-
}>>;
|
|
20
|
-
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
-
user: z.ZodOptional<z.ZodString>;
|
|
22
|
-
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
-
strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
-
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
25
|
-
on_demand: "on_demand";
|
|
26
|
-
flex: "flex";
|
|
27
|
-
auto: "auto";
|
|
28
|
-
}>>;
|
|
29
|
-
}, z.core.$strip>;
|
|
30
|
-
type GroqLanguageModelOptions = z.infer<typeof groqLanguageModelOptions>;
|
|
31
|
-
|
|
32
|
-
type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'whisper-large-v3' | (string & {});
|
|
33
|
-
declare const groqTranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
34
|
-
language?: string | null | undefined;
|
|
35
|
-
prompt?: string | null | undefined;
|
|
36
|
-
responseFormat?: string | null | undefined;
|
|
37
|
-
temperature?: number | null | undefined;
|
|
38
|
-
timestampGranularities?: string[] | null | undefined;
|
|
39
|
-
}>;
|
|
40
|
-
type GroqTranscriptionModelOptions = InferSchema<typeof groqTranscriptionModelOptions>;
|
|
41
|
-
|
|
42
|
-
declare const groqTools: {
|
|
43
|
-
browserSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
interface GroqProvider extends ProviderV4 {
|
|
47
|
-
/**
|
|
48
|
-
* Creates a model for text generation.
|
|
49
|
-
*/
|
|
50
|
-
(modelId: GroqChatModelId): LanguageModelV4;
|
|
51
|
-
/**
|
|
52
|
-
* Creates an Groq chat model for text generation.
|
|
53
|
-
*/
|
|
54
|
-
languageModel(modelId: GroqChatModelId): LanguageModelV4;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a model for transcription.
|
|
57
|
-
*/
|
|
58
|
-
transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV4;
|
|
59
|
-
/**
|
|
60
|
-
* Tools provided by Groq.
|
|
61
|
-
*/
|
|
62
|
-
tools: typeof groqTools;
|
|
63
|
-
/**
|
|
64
|
-
* @deprecated Use `embeddingModel` instead.
|
|
65
|
-
*/
|
|
66
|
-
textEmbeddingModel(modelId: string): never;
|
|
67
|
-
}
|
|
68
|
-
interface GroqProviderSettings {
|
|
69
|
-
/**
|
|
70
|
-
* Base URL for the Groq API calls.
|
|
71
|
-
*/
|
|
72
|
-
baseURL?: string;
|
|
73
|
-
/**
|
|
74
|
-
* API key for authenticating requests.
|
|
75
|
-
*/
|
|
76
|
-
apiKey?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Custom headers to include in the requests.
|
|
79
|
-
*/
|
|
80
|
-
headers?: Record<string, string>;
|
|
81
|
-
/**
|
|
82
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
83
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
84
|
-
*/
|
|
85
|
-
fetch?: FetchFunction;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Create an Groq provider instance.
|
|
89
|
-
*/
|
|
90
|
-
declare function createGroq(options?: GroqProviderSettings): GroqProvider;
|
|
91
|
-
/**
|
|
92
|
-
* Default Groq provider instance.
|
|
93
|
-
*/
|
|
94
|
-
declare const groq: GroqProvider;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Browser search tool for Groq models.
|
|
98
|
-
*
|
|
99
|
-
* Provides interactive browser search capabilities that go beyond traditional web search
|
|
100
|
-
* by navigating websites interactively and providing more detailed results.
|
|
101
|
-
*
|
|
102
|
-
* Currently supported on:
|
|
103
|
-
* - openai/gpt-oss-20b
|
|
104
|
-
* - openai/gpt-oss-120b
|
|
105
|
-
*
|
|
106
|
-
* @see https://console.groq.com/docs/browser-search
|
|
107
|
-
*/
|
|
108
|
-
declare const browserSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
|
|
109
|
-
|
|
110
|
-
declare const VERSION: string;
|
|
111
|
-
|
|
112
|
-
export { type GroqLanguageModelOptions, type GroqProvider, type GroqLanguageModelOptions as GroqProviderOptions, type GroqProviderSettings, type GroqTranscriptionModelOptions, VERSION, browserSearch, createGroq, groq };
|