modelmix 1.1.8 → 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 +21 -20
- package/demo/demo.mjs +6 -6
- package/package.json +1 -1
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
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
|
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);
|
|
@@ -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
|
@@ -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 =
|
|
33
|
-
|
|
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 =
|
|
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 =
|
|
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);
|