@ai-sdk/google 4.0.35 → 4.0.37
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 +14 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/google-provider.ts +13 -9
- package/src/index.ts +17 -5
- package/src/{translation/google-translation-model-options.ts → speech-translation/google-speech-translation-model-options.ts} +4 -4
- package/src/{translation/google-translation-model.ts → speech-translation/google-speech-translation-model.ts} +24 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bbd9b31: chore: rename `*TranslationModel` and its related types to `*SpeechTranslationModel` for consistency
|
|
8
|
+
|
|
9
|
+
## 4.0.36
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [3469d0c]
|
|
14
|
+
- @ai-sdk/provider@4.0.6
|
|
15
|
+
- @ai-sdk/provider-utils@5.0.23
|
|
16
|
+
|
|
3
17
|
## 4.0.35
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -511,11 +511,11 @@ interface GoogleImageSettings {
|
|
|
511
511
|
maxImagesPerCall?: number;
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
type
|
|
515
|
-
declare const
|
|
514
|
+
type GoogleSpeechTranslationModelId = 'gemini-3.5-live-translate-preview' | (string & {});
|
|
515
|
+
declare const googleSpeechTranslationModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
516
516
|
echoTargetLanguage?: boolean | undefined;
|
|
517
517
|
}>;
|
|
518
|
-
type
|
|
518
|
+
type GoogleSpeechTranslationModelOptions = InferSchema<typeof googleSpeechTranslationModelOptions>;
|
|
519
519
|
|
|
520
520
|
interface GoogleProvider extends ProviderV4 {
|
|
521
521
|
(modelId: GoogleModelId): LanguageModelV4;
|
|
@@ -556,11 +556,11 @@ interface GoogleProvider extends ProviderV4 {
|
|
|
556
556
|
/**
|
|
557
557
|
* Creates an experimental model for streaming speech translation.
|
|
558
558
|
*/
|
|
559
|
-
translation(modelId:
|
|
559
|
+
translation(modelId: GoogleSpeechTranslationModelId): Experimental_SpeechTranslationModelV4;
|
|
560
560
|
/**
|
|
561
561
|
* Creates an experimental model for streaming speech translation.
|
|
562
562
|
*/
|
|
563
|
-
speechTranslationModel(modelId:
|
|
563
|
+
speechTranslationModel(modelId: GoogleSpeechTranslationModelId): Experimental_SpeechTranslationModelV4;
|
|
564
564
|
/**
|
|
565
565
|
* Creates a model for speech generation (text-to-speech).
|
|
566
566
|
*/
|
|
@@ -678,7 +678,7 @@ type GoogleRealtimeModelOptions = {
|
|
|
678
678
|
};
|
|
679
679
|
};
|
|
680
680
|
|
|
681
|
-
type
|
|
681
|
+
type GoogleSpeechTranslationModelConfig = {
|
|
682
682
|
provider: string;
|
|
683
683
|
baseURL: string;
|
|
684
684
|
headers: () => Record<string, string | undefined>;
|
|
@@ -688,23 +688,23 @@ type GoogleTranslationModelConfig = {
|
|
|
688
688
|
finishGraceMs?: number;
|
|
689
689
|
};
|
|
690
690
|
};
|
|
691
|
-
declare class
|
|
691
|
+
declare class GoogleSpeechTranslationModel implements Experimental_SpeechTranslationModelV4 {
|
|
692
692
|
readonly specificationVersion = "v4";
|
|
693
|
-
readonly modelId:
|
|
693
|
+
readonly modelId: GoogleSpeechTranslationModelId;
|
|
694
694
|
private readonly config;
|
|
695
|
-
static [WORKFLOW_SERIALIZE](model:
|
|
695
|
+
static [WORKFLOW_SERIALIZE](model: GoogleSpeechTranslationModel): {
|
|
696
696
|
modelId: string;
|
|
697
697
|
config: _ai_sdk_provider.JSONObject;
|
|
698
698
|
};
|
|
699
699
|
static [WORKFLOW_DESERIALIZE](options: {
|
|
700
|
-
modelId:
|
|
701
|
-
config:
|
|
702
|
-
}):
|
|
700
|
+
modelId: GoogleSpeechTranslationModelId;
|
|
701
|
+
config: GoogleSpeechTranslationModelConfig;
|
|
702
|
+
}): GoogleSpeechTranslationModel;
|
|
703
703
|
get provider(): string;
|
|
704
|
-
constructor(modelId:
|
|
704
|
+
constructor(modelId: GoogleSpeechTranslationModelId, config: GoogleSpeechTranslationModelConfig);
|
|
705
705
|
doStream(options: Experimental_SpeechTranslationModelV4StreamOptions): Promise<Awaited<ReturnType<Experimental_SpeechTranslationModelV4['doStream']>>>;
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
declare const VERSION: string;
|
|
709
709
|
|
|
710
|
-
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions,
|
|
710
|
+
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleSpeechTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleSpeechTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleSpeechTranslationModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleTranslationModelOptions, type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleLanguageModelInteractionsOptions, type GoogleLanguageModelOptions, type GoogleProvider, type GoogleProviderMetadata, type GoogleProviderSettings, type GoogleSpeechModelId, type GoogleSpeechModelOptions, type GoogleVideoModelId, type GoogleVideoModelOptions, VERSION, createGoogle, createGoogle as createGoogleGenerativeAI, google };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.37" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -7368,7 +7368,7 @@ var GoogleRealtimeModel = class {
|
|
|
7368
7368
|
}
|
|
7369
7369
|
};
|
|
7370
7370
|
|
|
7371
|
-
// src/translation/google-translation-model.ts
|
|
7371
|
+
// src/speech-translation/google-speech-translation-model.ts
|
|
7372
7372
|
import {
|
|
7373
7373
|
InvalidArgumentError
|
|
7374
7374
|
} from "@ai-sdk/provider";
|
|
@@ -7385,13 +7385,13 @@ import {
|
|
|
7385
7385
|
waitForWebSocketBufferDrain
|
|
7386
7386
|
} from "@ai-sdk/provider-utils";
|
|
7387
7387
|
|
|
7388
|
-
// src/translation/google-translation-model-options.ts
|
|
7388
|
+
// src/speech-translation/google-speech-translation-model-options.ts
|
|
7389
7389
|
import {
|
|
7390
7390
|
lazySchema as lazySchema20,
|
|
7391
7391
|
zodSchema as zodSchema20
|
|
7392
7392
|
} from "@ai-sdk/provider-utils";
|
|
7393
7393
|
import { z as z22 } from "zod/v4";
|
|
7394
|
-
var
|
|
7394
|
+
var googleSpeechTranslationModelOptions = lazySchema20(
|
|
7395
7395
|
() => zodSchema20(
|
|
7396
7396
|
z22.object({
|
|
7397
7397
|
/**
|
|
@@ -7403,7 +7403,7 @@ var googleTranslationModelOptions = lazySchema20(
|
|
|
7403
7403
|
)
|
|
7404
7404
|
);
|
|
7405
7405
|
|
|
7406
|
-
// src/translation/google-translation-model.ts
|
|
7406
|
+
// src/speech-translation/google-speech-translation-model.ts
|
|
7407
7407
|
var liveWebSocketPath = "google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent";
|
|
7408
7408
|
var defaultFinishGraceMs = 1e3;
|
|
7409
7409
|
var googleLiveOutputAudioRate = 24e3;
|
|
@@ -7413,7 +7413,7 @@ function getLiveWebSocketURL(baseURL, apiKey) {
|
|
|
7413
7413
|
url.searchParams.set("key", apiKey);
|
|
7414
7414
|
return url;
|
|
7415
7415
|
}
|
|
7416
|
-
var
|
|
7416
|
+
var GoogleSpeechTranslationModel = class _GoogleSpeechTranslationModel {
|
|
7417
7417
|
constructor(modelId, config) {
|
|
7418
7418
|
this.specificationVersion = "v4";
|
|
7419
7419
|
this.modelId = modelId;
|
|
@@ -7426,7 +7426,7 @@ var GoogleTranslationModel = class _GoogleTranslationModel {
|
|
|
7426
7426
|
});
|
|
7427
7427
|
}
|
|
7428
7428
|
static [WORKFLOW_DESERIALIZE6](options) {
|
|
7429
|
-
return new
|
|
7429
|
+
return new _GoogleSpeechTranslationModel(options.modelId, options.config);
|
|
7430
7430
|
}
|
|
7431
7431
|
get provider() {
|
|
7432
7432
|
return this.config.provider;
|
|
@@ -7443,10 +7443,10 @@ var GoogleTranslationModel = class _GoogleTranslationModel {
|
|
|
7443
7443
|
const googleOptions = await parseProviderOptions8({
|
|
7444
7444
|
provider: "google",
|
|
7445
7445
|
providerOptions: options.providerOptions,
|
|
7446
|
-
schema:
|
|
7446
|
+
schema: googleSpeechTranslationModelOptions
|
|
7447
7447
|
});
|
|
7448
7448
|
const warnings = [];
|
|
7449
|
-
|
|
7449
|
+
validateGoogleSpeechTranslationInputAudioFormat(options.inputAudioFormat);
|
|
7450
7450
|
if (options.sourceLanguage != null) {
|
|
7451
7451
|
warnings.push({
|
|
7452
7452
|
type: "unsupported",
|
|
@@ -7478,7 +7478,7 @@ var GoogleTranslationModel = class _GoogleTranslationModel {
|
|
|
7478
7478
|
([key]) => key.toLowerCase() !== "x-goog-api-key"
|
|
7479
7479
|
)
|
|
7480
7480
|
);
|
|
7481
|
-
const setup =
|
|
7481
|
+
const setup = buildGoogleLiveSpeechTranslationSetup({
|
|
7482
7482
|
modelId: this.modelId,
|
|
7483
7483
|
targetLanguage: options.targetLanguage,
|
|
7484
7484
|
providerOptions: googleOptions
|
|
@@ -7489,7 +7489,7 @@ var GoogleTranslationModel = class _GoogleTranslationModel {
|
|
|
7489
7489
|
timestamp: currentDate,
|
|
7490
7490
|
modelId: this.modelId
|
|
7491
7491
|
},
|
|
7492
|
-
stream:
|
|
7492
|
+
stream: createGoogleLiveSpeechTranslationStream({
|
|
7493
7493
|
webSocket: this.config.webSocket,
|
|
7494
7494
|
url: getLiveWebSocketURL(this.config.baseURL, apiKey),
|
|
7495
7495
|
headers: webSocketHeaders,
|
|
@@ -7504,7 +7504,7 @@ var GoogleTranslationModel = class _GoogleTranslationModel {
|
|
|
7504
7504
|
};
|
|
7505
7505
|
}
|
|
7506
7506
|
};
|
|
7507
|
-
function
|
|
7507
|
+
function createGoogleLiveSpeechTranslationStream({
|
|
7508
7508
|
webSocket,
|
|
7509
7509
|
url,
|
|
7510
7510
|
headers,
|
|
@@ -7794,7 +7794,7 @@ function getPcm16SilenceDurationMs(audio) {
|
|
|
7794
7794
|
}
|
|
7795
7795
|
return sampleCount / googleLiveOutputAudioRate * 1e3;
|
|
7796
7796
|
}
|
|
7797
|
-
function
|
|
7797
|
+
function buildGoogleLiveSpeechTranslationSetup({
|
|
7798
7798
|
modelId,
|
|
7799
7799
|
targetLanguage,
|
|
7800
7800
|
providerOptions
|
|
@@ -7812,7 +7812,7 @@ function buildGoogleLiveTranslationSetup({
|
|
|
7812
7812
|
outputAudioTranscription: {}
|
|
7813
7813
|
};
|
|
7814
7814
|
}
|
|
7815
|
-
function
|
|
7815
|
+
function validateGoogleSpeechTranslationInputAudioFormat(inputAudioFormat) {
|
|
7816
7816
|
if (inputAudioFormat.type !== "audio/pcm" || inputAudioFormat.rate != null && inputAudioFormat.rate !== 16e3) {
|
|
7817
7817
|
throw new InvalidArgumentError({
|
|
7818
7818
|
argument: "inputAudioFormat",
|
|
@@ -7927,8 +7927,8 @@ function createGoogle(options = {}) {
|
|
|
7927
7927
|
headers: getHeaders,
|
|
7928
7928
|
fetch: options.fetch
|
|
7929
7929
|
});
|
|
7930
|
-
const
|
|
7931
|
-
provider: `${providerName}.translation`,
|
|
7930
|
+
const createSpeechTranslationModel = (modelId) => new GoogleSpeechTranslationModel(modelId, {
|
|
7931
|
+
provider: `${providerName}.speech-translation`,
|
|
7932
7932
|
baseURL,
|
|
7933
7933
|
headers: getHeaders,
|
|
7934
7934
|
webSocket: options.webSocket
|
|
@@ -7993,8 +7993,8 @@ function createGoogle(options = {}) {
|
|
|
7993
7993
|
provider.files = createFiles;
|
|
7994
7994
|
provider.speech = createSpeechModel;
|
|
7995
7995
|
provider.speechModel = createSpeechModel;
|
|
7996
|
-
provider.translation =
|
|
7997
|
-
provider.speechTranslationModel =
|
|
7996
|
+
provider.translation = createSpeechTranslationModel;
|
|
7997
|
+
provider.speechTranslationModel = createSpeechTranslationModel;
|
|
7998
7998
|
provider.interactions = createInteractionsModel;
|
|
7999
7999
|
provider.tools = googleTools;
|
|
8000
8000
|
return provider;
|
|
@@ -8002,7 +8002,8 @@ function createGoogle(options = {}) {
|
|
|
8002
8002
|
var google = createGoogle();
|
|
8003
8003
|
export {
|
|
8004
8004
|
GoogleRealtimeModel as Experimental_GoogleRealtimeModel,
|
|
8005
|
-
|
|
8005
|
+
GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel,
|
|
8006
|
+
GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel,
|
|
8006
8007
|
VERSION,
|
|
8007
8008
|
createGoogle,
|
|
8008
8009
|
createGoogle as createGoogleGenerativeAI,
|