Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

gemini-3-8-flash.spec.ts

54 lines1.6 KB

1import { chat } from '@tanstack/ai'
2import { createGeminiChat } from '@tanstack/ai-gemini'
3import { createGeminiTextInteractions } from '@tanstack/ai-gemini/experimental'
4import { vertexText } from '@tanstack/ai-vertex'
5import { vertexE2eConfig } from '../src/lib/vertex-e2e'
6import { test, expect } from './fixtures'
7​
8const model = 'gemini-3.8-flash'
9​
10const adapters = [
11 {
12 name: 'Gemini',
13 create: (baseUrl: string, headers: Record<string, string>) =>
14 createGeminiChat(model, 'e2e-dummy', {
15 httpOptions: { baseUrl, headers },
16 }),
17 },
18 {
19 name: 'Gemini Interactions',
20 create: (baseUrl: string, headers: Record<string, string>) =>
21 createGeminiTextInteractions(model, 'e2e-dummy', {
22 httpOptions: { baseUrl, headers },
23 }),
24 },
25 {
26 name: 'Vertex',
27 create: (baseUrl: string, headers: Record<string, string>) =>
28 vertexText(model, vertexE2eConfig(baseUrl, headers)),
29 },
31​
32for (const { name, create } of adapters) {
33 test(`${name} streams with gemini-3.8-flash on the wire`, async ({
34 aimockPort,
35 testId,
36 }) => {
37 const baseUrl = `http://127.0.0.1:${aimockPort}`
38 const adapter = create(baseUrl, { 'X-Test-Id': testId })
39 let text = ''
40 let finished = false
41 for await (const chunk of chat({
42 adapter,
43 messages: [
44 { role: 'user', content: '[gemini-3.8-flash] recommend a guitar' },
45 ],
46 })) {
47 expect(chunk.type).not.toBe('RUN_ERROR')
48 if (chunk.type === 'TEXT_MESSAGE_CONTENT') text += chunk.delta
49 if (chunk.type === 'RUN_FINISHED') finished = true
50 }
51 expect(text).toContain('Fender Stratocaster')
52 expect(finished).toBe(true)
53 })