modelmix 4.2.6 → 4.2.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/README.md CHANGED
@@ -11,6 +11,7 @@ Ever found yourself wanting to integrate AI models into your projects but worrie
11
11
  - **Flexible Integration**: Easily integrate popular models like OpenAI, Anthropic, Gemini, Perplexity, Groq, Together AI, Lambda, OpenRouter, Ollama, LM Studio or custom models.
12
12
  - **History Tracking**: Automatically logs the conversation history with model responses, allowing you to limit the number of historical messages with `max_history`.
13
13
  - **Model Fallbacks**: Automatically try different models if one fails or is unavailable.
14
+ - **Round Robin Load Balancing**: Rotate through multiple models on each request to distribute load and maximize free tier quotas.
14
15
  - **Chain Multiple Models**: Create powerful chains of models that work together, with automatic fallback if one fails.
15
16
  - **Model Context Protocol (MCP) Support**: Seamlessly integrate external tools and capabilities like web search, code execution, or custom functions through the Model Context Protocol standard.
16
17
 
@@ -354,6 +355,7 @@ new ModelMix(args = { options: {}, config: {} })
354
355
  - **config**: This object contains configuration settings that control the behavior of the `ModelMix` instance. These settings can also be overridden for specific model instances. Examples of configuration settings include:
355
356
  - `system`: Sets the default system message for the model, e.g., "You are an assistant."
356
357
  - `max_history`: Limits the number of historical messages to retain, e.g., 1.
358
+ - `roundRobin`: When `true`, rotates through attached models on each request for load balancing. When `false` (default), uses fallback mode where models are tried sequentially only if previous ones fail.
357
359
  - `bottleneck`: Configures the rate limiting behavior using Bottleneck. For example:
358
360
  - `maxConcurrent`: Maximum number of concurrent requests
359
361
  - `minTime`: Minimum time between requests (in ms)
@@ -9,7 +9,6 @@
9
9
  "version": "1.0.0",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@anthropic-ai/sdk": "^0.20.9",
13
12
  "dotenv": "^17.2.3",
14
13
  "isolated-vm": "^6.0.2",
15
14
  "lemonlog": "^1.1.4"
@@ -25,65 +24,6 @@
25
24
  "oas": "^20.10.3"
26
25
  }
27
26
  },
28
- "node_modules/@anthropic-ai/sdk": {
29
- "version": "0.20.9",
30
- "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.20.9.tgz",
31
- "integrity": "sha512-Lq74+DhiEQO6F9/gdVOLmHx57pX45ebK2Q/zH14xYe1157a7QeUVknRqIp0Jz5gQI01o7NKbuv9Dag2uQsLjDg==",
32
- "dependencies": {
33
- "@types/node": "^18.11.18",
34
- "@types/node-fetch": "^2.6.4",
35
- "abort-controller": "^3.0.0",
36
- "agentkeepalive": "^4.2.1",
37
- "form-data-encoder": "1.7.2",
38
- "formdata-node": "^4.3.2",
39
- "node-fetch": "^2.6.7",
40
- "web-streams-polyfill": "^3.2.1"
41
- }
42
- },
43
- "node_modules/@types/node": {
44
- "version": "18.19.33",
45
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.33.tgz",
46
- "integrity": "sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A==",
47
- "dependencies": {
48
- "undici-types": "~5.26.4"
49
- }
50
- },
51
- "node_modules/@types/node-fetch": {
52
- "version": "2.6.11",
53
- "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz",
54
- "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==",
55
- "dependencies": {
56
- "@types/node": "*",
57
- "form-data": "^4.0.0"
58
- }
59
- },
60
- "node_modules/abort-controller": {
61
- "version": "3.0.0",
62
- "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
63
- "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
64
- "dependencies": {
65
- "event-target-shim": "^5.0.0"
66
- },
67
- "engines": {
68
- "node": ">=6.5"
69
- }
70
- },
71
- "node_modules/agentkeepalive": {
72
- "version": "4.5.0",
73
- "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz",
74
- "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==",
75
- "dependencies": {
76
- "humanize-ms": "^1.2.1"
77
- },
78
- "engines": {
79
- "node": ">= 8.0.0"
80
- }
81
- },
82
- "node_modules/asynckit": {
83
- "version": "0.4.0",
84
- "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
85
- "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
86
- },
87
27
  "node_modules/base64-js": {
88
28
  "version": "1.5.1",
89
29
  "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -145,17 +85,6 @@
145
85
  "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
146
86
  "license": "ISC"
147
87
  },
148
- "node_modules/combined-stream": {
149
- "version": "1.0.8",
150
- "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
151
- "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
152
- "dependencies": {
153
- "delayed-stream": "~1.0.0"
154
- },
155
- "engines": {
156
- "node": ">= 0.8"
157
- }
158
- },
159
88
  "node_modules/debug": {
160
89
  "version": "4.4.1",
161
90
  "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
@@ -197,14 +126,6 @@
197
126
  "node": ">=4.0.0"
198
127
  }
199
128
  },
200
- "node_modules/delayed-stream": {
201
- "version": "1.0.0",
202
- "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
203
- "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
204
- "engines": {
205
- "node": ">=0.4.0"
206
- }
207
- },
208
129
  "node_modules/detect-libc": {
209
130
  "version": "2.1.2",
210
131
  "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
@@ -235,14 +156,6 @@
235
156
  "once": "^1.4.0"
236
157
  }
237
158
  },
238
- "node_modules/event-target-shim": {
239
- "version": "5.0.1",
240
- "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
241
- "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
242
- "engines": {
243
- "node": ">=6"
244
- }
245
- },
246
159
  "node_modules/expand-template": {
247
160
  "version": "2.0.3",
248
161
  "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz",
@@ -252,44 +165,6 @@
252
165
  "node": ">=6"
253
166
  }
254
167
  },
255
- "node_modules/form-data": {
256
- "version": "4.0.0",
257
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
258
- "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
259
- "dependencies": {
260
- "asynckit": "^0.4.0",
261
- "combined-stream": "^1.0.8",
262
- "mime-types": "^2.1.12"
263
- },
264
- "engines": {
265
- "node": ">= 6"
266
- }
267
- },
268
- "node_modules/form-data-encoder": {
269
- "version": "1.7.2",
270
- "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz",
271
- "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="
272
- },
273
- "node_modules/formdata-node": {
274
- "version": "4.4.1",
275
- "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz",
276
- "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==",
277
- "dependencies": {
278
- "node-domexception": "1.0.0",
279
- "web-streams-polyfill": "4.0.0-beta.3"
280
- },
281
- "engines": {
282
- "node": ">= 12.20"
283
- }
284
- },
285
- "node_modules/formdata-node/node_modules/web-streams-polyfill": {
286
- "version": "4.0.0-beta.3",
287
- "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
288
- "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
289
- "engines": {
290
- "node": ">= 14"
291
- }
292
- },
293
168
  "node_modules/fs-constants": {
294
169
  "version": "1.0.0",
295
170
  "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
@@ -302,14 +177,6 @@
302
177
  "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==",
303
178
  "license": "MIT"
304
179
  },
305
- "node_modules/humanize-ms": {
306
- "version": "1.2.1",
307
- "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
308
- "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
309
- "dependencies": {
310
- "ms": "^2.0.0"
311
- }
312
- },
313
180
  "node_modules/ieee754": {
314
181
  "version": "1.2.1",
315
182
  "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
@@ -364,25 +231,6 @@
364
231
  "debug": "^4.1.1"
365
232
  }
366
233
  },
367
- "node_modules/mime-db": {
368
- "version": "1.52.0",
369
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
370
- "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
371
- "engines": {
372
- "node": ">= 0.6"
373
- }
374
- },
375
- "node_modules/mime-types": {
376
- "version": "2.1.35",
377
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
378
- "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
379
- "dependencies": {
380
- "mime-db": "1.52.0"
381
- },
382
- "engines": {
383
- "node": ">= 0.6"
384
- }
385
- },
386
234
  "node_modules/mimic-response": {
387
235
  "version": "3.1.0",
388
236
  "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
@@ -433,43 +281,6 @@
433
281
  "node": ">=10"
434
282
  }
435
283
  },
436
- "node_modules/node-domexception": {
437
- "version": "1.0.0",
438
- "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
439
- "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
440
- "funding": [
441
- {
442
- "type": "github",
443
- "url": "https://github.com/sponsors/jimmywarting"
444
- },
445
- {
446
- "type": "github",
447
- "url": "https://paypal.me/jimmywarting"
448
- }
449
- ],
450
- "engines": {
451
- "node": ">=10.5.0"
452
- }
453
- },
454
- "node_modules/node-fetch": {
455
- "version": "2.7.0",
456
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
457
- "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
458
- "dependencies": {
459
- "whatwg-url": "^5.0.0"
460
- },
461
- "engines": {
462
- "node": "4.x || >=6.0.0"
463
- },
464
- "peerDependencies": {
465
- "encoding": "^0.1.0"
466
- },
467
- "peerDependenciesMeta": {
468
- "encoding": {
469
- "optional": true
470
- }
471
- }
472
- },
473
284
  "node_modules/once": {
474
285
  "version": "1.4.0",
475
286
  "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@@ -667,11 +478,6 @@
667
478
  "node": ">=6"
668
479
  }
669
480
  },
670
- "node_modules/tr46": {
671
- "version": "0.0.3",
672
- "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
673
- "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
674
- },
675
481
  "node_modules/tunnel-agent": {
676
482
  "version": "0.6.0",
677
483
  "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@@ -684,39 +490,12 @@
684
490
  "node": "*"
685
491
  }
686
492
  },
687
- "node_modules/undici-types": {
688
- "version": "5.26.5",
689
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
690
- "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
691
- },
692
493
  "node_modules/util-deprecate": {
693
494
  "version": "1.0.2",
694
495
  "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
695
496
  "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
696
497
  "license": "MIT"
697
498
  },
698
- "node_modules/web-streams-polyfill": {
699
- "version": "3.3.3",
700
- "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
701
- "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
702
- "engines": {
703
- "node": ">= 8"
704
- }
705
- },
706
- "node_modules/webidl-conversions": {
707
- "version": "3.0.1",
708
- "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
709
- "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
710
- },
711
- "node_modules/whatwg-url": {
712
- "version": "5.0.0",
713
- "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
714
- "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
715
- "dependencies": {
716
- "tr46": "~0.0.3",
717
- "webidl-conversions": "^3.0.0"
718
- }
719
- },
720
499
  "node_modules/wrappy": {
721
500
  "version": "1.0.2",
722
501
  "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
package/demo/package.json CHANGED
@@ -5,12 +5,14 @@
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "rlm-basic": "node rlm-basic.js",
10
+ "rlm-simple": "node rlm-simple.js",
11
+ "repl-powers": "node repl-powers.js"
9
12
  },
10
13
  "author": "",
11
14
  "license": "ISC",
12
15
  "dependencies": {
13
- "@anthropic-ai/sdk": "^0.20.9",
14
16
  "dotenv": "^17.2.3",
15
17
  "isolated-vm": "^6.0.2",
16
18
  "lemonlog": "^1.1.4"