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 threadId: 'thread-1',
13 model,
14 logger,
15 messages: [{ role: 'user', content: 'hi' }],
16 ...(reasoning ? { reasoning } : {}),
17 }
18}
19
20class ChatProbe extends LovableTextAdapter<typeof model> {
21 request(reasoning: ReasoningRequest | undefined) {
22 return this.mapOptionsToRequest(options(reasoning))
23 }
24}
25
26class ResponsesProbe extends LovableResponsesTextAdapter<typeof model> {
27 request(reasoning: ReasoningRequest | undefined) {
28 return this.mapOptionsToRequest(options(reasoning))
29 }
30}
31
32describe('Lovable chat({ reasoning }) request shape', () => {
33 it('chat: reasoning_effort', () => {
34 const chat = new ChatProbe({ apiKey: 'k' }, model)
35 expect(chat.request({ level: 'minimal', summary: true })).toMatchObject({
36 reasoning_effort: 'minimal',
37 })
38 expect(chat.request(undefined)).not.toHaveProperty('reasoning_effort')
39 })
40
41 it('Responses: reasoning.effort and a summary', () => {
42 const responses = new ResponsesProbe({ apiKey: 'k' }, model)
43 expect(responses.request({ level: 'high', summary: true })).toMatchObject({
44 reasoning: { effort: 'high', summary: 'auto' },
45 })
46 })
47})