modelmix 2.4.8 → 2.5.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
@@ -80,45 +80,42 @@ Here's a quick example to get you started:
80
80
 
81
81
  3. **Generate responses from different models**:
82
82
 
83
+ #### gpt-4o-mini
83
84
  ```javascript
84
- console.log("\n" + '--------| gpt-4o |--------');
85
- const gpt = mmix.create('gpt-4o', { temperature: 0.5 });
85
+ const gpt = mmix.create('gpt-4o-mini', { options: { temperature: 0 } });
86
86
  gpt.addText("Have you ever eaten a {animal}?");
87
87
  gpt.replace({ '{animal}': 'cat' });
88
88
  console.log(await gpt.message());
89
89
  ```
90
90
 
91
+ #### claude-3-5-sonnet-20240620 (writer)
91
92
  ```javascript
92
- console.log("\n" + '--------| [writer] claude-3-5-sonnet-20240620 |--------');
93
- const setup = {
94
- config: { system: "You are a writer like Stephen King" },
95
- options: { temperature: 0.5 }
96
- }
97
- const writer = mmix.create('claude-3-5-sonnet-20240620', setup);
93
+ const writer = mmix.create('claude-3-5-sonnet-20240620', { options: { temperature: 0.5 } });
94
+ writer.setSystem('You are a writer like Stephen King'); // or setSystemFromFile
98
95
  writer.replace({ '{story_title}': 'The Mysterious Package' })
99
96
  // or write.replaceKeyFromFile('{story_title}', './title.md');
100
97
  const story = await writer.addTextFromFile('./prompt.md').message();
101
98
  console.log(story);
102
99
  ```
103
-
100
+ #### claude-3-5-sonnet-20240620 (image)
104
101
  ```javascript
105
- console.log("\n" + '--------| [image] claude-3-5-sonnet-20240620 |--------');
106
- const claude = mmix.create('claude-3-5-sonnet-20240620', { temperature: 0.5 });
102
+ console.log("\n" + '--------| |--------');
103
+ const claude = mmix.create('claude-3-5-sonnet-20240620', { options: { temperature: 0 } });
107
104
  claude.addImage("./watson.jpg"); // or claude.addImageFromUrl(url)
108
105
  const imageDescription = await claude.addText("Describe the image").message();
109
106
  console.log(imageDescription);
110
107
  ```
111
108
 
109
+ #### pplx-70b-online
112
110
  ```javascript
113
- console.log("\n" + '--------| pplx-70b-online |--------');
114
- const pplx = mmix.create('pplx-70b-online', { max_tokens: 500 });
111
+ const pplx = mmix.create('pplx-70b-online', { config: { max_tokens: 500 } });
115
112
  pplx.addText('How much is ETH trading in USD?');
116
113
  const news = await pplx.addText('What are the 3 most recent Ethereum news?').message();
117
114
  console.log(news);
118
115
  ```
119
116
 
117
+ #### ollama (llava:latest)
120
118
  ```javascript
121
- console.log("\n" + '--------| ollama (llava:latest) |--------');
122
119
  await mmix.create('llava:latest')
123
120
  .addImage("./watson.jpg")
124
121
  .addText("What is the predominant color?")
package/demo/demo.mjs CHANGED
@@ -17,9 +17,10 @@ mmix.attach(new MixOpenAI());
17
17
  mmix.attach(new MixAnthropic());
18
18
  mmix.attach(new MixPerplexity({
19
19
  config: {
20
- apiKey: process.env.PPLX_API_KEY
20
+ apiKey: process.env.PPLX_API_KEY,
21
+ system: 'You are my personal assistant.'
21
22
  },
22
- system: 'You are my personal assistant.'
23
+
23
24
  }));
24
25
  mmix.attach(new MixOllama({
25
26
  config: {
@@ -33,28 +34,25 @@ mmix.attach(new MixOllama({
33
34
  mmix.replace({ '{name}': 'ALF' });
34
35
 
35
36
  console.log("\n" + '--------| gpt-4o |--------');
36
- const gpt = mmix.create('gpt-4o', { temperature: 0.5 }).addText("Have you ever eaten a {animal}?");
37
+ const gpt = mmix.create('gpt-4o', { options: { temperature: 0 } }).addText("Have you ever eaten a {animal}?");
37
38
  gpt.replace({ '{animal}': 'cat' });
38
39
  console.log(await gpt.message());
39
40
 
40
41
  console.log("\n" + '--------| claude-3-5-sonnet-20240620 |--------');
41
- const claude = mmix.create('claude-3-5-sonnet-20240620', { temperature: 0.5 });
42
+ const claude = mmix.create('claude-3-5-sonnet-20240620', { options: { temperature: 0 } });
42
43
  claude.addImageFromUrl('https://pbs.twimg.com/media/F6-GsjraAAADDGy?format=jpg');
43
44
  const imageDescription = await claude.addText('describe the image').message();
44
45
  console.log(imageDescription);
45
46
 
46
47
  console.log("\n" + '--------| claude-3-5-sonnet-20240620 |--------');
47
- const setup = {
48
- config: { system: "You are a writer like Stephen King" },
49
- options: { temperature: 0.5 }
50
- }
51
- const writer = mmix.create('claude-3-5-sonnet-20240620', setup);
48
+ const writer = mmix.create('claude-3-5-sonnet-20240620', { options: { temperature: 0.5 } });
49
+ writer.setSystem('You are a writer like Stephen King');
52
50
  writer.replaceKeyFromFile('{story_title}', './title.md');
53
51
  const story = await writer.addTextFromFile('./prompt.md').message();
54
52
  console.log(story);
55
53
 
56
54
  console.log("\n" + '--------| llama-3-sonar-large-32k-online |--------');
57
- const pplx = mmix.create('llama-3-sonar-large-32k-online', { max_tokens: 500 });
55
+ const pplx = mmix.create('llama-3-sonar-large-32k-online', { config: { max_tokens: 500 } });
58
56
  pplx.addText('How much is ETH trading in USD?');
59
57
  const news = await pplx.addText('What are the 3 most recent Ethereum news?').message();
60
58
  console.log(news);
package/index.js CHANGED
@@ -337,9 +337,9 @@ class MixCustom {
337
337
  async create(args = { config: {}, options: {} }) {
338
338
  try {
339
339
  if (args.config.debug) {
340
- log.info("config");
340
+ log.debug("config");
341
341
  log.info(args.config);
342
- log.inspect("options");
342
+ log.debug("options");
343
343
  log.inspect(args.options);
344
344
  }
345
345
 
@@ -475,11 +475,11 @@ class MixAnthropic extends MixCustom {
475
475
  });
476
476
  }
477
477
 
478
- getDefaultHeaders(getDefaultHeaders) {
478
+ getDefaultHeaders(customHeaders) {
479
479
  return super.getDefaultHeaders({
480
480
  'x-api-key': this.config.apiKey,
481
481
  'anthropic-version': '2023-06-01',
482
- ...getDefaultHeaders
482
+ ...customHeaders
483
483
  });
484
484
  }
485
485
 
@@ -491,6 +491,11 @@ class MixAnthropic extends MixCustom {
491
491
  processResponse(response) {
492
492
  return { response: response.data, message: response.data.content[0].text };
493
493
  }
494
+
495
+ create(args = { config: {}, options: {} }) {
496
+ args.options.system = args.config.system;
497
+ return super.create(args);
498
+ }
494
499
  }
495
500
 
496
501
  class MixPerplexity extends MixCustom {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelmix",
3
- "version": "2.4.8",
3
+ "version": "2.5.2",
4
4
  "description": "🧬 ModelMix - Unified API for Diverse AI LLM.",
5
5
  "main": "index.js",
6
6
  "repository": {