modelmix 5.0.6 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -112
- package/RLM_PLUGIN_SPEC.md +2 -2
- package/demo/fallback.js +2 -2
- package/demo/free.js +2 -3
- package/demo/gemini.js +2 -2
- package/demo/json.js +2 -2
- package/demo/mcp-simple.js +2 -2
- package/demo/mcp-tools.js +6 -6
- package/demo/mcp.js +1 -1
- package/demo/parallel-strategy.js +3 -3
- package/demo/parallel.js +2 -2
- package/demo/repl-powers.js +2 -3
- package/demo/rlm-basic.js +2 -2
- package/demo/rlm-fast.js +3 -3
- package/demo/rlm-simple.js +3 -3
- package/demo/short.js +1 -1
- package/demo/stream.js +1 -1
- package/demo/tokens.js +1 -1
- package/demo/verbose.js +5 -5
- package/effort.js +9 -3
- package/index.d.ts +0 -8
- package/index.js +499 -2861
- package/lib/content-cache.js +31 -0
- package/lib/model-chain.js +51 -0
- package/lib/object-utils.js +7 -0
- package/lib/provider-debug.js +23 -0
- package/lib/providers/anthropic.js +337 -0
- package/lib/providers/base.js +409 -0
- package/lib/providers/google.js +293 -0
- package/lib/providers/openai-compatible.js +338 -0
- package/lib/providers/openai.js +622 -0
- package/lib/providers.js +26 -0
- package/lib/template-engine.js +168 -0
- package/lib/token-usage.js +299 -0
- package/package.json +1 -1
- package/skills/modelmix/SKILL.md +10 -10
- package/test/effort.test.js +36 -0
- package/test/fallback.test.js +15 -3
- package/test/history.test.js +1 -1
- package/test/model-chain.test.js +12 -0
- package/test/moderation.test.js +1 -1
- package/test/public-api.test.js +54 -0
- package/test/tokens.test.js +20 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
|
|
3
|
+
const { ModelMix } = require('../index.js');
|
|
4
|
+
const { listChainModelShortcuts } = require('../lib/model-chain');
|
|
5
|
+
|
|
6
|
+
describe('model chain catalog', () => {
|
|
7
|
+
it('contains only implemented ModelMix shortcuts', () => {
|
|
8
|
+
for (const shortcut of listChainModelShortcuts()) {
|
|
9
|
+
expect(ModelMix.prototype[shortcut], shortcut).to.be.a('function');
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
package/test/moderation.test.js
CHANGED
|
@@ -100,7 +100,7 @@ describe('OpenAI moderation', () => {
|
|
|
100
100
|
it('rejects generative providers from the moderation chain', () => {
|
|
101
101
|
const model = ModerationMix.new();
|
|
102
102
|
|
|
103
|
-
expect(() => model.
|
|
103
|
+
expect(() => model.gpt5nano({ config: { apiKey: 'test-key' } })).to.throw(
|
|
104
104
|
'ModerationMix only accepts moderation providers.'
|
|
105
105
|
);
|
|
106
106
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
|
|
3
|
+
const api = require('../index.js');
|
|
4
|
+
|
|
5
|
+
describe('public module boundary', () => {
|
|
6
|
+
it('preserves the CommonJS export surface', () => {
|
|
7
|
+
expect(Object.keys(api).sort()).to.deep.equal([
|
|
8
|
+
'MixAnthropic',
|
|
9
|
+
'MixCerebras',
|
|
10
|
+
'MixCustom',
|
|
11
|
+
'MixFireworks',
|
|
12
|
+
'MixGoogle',
|
|
13
|
+
'MixGrok',
|
|
14
|
+
'MixGroq',
|
|
15
|
+
'MixKimi',
|
|
16
|
+
'MixLMStudio',
|
|
17
|
+
'MixMiMo',
|
|
18
|
+
'MixMiniMax',
|
|
19
|
+
'MixModeration',
|
|
20
|
+
'MixNVIDIA',
|
|
21
|
+
'MixOllama',
|
|
22
|
+
'MixOpenAI',
|
|
23
|
+
'MixOpenAIModeration',
|
|
24
|
+
'MixOpenAIResponses',
|
|
25
|
+
'MixOpenAIWebSocket',
|
|
26
|
+
'MixOpenRouter',
|
|
27
|
+
'MixPerplexity',
|
|
28
|
+
'MixTogether',
|
|
29
|
+
'ModelMix',
|
|
30
|
+
'ModerationMix',
|
|
31
|
+
'applyUnifiedEffort',
|
|
32
|
+
'normalizeEffort',
|
|
33
|
+
'resolveProviderFamily'
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('preserves provider inheritance and class identity', () => {
|
|
38
|
+
expect(Object.getPrototypeOf(api.MixOpenAIResponses.prototype)).to.equal(api.MixOpenAI.prototype);
|
|
39
|
+
expect(Object.getPrototypeOf(api.MixOpenAIModeration.prototype)).to.equal(api.MixModeration.prototype);
|
|
40
|
+
expect(Object.getPrototypeOf(api.ModerationMix.prototype)).to.equal(api.ModelMix.prototype);
|
|
41
|
+
expect(require('../index.js').MixCustom).to.equal(api.MixCustom);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('keeps root exports usable by model shortcuts', () => {
|
|
45
|
+
const model = api.ModelMix.new().qwen35397b({ config: { apiKey: 'test-key' } });
|
|
46
|
+
|
|
47
|
+
expect(model.models).to.have.length(1);
|
|
48
|
+
expect(model.models[0].provider.constructor).to.equal(api.MixOpenRouter);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('keeps the mutable pricing catalog private', () => {
|
|
52
|
+
expect(require('../lib/token-usage')).to.not.have.property('MODEL_PRICING');
|
|
53
|
+
});
|
|
54
|
+
});
|
package/test/tokens.test.js
CHANGED
|
@@ -576,6 +576,26 @@ describe('Token Usage Tracking', () => {
|
|
|
576
576
|
}
|
|
577
577
|
});
|
|
578
578
|
|
|
579
|
+
it('should register GPT-OSS 120B through the current OpenRouter model ID', function () {
|
|
580
|
+
const originalOpenRouterApiKey = process.env.OPENROUTER_API_KEY;
|
|
581
|
+
process.env.OPENROUTER_API_KEY = 'test-openrouter-key';
|
|
582
|
+
|
|
583
|
+
try {
|
|
584
|
+
const model = ModelMix.new().gptOss({
|
|
585
|
+
mix: { cerebras: false, groq: true, openrouter: true, together: false }
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
expect(model.models.map(({ key }) => key)).to.deep.equal([
|
|
589
|
+
'openai/gpt-oss-120b',
|
|
590
|
+
'openai/gpt-oss-120b'
|
|
591
|
+
]);
|
|
592
|
+
expect(model.models[1].provider).to.be.instanceOf(MixOpenRouter);
|
|
593
|
+
} finally {
|
|
594
|
+
if (originalOpenRouterApiKey === undefined) delete process.env.OPENROUTER_API_KEY;
|
|
595
|
+
else process.env.OPENROUTER_API_KEY = originalOpenRouterApiKey;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
579
599
|
it('should use api-key header for MiMo provider', function () {
|
|
580
600
|
const originalMimoApiKey = process.env.MIMO_API_KEY;
|
|
581
601
|
process.env.MIMO_API_KEY = 'test-mimo-key';
|