modelmix 1.1.6 → 1.1.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 +7 -7
- package/index.js +2 -1
- package/package.json +1 -1
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
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
}
|
|
@@ -27,7 +28,7 @@ class ModelMix {
|
|
|
27
28
|
modelInstance.active_requests = 0;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
create(modelKey, overOptions = {}) {
|
|
31
32
|
const modelEntry = Object.values(this.models).find(entry =>
|
|
32
33
|
entry.config.prefix.some(p => modelKey.startsWith(p))
|
|
33
34
|
);
|