@ai-sdk/google 4.0.25 → 4.0.27
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 +16 -0
- package/dist/index.d.ts +50 -3
- package/dist/index.js +516 -30
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +34 -14
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +51 -0
- package/package.json +2 -2
- package/src/get-realtime-base-url.ts +31 -0
- package/src/google-files.ts +0 -1
- package/src/google-provider.ts +32 -0
- package/src/index.ts +6 -0
- package/src/interactions/google-interactions-language-model.ts +21 -0
- package/src/interactions/google-interactions-prompt.ts +1 -0
- package/src/realtime/google-realtime-model.ts +5 -17
- package/src/translation/google-translation-model-options.ts +26 -0
- package/src/translation/google-translation-model.ts +612 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d2d9324: Forward `topK` through Google Interactions requests and warn when unsupported frequency or presence penalties are provided.
|
|
8
|
+
- 8bedb2c: Allow fetch to derive the content length for Google file upload request bodies.
|
|
9
|
+
|
|
10
|
+
## 4.0.26
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c49380c: feat: add experimental streaming speech translation models (`openai.translation('gpt-realtime-translate')` over the OpenAI Realtime translations WebSocket and `google.translation('gemini-3.5-live-translate-preview')` over the Gemini Live API). `connectToWebSocket` in `@ai-sdk/provider-utils` now passes close code and reason to `onClose` (additive, optional parameter).
|
|
15
|
+
- Updated dependencies [0c464d9]
|
|
16
|
+
- Updated dependencies [c49380c]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.14
|
|
18
|
+
|
|
3
19
|
## 4.0.25
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import
|
|
2
|
+
import { InferSchema, FetchFunction, WebSocketConstructor, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
3
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
4
|
+
import { ProviderV4, LanguageModelV4, ImageModelV4, EmbeddingModelV4, Experimental_VideoModelV4, Experimental_SpeechTranslationModelV4, SpeechModelV4, FilesV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig, Experimental_SpeechTranslationModelV4StreamOptions } from '@ai-sdk/provider';
|
|
4
5
|
|
|
5
6
|
declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
6
7
|
error: {
|
|
@@ -510,6 +511,12 @@ interface GoogleImageSettings {
|
|
|
510
511
|
maxImagesPerCall?: number;
|
|
511
512
|
}
|
|
512
513
|
|
|
514
|
+
type GoogleTranslationModelId = 'gemini-3.5-live-translate-preview' | (string & {});
|
|
515
|
+
declare const googleTranslationModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
516
|
+
echoTargetLanguage?: boolean | undefined;
|
|
517
|
+
}>;
|
|
518
|
+
type GoogleTranslationModelOptions = InferSchema<typeof googleTranslationModelOptions>;
|
|
519
|
+
|
|
513
520
|
interface GoogleProvider extends ProviderV4 {
|
|
514
521
|
(modelId: GoogleModelId): LanguageModelV4;
|
|
515
522
|
languageModel(modelId: GoogleModelId): LanguageModelV4;
|
|
@@ -546,6 +553,14 @@ interface GoogleProvider extends ProviderV4 {
|
|
|
546
553
|
* Creates a model for video generation.
|
|
547
554
|
*/
|
|
548
555
|
videoModel(modelId: GoogleVideoModelId): Experimental_VideoModelV4;
|
|
556
|
+
/**
|
|
557
|
+
* Creates an experimental model for streaming speech translation.
|
|
558
|
+
*/
|
|
559
|
+
translation(modelId: GoogleTranslationModelId): Experimental_SpeechTranslationModelV4;
|
|
560
|
+
/**
|
|
561
|
+
* Creates an experimental model for streaming speech translation.
|
|
562
|
+
*/
|
|
563
|
+
speechTranslationModel(modelId: GoogleTranslationModelId): Experimental_SpeechTranslationModelV4;
|
|
549
564
|
/**
|
|
550
565
|
* Creates a model for speech generation (text-to-speech).
|
|
551
566
|
*/
|
|
@@ -595,6 +610,11 @@ interface GoogleProviderSettings {
|
|
|
595
610
|
* Optional function to generate a unique ID for each request.
|
|
596
611
|
*/
|
|
597
612
|
generateId?: () => string;
|
|
613
|
+
/**
|
|
614
|
+
* Custom WebSocket implementation. This is useful for testing or for
|
|
615
|
+
* runtimes that need a WebSocket constructor with header support.
|
|
616
|
+
*/
|
|
617
|
+
webSocket?: WebSocketConstructor;
|
|
598
618
|
/**
|
|
599
619
|
* Custom provider name
|
|
600
620
|
* Defaults to 'google.generative-ai'.
|
|
@@ -658,6 +678,33 @@ type GoogleRealtimeModelOptions = {
|
|
|
658
678
|
};
|
|
659
679
|
};
|
|
660
680
|
|
|
681
|
+
type GoogleTranslationModelConfig = {
|
|
682
|
+
provider: string;
|
|
683
|
+
baseURL: string;
|
|
684
|
+
headers: () => Record<string, string | undefined>;
|
|
685
|
+
webSocket?: WebSocketConstructor;
|
|
686
|
+
_internal?: {
|
|
687
|
+
currentDate?: () => Date;
|
|
688
|
+
finishGraceMs?: number;
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
declare class GoogleTranslationModel implements Experimental_SpeechTranslationModelV4 {
|
|
692
|
+
readonly specificationVersion = "v4";
|
|
693
|
+
readonly modelId: GoogleTranslationModelId;
|
|
694
|
+
private readonly config;
|
|
695
|
+
static [WORKFLOW_SERIALIZE](model: GoogleTranslationModel): {
|
|
696
|
+
modelId: string;
|
|
697
|
+
config: _ai_sdk_provider.JSONObject;
|
|
698
|
+
};
|
|
699
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
700
|
+
modelId: GoogleTranslationModelId;
|
|
701
|
+
config: GoogleTranslationModelConfig;
|
|
702
|
+
}): GoogleTranslationModel;
|
|
703
|
+
get provider(): string;
|
|
704
|
+
constructor(modelId: GoogleTranslationModelId, config: GoogleTranslationModelConfig);
|
|
705
|
+
doStream(options: Experimental_SpeechTranslationModelV4StreamOptions): Promise<Awaited<ReturnType<Experimental_SpeechTranslationModelV4['doStream']>>>;
|
|
706
|
+
}
|
|
707
|
+
|
|
661
708
|
declare const VERSION: string;
|
|
662
709
|
|
|
663
|
-
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, 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 };
|
|
710
|
+
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, GoogleTranslationModel as Experimental_GoogleTranslationModel, type GoogleTranslationModelConfig as Experimental_GoogleTranslationModelConfig, type GoogleTranslationModelId as Experimental_GoogleTranslationModelId, type GoogleTranslationModelOptions 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 };
|