modelmix 2.4.6 → 2.4.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/index.js +56 -15
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -120,6 +120,21 @@ class MessageHandler {
|
|
|
120
120
|
return this;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
setSystem(text) {
|
|
124
|
+
this.config.system = text;
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setSystemFromFile(filePath) {
|
|
129
|
+
try {
|
|
130
|
+
const content = fs.readFileSync(filePath, { encoding: 'utf8' });
|
|
131
|
+
this.setSystem(content);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error(`Error reading system message file ${filePath}:`, error);
|
|
134
|
+
}
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
123
138
|
addImage(filePath, config = { role: "user" }) {
|
|
124
139
|
try {
|
|
125
140
|
const imageBuffer = fs.readFileSync(filePath);
|
|
@@ -320,25 +335,51 @@ class MixCustom {
|
|
|
320
335
|
}
|
|
321
336
|
|
|
322
337
|
async create(args = { config: {}, options: {} }) {
|
|
338
|
+
try {
|
|
339
|
+
if (args.config.debug) {
|
|
340
|
+
log.info("config");
|
|
341
|
+
log.info(args.config);
|
|
342
|
+
log.inspect("options");
|
|
343
|
+
log.inspect(args.options);
|
|
344
|
+
}
|
|
323
345
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
346
|
+
if (args.options.stream) {
|
|
347
|
+
return this.processStream(await axios.post(this.config.url, args.options, {
|
|
348
|
+
headers: this.headers,
|
|
349
|
+
responseType: 'stream'
|
|
350
|
+
}));
|
|
351
|
+
} else {
|
|
352
|
+
return this.processResponse(await axios.post(this.config.url, args.options, {
|
|
353
|
+
headers: this.headers
|
|
354
|
+
}));
|
|
355
|
+
}
|
|
356
|
+
} catch (error) {
|
|
357
|
+
throw this.handleError(error, args);
|
|
329
358
|
}
|
|
359
|
+
}
|
|
330
360
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
361
|
+
handleError(error, args) {
|
|
362
|
+
let errorMessage = 'An error occurred in MixCustom';
|
|
363
|
+
let statusCode = null;
|
|
364
|
+
let errorDetails = null;
|
|
365
|
+
|
|
366
|
+
if (error.isAxiosError) {
|
|
367
|
+
statusCode = error.response ? error.response.status : null;
|
|
368
|
+
errorMessage = `Request to ${this.config.url} failed with status code ${statusCode}`;
|
|
369
|
+
errorDetails = error.response ? error.response.data : null;
|
|
340
370
|
}
|
|
341
|
-
|
|
371
|
+
|
|
372
|
+
const formattedError = {
|
|
373
|
+
message: errorMessage,
|
|
374
|
+
statusCode,
|
|
375
|
+
details: errorDetails,
|
|
376
|
+
stack: error.stack,
|
|
377
|
+
config: args.config,
|
|
378
|
+
options: args.options
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
return formattedError;
|
|
382
|
+
}
|
|
342
383
|
|
|
343
384
|
processStream(response) {
|
|
344
385
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modelmix",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.8",
|
|
4
4
|
"description": "🧬 ModelMix - Unified API for Diverse AI LLM.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"chat",
|
|
25
25
|
"multimodal",
|
|
26
26
|
"groq",
|
|
27
|
-
"
|
|
27
|
+
"gpt-4o-mini",
|
|
28
28
|
"4o",
|
|
29
29
|
"ollama",
|
|
30
30
|
"lmstudio"
|