modelmix 2.2.0 → 2.2.4

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.
Files changed (2) hide show
  1. package/index.js +9 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -28,7 +28,7 @@ class ModelMix {
28
28
  return this;
29
29
  }
30
30
 
31
- create(modelKey, overOptions = {}) {
31
+ create(modelKey, args = { config: {}, options: {} }) {
32
32
  const modelEntry = Object.values(this.models).find(entry =>
33
33
  entry.config.prefix.some(p => modelKey.startsWith(p))
34
34
  );
@@ -40,10 +40,15 @@ class ModelMix {
40
40
  const options = {
41
41
  ...this.defaultOptions,
42
42
  ...modelEntry.options,
43
- ...overOptions,
43
+ ...args.options,
44
44
  model: modelKey
45
45
  };
46
- const config = { ...this.config, ...modelEntry.config };
46
+
47
+ const config = {
48
+ ...this.config,
49
+ ...modelEntry.config,
50
+ ...args.config
51
+ };
47
52
 
48
53
  return new MessageHandler(this, modelEntry, options, config);
49
54
  }
@@ -159,13 +164,13 @@ class MessageHandler {
159
164
  }
160
165
 
161
166
  async execute() {
167
+ this.messages = this.messages.slice(-this.config.max_history);
162
168
  this.messages = this.groupByRoles(this.messages);
163
169
 
164
170
  if (this.messages.length === 0) {
165
171
  throw new Error("No user messages have been added. Use addMessage(prompt) to add a message.");
166
172
  }
167
173
 
168
- this.messages = this.messages.slice(-this.config.max_history);
169
174
  this.options.messages = this.messages;
170
175
 
171
176
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelmix",
3
- "version": "2.2.0",
3
+ "version": "2.2.4",
4
4
  "description": "🧬 ModelMix - Unified API for Diverse AI Language Models.",
5
5
  "main": "index.js",
6
6
  "repository": {