guanghu-ice-heart/server-tools/tcs-mother-body/model-router.test.mjs

3 lines
785 B
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {ModelRouter} from './model-router.mjs';
test('automatic router uses stronger provider for mother and cheaper provider for door without exposing keys',async()=>{const calls=[];const fetchImpl=async(url,options)=>{calls.push({url,body:JSON.parse(options.body),auth:options.headers.authorization});return {ok:true,async json(){return {choices:[{message:{content:'{"schema":"ok"}'}}]};}};};const router=new ModelRouter({fetchImpl,deepseekKey:'deep-secret',openluxKey:'open-secret'});await router.cognize('mother-evolve',{});await router.cognize('door-test',{});assert.match(calls[0].url,/deepseek/);assert.match(calls[1].url,/openlux/);assert.equal(JSON.stringify(router.status()).includes('secret'),false);});