modelmix 1.2.0 → 1.2.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 CHANGED
@@ -45,7 +45,7 @@ Here's a quick example to get you started:
45
45
 
46
46
  const env = process.env;
47
47
 
48
- const driver = new ModelMix({
48
+ const mmix = new ModelMix({
49
49
  options: {
50
50
  max_tokens: 200,
51
51
  },
@@ -55,9 +55,9 @@ Here's a quick example to get you started:
55
55
  }
56
56
  });
57
57
 
58
- driver.attach(new OpenAIModel(new OpenAI({ apiKey: env.OPENAI_API_KEY })));
59
- driver.attach(new AnthropicModel(new Anthropic({ apiKey: env.ANTHROPIC_API_KEY })));
60
- driver.attach(new CustomModel({
58
+ mmix.attach(new OpenAIModel(new OpenAI({ apiKey: env.OPENAI_API_KEY })));
59
+ mmix.attach(new AnthropicModel(new Anthropic({ apiKey: env.ANTHROPIC_API_KEY })));
60
+ mmix.attach(new CustomModel({
61
61
  config: {
62
62
  url: 'https://api.perplexity.ai/chat/completions',
63
63
  bearer: env.PPLX_API_KEY,
@@ -70,16 +70,16 @@ Here's a quick example to get you started:
70
70
  3. **Generate responses from different models**:
71
71
 
72
72
  ```javascript
73
- const claude = await driver.create('claude-3-sonnet-20240229', { temperature: 0.5 });
73
+
74
+ const gpt = mmix.create('gpt-4o', { temperature: 0.5 }).addText("Have you ever eaten a cat?");
75
+ console.log(await gpt.message());
76
+
77
+ const claude = mmix.create('claude-3-sonnet-20240229', { temperature: 0.5 });
74
78
  await claude.addImage("./watson.png")
75
79
  const imageDescription = await claude.addText("describe the image").message();
76
80
  console.log(imageDescription);
77
81
 
78
- const gpt = await driver.create('gpt-4o', { temperature: 0.5 });
79
- const question = await gpt.addText("Have you ever eaten a cat?").message();
80
- console.log(question);
81
-
82
- const pplx = await driver.create('pplx-70b-online', { max_tokens: 500 });
82
+ const pplx = mmix.create('pplx-70b-online', { max_tokens: 500 });
83
83
  await pplx.addText('How much is ETH trading in USD?');
84
84
  const news = await pplx.addText('What are the 3 most recent Ethereum news?').message();
85
85
  console.log(news);
package/demo/demo.mjs CHANGED
@@ -13,7 +13,8 @@ const mmix = new ModelMix({
13
13
  },
14
14
  config: {
15
15
  system: "You are ALF from Melmac.",
16
- max_history: 2
16
+ max_history: 2,
17
+ max_request: 1,
17
18
  }
18
19
  });
19
20
 
@@ -29,18 +30,17 @@ mmix.attach(new CustomModel({
29
30
  }));
30
31
 
31
32
  console.log("\n" + '--------| gpt-4o |--------');
32
- const gpt = await mmix.create('gpt-4o', { temperature: 0.5 });
33
- const question = await gpt.addText("Have you ever eaten a cat?").message();
34
- console.log(question);
33
+ const gpt = mmix.create('gpt-4o', { temperature: 0.5 }).addText("Have you ever eaten a cat?");
34
+ console.log(await gpt.message());
35
35
 
36
36
  console.log("\n" + '--------| claude-3-sonnet-20240229 |--------');
37
- const claude = await mmix.create('claude-3-sonnet-20240229', { temperature: 0.5 });
37
+ const claude = mmix.create('claude-3-sonnet-20240229', { temperature: 0.5 });
38
38
  await claude.addImage("./watson.png")
39
39
  const imageDescription = await claude.addText("describe the image").message();
40
40
  console.log(imageDescription);
41
41
 
42
42
  console.log("\n" + '--------| pplx-70b-online |--------');
43
- const pplx = await mmix.create('pplx-70b-online', { max_tokens: 500 });
43
+ const pplx = mmix.create('pplx-70b-online', { max_tokens: 500 });
44
44
  await pplx.addText('How much is ETH trading in USD?');
45
45
  const news = await pplx.addText('What are the 3 most recent Ethereum news?').message();
46
46
  console.log(news);
package/index.js CHANGED
@@ -28,7 +28,7 @@ class ModelMix {
28
28
  modelInstance.active_requests = 0;
29
29
  }
30
30
 
31
- async create(modelKey, overOptions = {}) {
31
+ create(modelKey, overOptions = {}) {
32
32
  const modelEntry = Object.values(this.models).find(entry =>
33
33
  entry.config.prefix.some(p => modelKey.startsWith(p))
34
34
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelmix",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "🧬 ModelMix - Unified API for Diverse AI Language Models.",
5
5
  "main": "index.js",
6
6
  "repository": {