modelmix 1.1.6 → 1.2.0

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
@@ -90,10 +90,6 @@ Here's a quick example to get you started:
90
90
 
91
91
  ## 📚 ModelMix Class Overview
92
92
 
93
- #### ModelMix
94
-
95
- **Constructor**
96
-
97
93
  ```javascript
98
94
  new ModelMix(args = { options: {}, config: {} })
99
95
  ```
@@ -107,6 +103,7 @@ new ModelMix(args = { options: {}, config: {} })
107
103
  - `system`: Sets the default system message for the model, e.g., "You are an assistant."
108
104
  - `max_history`: Limits the number of historical messages to retain, e.g., 5.
109
105
  - `max_request`: Limits the number of parallel request.
106
+ - ...
110
107
 
111
108
  **Methods**
112
109
 
@@ -125,8 +122,6 @@ new ModelMix(args = { options: {}, config: {} })
125
122
 
126
123
  #### OpenAIModel
127
124
 
128
- **Constructor**
129
-
130
125
  ```javascript
131
126
  new OpenAIModel(openai, args = { options: {}, config: {} })
132
127
  ```
@@ -136,8 +131,6 @@ new OpenAIModel(openai, args = { options: {}, config: {} })
136
131
 
137
132
  #### AnthropicModel
138
133
 
139
- **Constructor**
140
-
141
134
  ```javascript
142
135
  new AnthropicModel(anthropic, args = { options: {}, config: {} })
143
136
  ```
@@ -147,13 +140,21 @@ new AnthropicModel(anthropic, args = { options: {}, config: {} })
147
140
 
148
141
  #### CustomModel
149
142
 
150
- **Constructor**
151
-
152
143
  ```javascript
153
144
  new CustomModel(args = { config: {}, options: {} })
154
145
  ```
155
146
 
156
147
  - **args**: Configuration object with `config` and `options` properties.
148
+ - **config**:
149
+ - `url`:
150
+ - `bearer`:
151
+ - `prefix`:
152
+ - ...
153
+ - **options**: This object contains default options that are applied to all models. These options can be overridden when creating a specific model instance. Examples of default options include:
154
+ - `max_tokens`: Sets the maximum number of tokens to generate, e.g., 2000.
155
+ - `temperature`: Controls the randomness of the model's output, e.g., 1.
156
+ - `top_p`: Controls the diversity of the output, e.g., 1.
157
+ - ...
157
158
 
158
159
  ## 🤝 Contributing
159
160
 
package/demo/demo.mjs CHANGED
@@ -7,7 +7,7 @@ import { ModelMix, OpenAIModel, AnthropicModel, CustomModel } from '../index.js'
7
7
 
8
8
  const env = process.env;
9
9
 
10
- const driver = new ModelMix({
10
+ const mmix = new ModelMix({
11
11
  options: {
12
12
  max_tokens: 200,
13
13
  },
@@ -17,9 +17,9 @@ const driver = new ModelMix({
17
17
  }
18
18
  });
19
19
 
20
- driver.attach(new OpenAIModel(new OpenAI({ apiKey: env.OPENAI_API_KEY })));
21
- driver.attach(new AnthropicModel(new Anthropic({ apiKey: env.ANTHROPIC_API_KEY })));
22
- driver.attach(new CustomModel({
20
+ mmix.attach(new OpenAIModel(new OpenAI({ apiKey: env.OPENAI_API_KEY })));
21
+ mmix.attach(new AnthropicModel(new Anthropic({ apiKey: env.ANTHROPIC_API_KEY })));
22
+ mmix.attach(new CustomModel({
23
23
  config: {
24
24
  url: 'https://api.perplexity.ai/chat/completions',
25
25
  bearer: env.PPLX_API_KEY,
@@ -29,18 +29,18 @@ driver.attach(new CustomModel({
29
29
  }));
30
30
 
31
31
  console.log("\n" + '--------| gpt-4o |--------');
32
- const gpt = await driver.create('gpt-4o', { temperature: 0.5 });
32
+ const gpt = await mmix.create('gpt-4o', { temperature: 0.5 });
33
33
  const question = await gpt.addText("Have you ever eaten a cat?").message();
34
34
  console.log(question);
35
35
 
36
36
  console.log("\n" + '--------| claude-3-sonnet-20240229 |--------');
37
- const claude = await driver.create('claude-3-sonnet-20240229', { temperature: 0.5 });
37
+ const claude = await 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 driver.create('pplx-70b-online', { max_tokens: 500 });
43
+ const pplx = await 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
@@ -15,6 +15,7 @@ class ModelMix {
15
15
 
16
16
  this.config = {
17
17
  system: 'You are an assistant.',
18
+ max_request: 1,
18
19
  max_history: 5, // Default max history
19
20
  ...args.config
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelmix",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "description": "🧬 ModelMix - Unified API for Diverse AI Language Models.",
5
5
  "main": "index.js",
6
6
  "repository": {