modelmix 2.9.4 → 2.9.8
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/demo/custom.mjs +3 -3
- package/index.js +19 -2
- package/package.json +5 -3
package/demo/custom.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'dotenv/config'
|
|
2
2
|
|
|
3
|
-
import { ModelMix,
|
|
3
|
+
import { ModelMix, MixCerebras, MixTogether } from '../index.js';
|
|
4
4
|
|
|
5
5
|
const mmix = new ModelMix({
|
|
6
6
|
options: {
|
|
@@ -13,8 +13,8 @@ const mmix = new ModelMix({
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
mmix.attach(new
|
|
16
|
+
mmix.attach(new MixCerebras());
|
|
17
17
|
|
|
18
|
-
let r = mmix.create('
|
|
18
|
+
let r = mmix.create('llama-4-scout-17b-16e-instruct').addText('what is the capital of the moon?');
|
|
19
19
|
r = await r.addText('do you like cats?').message();
|
|
20
20
|
console.log(r);
|
package/index.js
CHANGED
|
@@ -316,7 +316,8 @@ class MessageHandler {
|
|
|
316
316
|
if (this.fallbackModels.length > 0) {
|
|
317
317
|
const nextModelKey = this.fallbackModels[0];
|
|
318
318
|
log.warn(`Model ${this.options.model} failed, trying fallback model ${nextModelKey}...`);
|
|
319
|
-
|
|
319
|
+
log.warn(error.details);
|
|
320
|
+
|
|
320
321
|
// Create a completely new handler with the fallback model
|
|
321
322
|
const nextHandler = this.mix.create(
|
|
322
323
|
[nextModelKey, ...this.fallbackModels.slice(1)],
|
|
@@ -719,4 +720,20 @@ class MixTogether extends MixCustom {
|
|
|
719
720
|
}
|
|
720
721
|
}
|
|
721
722
|
|
|
722
|
-
|
|
723
|
+
class MixCerebras extends MixCustom {
|
|
724
|
+
getDefaultConfig(customConfig) {
|
|
725
|
+
return super.getDefaultConfig({
|
|
726
|
+
url: 'https://api.cerebras.ai/v1/chat/completions',
|
|
727
|
+
prefix: ["llama"],
|
|
728
|
+
apiKey: process.env.CEREBRAS_API_KEY,
|
|
729
|
+
...customConfig
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
create(args = { config: {}, options: {} }) {
|
|
734
|
+
args.options.messages = [{ role: 'system', content: args.config.system }, ...args.options.messages || []];
|
|
735
|
+
return super.create(args);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
module.exports = { MixCustom, ModelMix, MixAnthropic, MixOpenAI, MixPerplexity, MixOllama, MixLMStudio, MixGroq, MixTogether, MixGrok, MixCerebras };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modelmix",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.8",
|
|
4
4
|
"description": "🧬 ModelMix - Unified API for Diverse AI LLM.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -31,11 +31,13 @@
|
|
|
31
31
|
"deepseek",
|
|
32
32
|
"fallback",
|
|
33
33
|
"o3",
|
|
34
|
-
"o3-mini",
|
|
34
|
+
"o3-mini",
|
|
35
35
|
"nousresearch",
|
|
36
36
|
"reasoning",
|
|
37
37
|
"bottleneck",
|
|
38
38
|
"claude-3-7-sonnet",
|
|
39
|
+
"cerebras",
|
|
40
|
+
"scout",
|
|
39
41
|
"clasen"
|
|
40
42
|
],
|
|
41
43
|
"author": "Martin Clasen",
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
},
|
|
46
48
|
"homepage": "https://github.com/clasen/ModelMix#readme",
|
|
47
49
|
"dependencies": {
|
|
48
|
-
"axios": "^1.
|
|
50
|
+
"axios": "^1.8.4",
|
|
49
51
|
"bottleneck": "^2.19.5",
|
|
50
52
|
"lemonlog": "^1.1.2"
|
|
51
53
|
}
|