Open History to see the last commit
1import { test, expect } from './fixtures'
2
3for (const provider of ['neon', 'neon-anthropic']) {
4 for (const stream of [false, true]) {
5 test(`${provider} -- summarize omits rejected sampling (stream=${stream})`, async ({
6 request,
7 aimockPort,
8 testId,
9 }) => {
10 const response = await request.post('/api/summarize', {
11 data: {
12 provider,
13 text: '[summarize] The Fender Stratocaster is a versatile electric guitar',
14 maxLength: 73,
15 stream,
16 aimockPort,
17 testId,
18 },
19 })
20 expect(response.ok()).toBe(true)
21 expect(await response.text()).toContain('Stratocaster')
22
23 const journal = await request.get(
24 `http://127.0.0.1:${aimockPort}/v1/_requests`,
25 )
26 const entries = (await journal.json()) as Array<{
27 headers?: Record<string, string>
28 body?: Record<string, unknown>
29 }>
30 const calls = entries.filter(
31 (entry) => entry.headers?.['x-test-id'] === testId,
32 )
33 expect(calls).toHaveLength(1)
34 expect(calls[0]?.body?.model).toBe(
35 provider === 'neon' ? 'gemini-3-8-flash' : 'claude-opus-5-5',
36 )
37 expect(calls[0]?.body?.max_tokens).toBe(73)
38 expect(calls[0]?.body).not.toHaveProperty('temperature')
39 expect(calls[0]?.body).not.toHaveProperty('top_p')
40 })
41 }
42}
43
44for (const stream of [false, true]) {
45 test(`neon-responses -- summarize honors Responses token options (stream=${stream})`, async ({
46 request,
47 }) => {
48 const response = await request.post(
49 `/api/neon-wire?activity=summarize&stream=${stream}`,
50 )
51 expect(response.ok()).toBe(true)
52 const { summary, requests } = await response.json()
53 expect(summary).toContain('Stratocaster')
54 expect(requests).toHaveLength(1)
55 expect(requests[0].url).toContain('/openai/v1/responses')
56 expect(requests[0].body).toMatchObject({
57 model: 'gpt-6-1-sol',
58 max_output_tokens: 91,
59 })
60 expect(requests[0].body).not.toHaveProperty('max_tokens')
61 expect(requests[0].body).not.toHaveProperty('temperature')
62 })
63}
64
65test('neon -- Gemini reasoning usage reaches the SSE client', async ({
66 request,
67}) => {
68 const response = await request.post('/api/neon-wire')
69 expect(response.ok()).toBe(true)
70 const events = (await response.text())
71 .split('\n')
72 .filter((line) => line.startsWith('data: {'))
73 .map((line) => JSON.parse(line.slice(6)))
74 expect(events.some((event) => event.type === 'RUN_ERROR')).toBe(false)
75 expect(
76 events.find((event) => event.type === 'TEXT_MESSAGE_CONTENT'),
77 ).toMatchObject({ delta: 'Hello' })
78 expect(events.find((event) => event.type === 'RUN_FINISHED')).toMatchObject({
79 usage: [
80 {
81 inputTokens: 180,
82 outputTokens: 7,
83 totalTokens: 459,
84 reasoningTokens: 272,
85 },
86 ],
87 })
88})