Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2import { resolveDebugOption } from '@tanstack/ai/adapter-internals'
3import { LovableTextAdapter } from '../src/adapters/text'
4import { LovableResponsesTextAdapter } from '../src/adapters/responses-text'
5import type { ReasoningRequest, TextOptions } from '@tanstack/ai'
6
7const logger = resolveDebugOption(false)
8const model = 'google/gemini-3.6-flash'
9
10function options(reasoning: ReasoningRequest | undefined): TextOptions {
11 return {
12 model,
13 logger,
14 messages: [{ role: 'user', content: 'hi' }],
15 ...(reasoning ? { reasoning } : {}),
16 }
17}
18
19class ChatProbe extends LovableTextAdapter<typeof model> {
20 request(reasoning: ReasoningRequest | undefined) {
21 return this.mapOptionsToRequest(options(reasoning))
22 }
23}
24
25class ResponsesProbe extends LovableResponsesTextAdapter<typeof model> {
26 request(reasoning: ReasoningRequest | undefined) {
27 return this.mapOptionsToRequest(options(reasoning))
28 }
29}
30
31describe('Lovable chat({ reasoning }) request shape', () => {
32 it('chat: reasoning_effort', () => {
33 const chat = new ChatProbe({ apiKey: 'k' }, model)
34 expect(chat.request({ level: 'minimal', summary: true })).toMatchObject({
35 reasoning_effort: 'minimal',
36 })
37 expect(chat.request(undefined)).not.toHaveProperty('reasoning_effort')
38 })
39
40 it('Responses: reasoning.effort and a summary', () => {
41 const responses = new ResponsesProbe({ apiKey: 'k' }, model)
42 expect(responses.request({ level: 'high', summary: true })).toMatchObject({
43 reasoning: { effort: 'high', summary: 'auto' },
44 })
45 })
46})