Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { buildReport, parseLedger } from './completeness.ts'
4import type { ModelRow } from './completeness.ts'
5
6const chat: ModelRow = {
7 provider: 'host',
8 rawId: 'm',
9 activity: 'chat',
10 contextWindow: 8,
11 maxOutput: 8,
12 modalities: { input: ['text'] },
13 pricing: {
14 tables: {
15 rate: {
16 base: { input_tokens: 1, output_tokens: 2, cache_read_tokens: 0.1 },
17 },
18 },
19 },
20 capabilities: { reasoning: true },
21 reasoning: { mode: 'effort', mandatory: true, efforts: ['low'] },
22 requestMap: { replayReasoningContent: false },
23 schemaEndpointId: 'chat/completions',
24}
25
26describe('applicable facts', () => {
27 it('scores replayReasoningContent only on chat/completions routes', () => {
28 const report = buildReport([
29 chat,
30 {
31 ...chat,
32 rawId: 'messages',
33 schemaEndpointId: 'v1/messages',
34 requestMap: null,
35 },
36 {
37 ...chat,
38 rawId: 'converse',
39 schemaEndpointId: 'model/x/converse',
40 requestMap: null,
41 },
42 {
43 ...chat,
44 rawId: 'responses',
45 schemaEndpointId: 'responses',
46 requestMap: null,
47 },
48 {
49 ...chat,
50 rawId: 'gemini',
51 schemaEndpointId: 'v1beta/models/{modelsId}:generateContent',
52 requestMap: { maxTokensField: 'max_tokens' },
53 },
54 ])
55 const host = report.providers[0]
56 expect(host?.facts.replayReasoningContent).toEqual({ have: 1, need: 1 })
57 expect(host?.facts.requestMap).toEqual({ have: 1, need: 2 })
58 })
59
60 it('does not score requestMap on a native route', () => {
61 const report = buildReport([
62 {
63 ...chat,
64 schemaEndpointId: 'v1/messages',
65 requestMap: null,
66 reasoning: null,
67 capabilities: { tools: true },
68 },
69 ])
70 expect(report.providers[0]?.facts.requestMap).toEqual({ have: 0, need: 0 })
71 expect(report.providers[0]?.facts.replayReasoningContent).toEqual({
72 have: 0,
73 need: 0,
74 })
75 })
76
77 it('counts a stated cache absence and not a made-up price', () => {
78 const report = buildReport([
79 {
80 ...chat,
81 pricing: {
82 tables: { rate: { base: { input_tokens: 1, output_tokens: 2 } } },
83 },
84 factSources: { cacheRead: { path: 'not-offered' } },
85 },
86 ])
87 expect(report.providers[0]?.facts.cacheRead).toEqual({ have: 1, need: 1 })
88 })
89
90 it('scores n/a when every row is a non-chat activity, and 0 when one is unclassified', () => {
91 const speech = buildReport([
92 { provider: 'speech', activity: 'audio' },
93 { provider: 'speech', activity: 'audio' },
94 ])
95 expect(speech.providers[0]?.score).toBeNull()
96 const missed = buildReport([
97 { provider: 'images', activity: 'image' },
98 { provider: 'images', activity: null },
99 ])
100 expect(missed.providers[0]?.score).toBe(0)
101 })
102
103 it('leaves a native replay row out of a model-scoped ledger denominator', () => {
104 const report = buildReport(
105 [{ ...chat, schemaEndpointId: 'v1/messages', requestMap: null }],
106 parseLedger('- host/m: replayReasoningContent — native route'),
107 )
108 expect(report.providers[0]?.facts.replayReasoningContent.need).toBe(0)
109 expect(
110 report.providers[0]?.modelSilent?.replayReasoningContent,
111 ).toBeUndefined()
112 })
113})