@ai-sdk/groq 4.0.0-beta.2 → 4.0.0-beta.21
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 +149 -4
- package/README.md +2 -0
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -8
- package/dist/index.mjs.map +1 -1
- package/docs/09-groq.mdx +3 -2
- package/package.json +3 -5
- package/src/convert-groq-usage.ts +2 -2
- package/src/convert-to-groq-chat-messages.ts +9 -3
- package/src/groq-chat-language-model.ts +39 -22
- package/src/groq-chat-options.ts +2 -1
- package/src/groq-prepare-tools.ts +6 -6
- package/src/groq-provider.ts +8 -8
- package/src/groq-transcription-model.ts +7 -7
- package/src/map-groq-finish-reason.ts +2 -2
package/src/groq-provider.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
LanguageModelV4,
|
|
3
3
|
NoSuchModelError,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
ProviderV4,
|
|
5
|
+
TranscriptionModelV4,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
8
|
FetchFunction,
|
|
@@ -17,21 +17,21 @@ import { GroqTranscriptionModel } from './groq-transcription-model';
|
|
|
17
17
|
|
|
18
18
|
import { groqTools } from './groq-tools';
|
|
19
19
|
import { VERSION } from './version';
|
|
20
|
-
export interface GroqProvider extends
|
|
20
|
+
export interface GroqProvider extends ProviderV4 {
|
|
21
21
|
/**
|
|
22
22
|
* Creates a model for text generation.
|
|
23
23
|
*/
|
|
24
|
-
(modelId: GroqChatModelId):
|
|
24
|
+
(modelId: GroqChatModelId): LanguageModelV4;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Creates an Groq chat model for text generation.
|
|
28
28
|
*/
|
|
29
|
-
languageModel(modelId: GroqChatModelId):
|
|
29
|
+
languageModel(modelId: GroqChatModelId): LanguageModelV4;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Creates a model for transcription.
|
|
33
33
|
*/
|
|
34
|
-
transcription(modelId: GroqTranscriptionModelId):
|
|
34
|
+
transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV4;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Tools provided by Groq.
|
|
@@ -118,7 +118,7 @@ export function createGroq(options: GroqProviderSettings = {}): GroqProvider {
|
|
|
118
118
|
return createLanguageModel(modelId);
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
provider.specificationVersion = '
|
|
121
|
+
provider.specificationVersion = 'v4' as const;
|
|
122
122
|
provider.languageModel = createLanguageModel;
|
|
123
123
|
provider.chat = createChatModel;
|
|
124
124
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TranscriptionModelV4, SharedV4Warning } from '@ai-sdk/provider';
|
|
2
2
|
import {
|
|
3
3
|
combineHeaders,
|
|
4
4
|
convertBase64ToUint8Array,
|
|
@@ -22,8 +22,8 @@ interface GroqTranscriptionModelConfig extends GroqConfig {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export class GroqTranscriptionModel implements
|
|
26
|
-
readonly specificationVersion = '
|
|
25
|
+
export class GroqTranscriptionModel implements TranscriptionModelV4 {
|
|
26
|
+
readonly specificationVersion = 'v4';
|
|
27
27
|
|
|
28
28
|
get provider(): string {
|
|
29
29
|
return this.config.provider;
|
|
@@ -38,8 +38,8 @@ export class GroqTranscriptionModel implements TranscriptionModelV3 {
|
|
|
38
38
|
audio,
|
|
39
39
|
mediaType,
|
|
40
40
|
providerOptions,
|
|
41
|
-
}: Parameters<
|
|
42
|
-
const warnings:
|
|
41
|
+
}: Parameters<TranscriptionModelV4['doGenerate']>[0]) {
|
|
42
|
+
const warnings: SharedV4Warning[] = [];
|
|
43
43
|
|
|
44
44
|
// Parse provider options
|
|
45
45
|
const groqOptions = await parseProviderOptions({
|
|
@@ -101,8 +101,8 @@ export class GroqTranscriptionModel implements TranscriptionModelV3 {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
async doGenerate(
|
|
104
|
-
options: Parameters<
|
|
105
|
-
): Promise<Awaited<ReturnType<
|
|
104
|
+
options: Parameters<TranscriptionModelV4['doGenerate']>[0],
|
|
105
|
+
): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {
|
|
106
106
|
const currentDate = this.config._internal?.currentDate?.() ?? new Date();
|
|
107
107
|
const { formData, warnings } = await this.getArgs(options);
|
|
108
108
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV4FinishReason } from '@ai-sdk/provider';
|
|
2
2
|
|
|
3
3
|
export function mapGroqFinishReason(
|
|
4
4
|
finishReason: string | null | undefined,
|
|
5
|
-
):
|
|
5
|
+
): LanguageModelV4FinishReason['unified'] {
|
|
6
6
|
switch (finishReason) {
|
|
7
7
|
case 'stop':
|
|
8
8
|
return 'stop';
|