Open History to see the last commit
1import { expect, it } from 'vitest'
2import docs from './fixtures/host-native-reasoning.json'
3import {
4 nativeReasoningCapability,
5 parseFireworksNativeReasoning,
6 parseHfHostedReasoning,
7} from './native-host-reasoning.ts'
8
9it('extracts exact hosted model links only from native explicit reasoning recommendations', () => {
10 expect(parseHfHostedReasoning(docs.hf)).toEqual([
11 'Qwen/Qwen3-4B-Thinking-2507',
12 'deepseek-ai/DeepSeek-R1',
13 'zai-org/GLM-4.5V',
14 ])
15 expect(() =>
16 parseHfHostedReasoning('<li>reasoning capabilities</li>'),
17 ).toThrow()
18 expect(() =>
19 parseHfHostedReasoning(
20 docs.hf.replaceAll('https://huggingface.co/', 'https://example.com/'),
21 ),
22 ).toThrow()
23})
24it('reads positive native Fireworks metadata without inferring undocumented controls', () => {
25 for (const [id, body] of Object.entries(docs.fireworks)) {
26 expect(
27 parseFireworksNativeReasoning(body, 'accounts/fireworks/models/' + id),
28 ).toBe(!id.startsWith('glm'))
29 }
30 expect(
31 parseFireworksNativeReasoning(
32 { name: 'm', description: 'Does not provide reasoning capabilities.' },
33 'm',
34 ),
35 ).toBe(false)
36 for (const description of [
37 'Lacks reasoning capabilities.',
38 'Does not support reasoning. Reasoning capabilities are available only on another model.',
39 ])
40 expect(parseFireworksNativeReasoning({ name: 'm', description }, 'm')).toBe(
41 false,
42 )
43 expect(() =>
44 parseFireworksNativeReasoning(
45 { name: 'other', description: 'reasoning capabilities' },
46 'm',
47 ),
48 ).toThrow()
49 expect(() => parseFireworksNativeReasoning({ name: 'm' }, 'm')).toThrow()
50})
51it('preserves populated flags, unknown controls, and unrelated provenance', () => {
52 const source = {
53 derivation: 'listing' as const,
54 sourceUrl: 'https://api.fireworks.ai/v1/accounts/fireworks/models/m',
55 path: 'description',
56 }
57 const model = {
58 rawId: 'm',
59 capabilities: { tools: true, structured: false },
60 reasoning: null,
61 factSources: { capabilities: { tools: source } },
62 }
63 const next = nativeReasoningCapability(model, source)
64 expect(next.capabilities).toEqual({
65 tools: true,
66 structured: false,
67 reasoning: true,
68 })
69 expect(next.reasoning).toBeNull()
70 expect(next.factSources?.capabilities?.tools).toEqual(source)
71 expect(() =>
72 nativeReasoningCapability(
73 { ...model, capabilities: { reasoning: false } },
74 source,
75 ),
76 ).toThrow()
77 expect(() =>
78 nativeReasoningCapability(
79 { ...model, unsupportedCapabilities: ['reasoning'] },
80 source,
81 ),
82 ).toThrow()
83})