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 threadId: 'thread-1',
13 model,
14 logger,
15 messages: [{ role: 'user', content: 'hi' }],
16 ...(reasoning ? { reasoning } : {}),
17 })
18 }
19}
20
21describe('Cloudflare chat({ reasoning }) request shape', () => {
22 const adapter = new Probe({ accountId: 'a', apiKey: 'k' }, model)
23
24 it('sends the level effort', () => {
25 expect(adapter.request({ level: 'max', summary: true })).toMatchObject({
26 reasoning_effort: 'max',
27 })
28 })
29
30 it('sends null for off', () => {
31 expect(
32 adapter.request({ level: 'off', summary: true }).reasoning_effort,
33 ).toBeNull()
34 })
35
36 it('sends nothing without a request', () => {
37 expect(adapter.request(undefined)).not.toHaveProperty('reasoning_effort')
38 })
39})