profileShare

rasmusjy / roundtable

Read-only snapshot

No repository description.

main default branch 181 files Expires Sep 13, 2026, 9:06 AM
cost-estimate.test.ts 1,498 bytes
1 import { describe, expect, it } from 'vitest';
2 import { estimateDebateCostUsd, type TokenPrice } from './cost-estimate';
3
4 const price = (): TokenPrice => ({ prompt: 1e-6, completion: 3e-6 });
5
6 describe('estimateDebateCostUsd', () => {
7 const base = {
8 councilModels: ['a/x', 'b/y', 'c/z'],
9 chairmanModel: 'd/chair',
10 convergenceModel: 'e/conv',
11 price,
12 };
13
14 it('is positive and grows with rounds', () => {
15 const r1 = estimateDebateCostUsd({ ...base, rounds: 1 });
16 const r3 = estimateDebateCostUsd({ ...base, rounds: 3 });
17 expect(r1).toBeGreaterThan(0);
18 expect(r3).toBeGreaterThan(r1);
19 });
20
21 it('grows with council size', () => {
22 const small = estimateDebateCostUsd({ ...base, councilModels: ['a/x', 'b/y', 'c/z'], rounds: 2 });
23 const big = estimateDebateCostUsd({ ...base, councilModels: ['a/x', 'b/y', 'c/z', 'd/w', 'e/v'], rounds: 2 });
24 expect(big).toBeGreaterThan(small);
25 });
26
27 it('falls back to a default price for unknown models', () => {
28 const withFallback = estimateDebateCostUsd({ ...base, rounds: 1, price: () => undefined });
29 expect(withFallback).toBeGreaterThan(0);
30 });
31
32 it('uses more expensive models to produce higher estimates', () => {
33 const cheap = estimateDebateCostUsd({ ...base, rounds: 2, price: () => ({ prompt: 1e-7, completion: 4e-7 }) });
34 const dear = estimateDebateCostUsd({ ...base, rounds: 2, price: () => ({ prompt: 3e-6, completion: 1.5e-5 }) });
35 expect(dear).toBeGreaterThan(cheap);
36 });
37 });
38