Skip to content

Commit 639e12d

Browse files
committed
update LiveAPI models
1 parent a09ef78 commit 639e12d

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

packages/ai/integration/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function formatConfigAsString(config: { ai: AI; model: string }): string {
4343
}
4444

4545
const backends: readonly Backend[] = [
46-
new GoogleAIBackend(),
46+
// new GoogleAIBackend(),
4747
new VertexAIBackend('global')
4848
];
4949

@@ -56,8 +56,8 @@ const modelNames: readonly string[] = ['gemini-2.0-flash', 'gemini-2.5-flash'];
5656

5757
// The Live API requires a different set of models, and they're different for each backend.
5858
const liveModelNames: Map<BackendType, string[]> = new Map([
59-
[BackendType.GOOGLE_AI, ['gemini-live-2.5-flash-preview']],
60-
[BackendType.VERTEX_AI, ['gemini-2.0-flash-live-preview-04-09']]
59+
[BackendType.GOOGLE_AI, ['gemini-2.5-flash-native-audio-preview-09-2025']],
60+
[BackendType.VERTEX_AI, ['gemini-live-2.5-flash-preview-native-audio-09-2025']]
6161
]);
6262

6363
/**

packages/ai/integration/live.test.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { liveTestConfigs } from './constants';
2828
import { HELLO_AUDIO_PCM_BASE64 } from './sample-data/hello-audio';
2929

3030
// A helper function to consume the generator and collect text parts from one turn.
31-
async function nextTurnText(
31+
async function nextTurnValue(
3232
stream: AsyncGenerator<
3333
LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation
3434
>
@@ -38,6 +38,7 @@ async function nextTurnText(
3838
// We want to keep the generator open so that we can pass it to this function again to get the
3939
// next turn's text.
4040
let result = await stream.next();
41+
console.log('result', result);
4142
while (!result.done) {
4243
const chunk = result.value as
4344
| LiveServerContent
@@ -73,35 +74,37 @@ async function nextTurnText(
7374
describe('Live', function () {
7475
this.timeout(20000);
7576

76-
const textLiveGenerationConfig: LiveGenerationConfig = {
77-
responseModalities: [ResponseModality.TEXT],
78-
temperature: 0,
79-
topP: 0
77+
const audioLiveGenerationConfig: LiveGenerationConfig = {
78+
responseModalities: [ResponseModality.AUDIO]
8079
};
8180

8281
liveTestConfigs.forEach(testConfig => {
8382
describe(`${testConfig.toString()}`, () => {
8483
describe('Live', () => {
85-
it('should connect, send a message, receive a response, and close', async () => {
84+
it.only('should connect, send a message, receive a response, and close', async () => {
8685
const model = getLiveGenerativeModel(testConfig.ai, {
8786
model: testConfig.model,
88-
generationConfig: textLiveGenerationConfig
87+
generationConfig: audioLiveGenerationConfig
8988
});
9089

9190
const session = await model.connect();
92-
const responsePromise = nextTurnText(session.receive());
93-
await session.send(
94-
'Where is Google headquarters located? Answer with the city name only.'
95-
);
96-
const responseText = await responsePromise;
97-
expect(responseText).to.exist;
98-
expect(responseText).to.include('Mountain View');
91+
const responsePromise = nextTurnValue(session.receive());
92+
await session.send([
93+
{
94+
inlineData: {
95+
data: HELLO_AUDIO_PCM_BASE64,
96+
mimeType: 'audio/pcm'
97+
}
98+
}
99+
]);
100+
const responseValue = await responsePromise;
101+
expect(responseValue).to.exist;
99102
await session.close();
100103
});
101104
it('should handle multiple messages in a session', async () => {
102105
const model = getLiveGenerativeModel(testConfig.ai, {
103106
model: testConfig.model,
104-
generationConfig: textLiveGenerationConfig
107+
generationConfig: audioLiveGenerationConfig
105108
});
106109
const session = await model.connect();
107110
const generator = session.receive();
@@ -110,15 +113,15 @@ describe('Live', function () {
110113
'Where is Google headquarters located? Answer with the city name only.'
111114
);
112115

113-
const responsePromise1 = nextTurnText(generator);
116+
const responsePromise1 = nextTurnValue(generator);
114117
const responseText1 = await responsePromise1; // Wait for the turn to complete
115118
expect(responseText1).to.include('Mountain View');
116119

117120
await session.send(
118121
'What state is that in? Answer with the state name only.'
119122
);
120123

121-
const responsePromise2 = nextTurnText(generator);
124+
const responsePromise2 = nextTurnValue(generator);
122125
const responseText2 = await responsePromise2; // Wait for the second turn to complete
123126
expect(responseText2).to.include('California');
124127

@@ -154,10 +157,10 @@ describe('Live', function () {
154157
it('should send a single text chunk and receive a response', async () => {
155158
const model = getLiveGenerativeModel(testConfig.ai, {
156159
model: testConfig.model,
157-
generationConfig: textLiveGenerationConfig
160+
generationConfig: audioLiveGenerationConfig
158161
});
159162
const session = await model.connect();
160-
const responsePromise = nextTurnText(session.receive());
163+
const responsePromise = nextTurnValue(session.receive());
161164

162165
await session.sendTextRealtime('Are you an AI? Yes or No.');
163166

@@ -172,10 +175,10 @@ describe('Live', function () {
172175
it('should send a single audio chunk and receive a response', async () => {
173176
const model = getLiveGenerativeModel(testConfig.ai, {
174177
model: testConfig.model,
175-
generationConfig: textLiveGenerationConfig
178+
generationConfig: audioLiveGenerationConfig
176179
});
177180
const session = await model.connect();
178-
const responsePromise = nextTurnText(session.receive());
181+
const responsePromise = nextTurnValue(session.receive());
179182

180183
await session.sendAudioRealtime({
181184
data: HELLO_AUDIO_PCM_BASE64, // "Hey, can you hear me?"
@@ -193,10 +196,10 @@ describe('Live', function () {
193196
it('should send a single audio chunk and receive a response', async () => {
194197
const model = getLiveGenerativeModel(testConfig.ai, {
195198
model: testConfig.model,
196-
generationConfig: textLiveGenerationConfig
199+
generationConfig: audioLiveGenerationConfig
197200
});
198201
const session = await model.connect();
199-
const responsePromise = nextTurnText(session.receive());
202+
const responsePromise = nextTurnValue(session.receive());
200203

201204
await session.sendMediaChunks([
202205
{
@@ -214,10 +217,10 @@ describe('Live', function () {
214217
it('should send multiple audio chunks in a single batch call', async () => {
215218
const model = getLiveGenerativeModel(testConfig.ai, {
216219
model: testConfig.model,
217-
generationConfig: textLiveGenerationConfig
220+
generationConfig: audioLiveGenerationConfig
218221
});
219222
const session = await model.connect();
220-
const responsePromise = nextTurnText(session.receive());
223+
const responsePromise = nextTurnValue(session.receive());
221224

222225
// TODO (dlarocque): Pass two PCM files with different audio, and validate that the model
223226
// heard both.
@@ -237,10 +240,10 @@ describe('Live', function () {
237240
it('should consume a stream with multiple chunks and receive a response', async () => {
238241
const model = getLiveGenerativeModel(testConfig.ai, {
239242
model: testConfig.model,
240-
generationConfig: textLiveGenerationConfig
243+
generationConfig: audioLiveGenerationConfig
241244
});
242245
const session = await model.connect();
243-
const responsePromise = nextTurnText(session.receive());
246+
const responsePromise = nextTurnValue(session.receive());
244247

245248
// TODO (dlarocque): Pass two PCM files with different audio, and validate that the model
246249
// heard both.

0 commit comments

Comments
 (0)