| 512 | }; |
| 513 | |
| 514 | async function testRoute(prompt: string, label: string, expectedTier?: string) { |
| 515 | const decision = await route(prompt, undefined, 4096, routerOpts); |
| 516 | const savingsPct = (decision.savings * 100).toFixed(1); |
| 517 | if (expectedTier) { |
| 518 | assert( |
| 519 | decision.tier === expectedTier, |
| 520 | `${label} → ${decision.model} (${decision.tier}, ${decision.method}) saved=${savingsPct}%`, |
| 521 | ); |
| 522 | } else { |
| 523 | console.log( |
| 524 | ` → ${label} → ${decision.model} (${decision.tier}, ${decision.method}) saved=${savingsPct}%`, |
| 525 | ); |
| 526 | } |
| 527 | return decision; |
| 528 | } |
| 529 | |
| 530 | await testRoute("What is the capital of France?", "Simple factual", "SIMPLE"); |
| 531 | await testRoute("Hello, how are you?", "Greeting", "SIMPLE"); |