@ai-sdk/google 4.0.0-canary.77 → 4.0.0-canary.78
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 +6 -0
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +32 -2
- package/dist/internal/index.js +322 -48
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/google-speech-model.ts +31 -6
- package/src/internal/index.ts +1 -0
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import { googleSpeechResponseSchema } from './google-speech-api';
|
|
|
17
17
|
import {
|
|
18
18
|
googleSpeechProviderOptionsSchema,
|
|
19
19
|
type GoogleSpeechModelId,
|
|
20
|
+
type GoogleSpeechModelOptions,
|
|
20
21
|
} from './google-speech-model-options';
|
|
21
22
|
|
|
22
23
|
interface GoogleSpeechModelConfig {
|
|
@@ -70,11 +71,35 @@ export class GoogleSpeechModel implements SpeechModelV4 {
|
|
|
70
71
|
}: Parameters<SpeechModelV4['doGenerate']>[0]) {
|
|
71
72
|
const warnings: SharedV4Warning[] = [];
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
// Names to look up in providerOptions. The Vertex provider exposes these
|
|
75
|
+
// under `googleVertex`/`vertex` (matching the Google Vertex language model),
|
|
76
|
+
// while every other Google provider uses `google`.
|
|
77
|
+
const providerOptionsNames: readonly string[] =
|
|
78
|
+
this.config.provider.includes('vertex')
|
|
79
|
+
? (['googleVertex', 'vertex'] as const)
|
|
80
|
+
: (['google'] as const);
|
|
81
|
+
|
|
82
|
+
let googleOptions: GoogleSpeechModelOptions | undefined;
|
|
83
|
+
for (const name of providerOptionsNames) {
|
|
84
|
+
googleOptions = await parseProviderOptions({
|
|
85
|
+
provider: name,
|
|
86
|
+
providerOptions,
|
|
87
|
+
schema: googleSpeechProviderOptionsSchema,
|
|
88
|
+
});
|
|
89
|
+
if (googleOptions != null) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Cross-namespace fallback: a Vertex provider may receive options under the
|
|
95
|
+
// `google` key (e.g. via the AI Gateway).
|
|
96
|
+
if (googleOptions == null && !providerOptionsNames.includes('google')) {
|
|
97
|
+
googleOptions = await parseProviderOptions({
|
|
98
|
+
provider: 'google',
|
|
99
|
+
providerOptions,
|
|
100
|
+
schema: googleSpeechProviderOptionsSchema,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
78
103
|
|
|
79
104
|
// Multi-speaker (provider option) takes precedence over the single voice.
|
|
80
105
|
const multiSpeakerVoiceConfig = googleOptions?.multiSpeakerVoiceConfig;
|
|
@@ -133,7 +158,7 @@ export class GoogleSpeechModel implements SpeechModelV4 {
|
|
|
133
158
|
}
|
|
134
159
|
|
|
135
160
|
const requestBody = {
|
|
136
|
-
contents: [{ parts: [{ text: promptText }] }],
|
|
161
|
+
contents: [{ role: 'user', parts: [{ text: promptText }] }],
|
|
137
162
|
generationConfig: {
|
|
138
163
|
responseModalities: ['AUDIO'],
|
|
139
164
|
speechConfig,
|
package/src/internal/index.ts
CHANGED