modelmix 2.8.4 → 2.8.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/demo.mjs +2 -2
- package/index.js +25 -20
- package/package.json +5 -8
package/demo/demo.mjs
CHANGED
|
@@ -44,8 +44,8 @@ claude.addImageFromUrl('https://pbs.twimg.com/media/F6-GsjraAAADDGy?format=jpg')
|
|
|
44
44
|
const imageDescription = await claude.addText('describe the image').message();
|
|
45
45
|
console.log(imageDescription);
|
|
46
46
|
|
|
47
|
-
console.log("\n" + '--------| claude-3-
|
|
48
|
-
const writer = mmix.create('claude-3-
|
|
47
|
+
console.log("\n" + '--------| claude-3-7-sonnet-20250219 |--------');
|
|
48
|
+
const writer = mmix.create('claude-3-7-sonnet-20250219', { options: { temperature: 0.5 } });
|
|
49
49
|
writer.setSystem('You are a writer like Stephen King');
|
|
50
50
|
writer.replaceKeyFromFile('{story_title}', './title.md');
|
|
51
51
|
const story = await writer.addTextFromFile('./prompt.md').message();
|
package/index.js
CHANGED
|
@@ -426,9 +426,6 @@ class MixCustom {
|
|
|
426
426
|
|
|
427
427
|
class MixOpenAI extends MixCustom {
|
|
428
428
|
getDefaultConfig(customConfig) {
|
|
429
|
-
if (!customConfig.apiKey && !process.env.OPENAI_API_KEY) {
|
|
430
|
-
throw new Error('OpenAI API key not found. Please provide it in customConfig or set OPENAI_API_KEY environment variable.');
|
|
431
|
-
}
|
|
432
429
|
return super.getDefaultConfig({
|
|
433
430
|
url: 'https://api.openai.com/v1/chat/completions',
|
|
434
431
|
prefix: ['gpt', 'ft:', 'o3', 'o1'],
|
|
@@ -438,6 +435,10 @@ class MixOpenAI extends MixCustom {
|
|
|
438
435
|
}
|
|
439
436
|
|
|
440
437
|
create(args = { config: {}, options: {} }) {
|
|
438
|
+
if (!this.config.apiKey) {
|
|
439
|
+
throw new Error('OpenAI API key not found. Please provide it in config or set OPENAI_API_KEY environment variable.');
|
|
440
|
+
}
|
|
441
|
+
|
|
441
442
|
// Remove max_tokens and temperature for o1/o3 models
|
|
442
443
|
if (args.options.model?.startsWith('o')) {
|
|
443
444
|
delete args.options.max_tokens;
|
|
@@ -472,9 +473,6 @@ class MixOpenAI extends MixCustom {
|
|
|
472
473
|
|
|
473
474
|
class MixAnthropic extends MixCustom {
|
|
474
475
|
getDefaultConfig(customConfig) {
|
|
475
|
-
if (!customConfig.apiKey && !process.env.ANTHROPIC_API_KEY) {
|
|
476
|
-
throw new Error('Anthropic API key not found. Please provide it in customConfig or set ANTHROPIC_API_KEY environment variable.');
|
|
477
|
-
}
|
|
478
476
|
return super.getDefaultConfig({
|
|
479
477
|
url: 'https://api.anthropic.com/v1/messages',
|
|
480
478
|
prefix: ['claude'],
|
|
@@ -483,6 +481,15 @@ class MixAnthropic extends MixCustom {
|
|
|
483
481
|
});
|
|
484
482
|
}
|
|
485
483
|
|
|
484
|
+
create(args = { config: {}, options: {} }) {
|
|
485
|
+
if (!this.config.apiKey) {
|
|
486
|
+
throw new Error('Anthropic API key not found. Please provide it in config or set ANTHROPIC_API_KEY environment variable.');
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
args.options.system = args.config.system;
|
|
490
|
+
return super.create(args);
|
|
491
|
+
}
|
|
492
|
+
|
|
486
493
|
getDefaultHeaders(customHeaders) {
|
|
487
494
|
return super.getDefaultHeaders({
|
|
488
495
|
'x-api-key': this.config.apiKey,
|
|
@@ -499,18 +506,10 @@ class MixAnthropic extends MixCustom {
|
|
|
499
506
|
processResponse(response) {
|
|
500
507
|
return { response: response.data, message: response.data.content[0].text };
|
|
501
508
|
}
|
|
502
|
-
|
|
503
|
-
create(args = { config: {}, options: {} }) {
|
|
504
|
-
args.options.system = args.config.system;
|
|
505
|
-
return super.create(args);
|
|
506
|
-
}
|
|
507
509
|
}
|
|
508
510
|
|
|
509
511
|
class MixPerplexity extends MixCustom {
|
|
510
512
|
getDefaultConfig(customConfig) {
|
|
511
|
-
if (!customConfig.apiKey && !process.env.PPLX_API_KEY) {
|
|
512
|
-
throw new Error('Perplexity API key not found. Please provide it in customConfig or set PPLX_API_KEY environment variable.');
|
|
513
|
-
}
|
|
514
513
|
return super.getDefaultConfig({
|
|
515
514
|
url: 'https://api.perplexity.ai/chat/completions',
|
|
516
515
|
prefix: ['llama-3', 'mixtral'],
|
|
@@ -520,6 +519,10 @@ class MixPerplexity extends MixCustom {
|
|
|
520
519
|
}
|
|
521
520
|
|
|
522
521
|
create(args = { config: {}, options: {} }) {
|
|
522
|
+
if (!this.config.apiKey) {
|
|
523
|
+
throw new Error('Perplexity API key not found. Please provide it in config or set PPLX_API_KEY environment variable.');
|
|
524
|
+
}
|
|
525
|
+
|
|
523
526
|
args.options.messages = [{ role: 'system', content: args.config.system }, ...args.options.messages || []];
|
|
524
527
|
return super.create(args);
|
|
525
528
|
}
|
|
@@ -595,9 +598,6 @@ class MixLMStudio extends MixCustom {
|
|
|
595
598
|
|
|
596
599
|
class MixGroq extends MixCustom {
|
|
597
600
|
getDefaultConfig(customConfig) {
|
|
598
|
-
if (!customConfig.apiKey && !process.env.GROQ_API_KEY) {
|
|
599
|
-
throw new Error('Groq API key not found. Please provide it in customConfig or set GROQ_API_KEY environment variable.');
|
|
600
|
-
}
|
|
601
601
|
return super.getDefaultConfig({
|
|
602
602
|
url: 'https://api.groq.com/openai/v1/chat/completions',
|
|
603
603
|
prefix: ["llama", "mixtral", "gemma", "deepseek-r1-distill"],
|
|
@@ -607,6 +607,10 @@ class MixGroq extends MixCustom {
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
create(args = { config: {}, options: {} }) {
|
|
610
|
+
if (!this.config.apiKey) {
|
|
611
|
+
throw new Error('Groq API key not found. Please provide it in config or set GROQ_API_KEY environment variable.');
|
|
612
|
+
}
|
|
613
|
+
|
|
610
614
|
args.options.messages = [{ role: 'system', content: args.config.system }, ...args.options.messages || []];
|
|
611
615
|
args.options.messages = MixOpenAI.convertMessages(args.options.messages);
|
|
612
616
|
return super.create(args);
|
|
@@ -615,9 +619,6 @@ class MixGroq extends MixCustom {
|
|
|
615
619
|
|
|
616
620
|
class MixTogether extends MixCustom {
|
|
617
621
|
getDefaultConfig(customConfig) {
|
|
618
|
-
if (!customConfig.apiKey && !process.env.TOGETHER_API_KEY) {
|
|
619
|
-
throw new Error('Together API key not found. Please provide it in customConfig or set TOGETHER_API_KEY environment variable.');
|
|
620
|
-
}
|
|
621
622
|
return super.getDefaultConfig({
|
|
622
623
|
url: 'https://api.together.xyz/v1/chat/completions',
|
|
623
624
|
prefix: ["meta-llama", "google", "NousResearch", "deepseek-ai"],
|
|
@@ -643,6 +644,10 @@ class MixTogether extends MixCustom {
|
|
|
643
644
|
}
|
|
644
645
|
|
|
645
646
|
create(args = { config: {}, options: {} }) {
|
|
647
|
+
if (!this.config.apiKey) {
|
|
648
|
+
throw new Error('Together API key not found. Please provide it in config or set TOGETHER_API_KEY environment variable.');
|
|
649
|
+
}
|
|
650
|
+
|
|
646
651
|
args.options.messages = [{ role: 'system', content: args.config.system }, ...args.options.messages || []];
|
|
647
652
|
args.options.messages = this.convertMessages(args.options.messages);
|
|
648
653
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modelmix",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "🧬 ModelMix - Unified API for Diverse AI LLM.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,30 +13,27 @@
|
|
|
13
13
|
"model",
|
|
14
14
|
"openai",
|
|
15
15
|
"anthropic",
|
|
16
|
-
"
|
|
16
|
+
"agent",
|
|
17
17
|
"perplexity",
|
|
18
|
-
"sonnet-3
|
|
18
|
+
"sonnet-3",
|
|
19
19
|
"gpt",
|
|
20
20
|
"claude",
|
|
21
21
|
"llama",
|
|
22
22
|
"mixtral",
|
|
23
|
-
"nlp",
|
|
24
23
|
"chat",
|
|
25
24
|
"multimodal",
|
|
26
25
|
"groq",
|
|
27
|
-
"gpt-4o-mini",
|
|
28
|
-
"4o",
|
|
29
26
|
"ollama",
|
|
30
27
|
"lmstudio",
|
|
31
28
|
"together",
|
|
32
29
|
"o1",
|
|
33
|
-
"o1-mini",
|
|
34
30
|
"deepseek",
|
|
35
31
|
"o3",
|
|
36
32
|
"o3-mini",
|
|
37
33
|
"nousresearch",
|
|
38
|
-
"
|
|
34
|
+
"reasoning",
|
|
39
35
|
"bottleneck",
|
|
36
|
+
"claude-3-7-sonnet",
|
|
40
37
|
"clasen"
|
|
41
38
|
],
|
|
42
39
|
"author": "Martin Clasen",
|