Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2import { resolveDebugOption } from '@tanstack/ai/adapter-internals'
3import { CloudflareTextAdapter } from '../src/adapters/text'
4import type { ReasoningRequest } from '@tanstack/ai'
5
6const logger = resolveDebugOption(false)
7const model = '@cf/deepseek-ai/deepseek-v4-flash-0731'
8
9class Probe extends CloudflareTextAdapter<typeof model> {
10 request(reasoning: ReasoningRequest | undefined) {
11 return this.mapOptionsToRequest({
12 model,
13 logger,
14 messages: [{ role: 'user', content: 'hi' }],
15 ...(reasoning ? { reasoning } : {}),
16 })
17 }
18}
19
20describe('Cloudflare chat({ reasoning }) request shape', () => {
21 const adapter = new Probe({ accountId: 'a', apiKey: 'k' }, model)
22
23 it('sends the level effort', () => {
24 expect(adapter.request({ level: 'max', summary: true })).toMatchObject({
25 reasoning_effort: 'max',
26 })
27 })
28
29 it('sends null for off', () => {
30 expect(
31 adapter.request({ level: 'off', summary: true }).reasoning_effort,
32 ).toBeNull()
33 })
34
35 it('sends nothing without a request', () => {
36 expect(adapter.request(undefined)).not.toHaveProperty('reasoning_effort')
37 })
38})