spice-js 2.6.50 → 2.6.51
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/build/nova/Ai.js +17 -17
- package/package.json +1 -1
- package/src/nova/Ai.js +11 -12
package/build/nova/Ai.js
CHANGED
|
@@ -66,10 +66,13 @@ class AI {
|
|
|
66
66
|
_fs.default.mkdirSync(outputDir, {
|
|
67
67
|
recursive: true
|
|
68
68
|
});
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
|
|
71
|
+
var timestamp = new Date().toISOString().replace(/[:.-]/g, "");
|
|
72
|
+
var randomString = crypto.randomBytes(4).toString("hex");
|
|
73
|
+
var uniqueDirName = "file_" + timestamp + "_" + randomString; // Create a temporary file to store the input
|
|
71
74
|
|
|
72
|
-
var tempFilePath = path.join(outputDir,
|
|
75
|
+
var tempFilePath = path.join(outputDir, uniqueDirName); // Check if fileData is a buffer or a stream
|
|
73
76
|
|
|
74
77
|
if (Buffer.isBuffer(fileData)) {
|
|
75
78
|
// It's a buffer, write it directly to the temp file
|
|
@@ -85,9 +88,10 @@ class AI {
|
|
|
85
88
|
|
|
86
89
|
if (_lodash.default.includes(supportedFileTypes, fileType)) {
|
|
87
90
|
// If it's a JPEG or PNG, just move it to the output directory
|
|
88
|
-
var
|
|
91
|
+
var _timestamp = new Date().toISOString().replace(/[:.-]/g, "");
|
|
92
|
+
|
|
89
93
|
var extension = fileType === "jpeg" ? "jpg" : fileType;
|
|
90
|
-
var outputPath = path.join(outputDir,
|
|
94
|
+
var outputPath = path.join(outputDir, _timestamp + "." + extension);
|
|
91
95
|
|
|
92
96
|
_fs.default.renameSync(tempFilePath, outputPath);
|
|
93
97
|
|
|
@@ -235,18 +239,14 @@ class AI {
|
|
|
235
239
|
|
|
236
240
|
var outputDir = _this3.createUniqueDirectory();
|
|
237
241
|
|
|
238
|
-
|
|
239
|
-
/*#__PURE__*/
|
|
240
|
-
function () {
|
|
241
|
-
var _ref = _asyncToGenerator(function* (fileData) {
|
|
242
|
-
var imagePaths = yield _this3.extractOrStoreFile(fileData, outputDir, types);
|
|
243
|
-
return imagePaths;
|
|
244
|
-
});
|
|
242
|
+
var results = [];
|
|
245
243
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
244
|
+
for (var fileData of files) {
|
|
245
|
+
var imagePaths = yield _this3.extractOrStoreFile(fileData, outputDir, types);
|
|
246
|
+
results.push(imagePaths);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return results.flat();
|
|
250
250
|
})();
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -259,7 +259,7 @@ class AI {
|
|
|
259
259
|
return provider.getSupportedTypes();
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
prompt(prompt,
|
|
262
|
+
prompt(prompt, _ref, options) {
|
|
263
263
|
var _this4 = this;
|
|
264
264
|
|
|
265
265
|
return _asyncToGenerator(function* () {
|
|
@@ -267,7 +267,7 @@ class AI {
|
|
|
267
267
|
files,
|
|
268
268
|
system_message,
|
|
269
269
|
prompt_options
|
|
270
|
-
} =
|
|
270
|
+
} = _ref;
|
|
271
271
|
var context_files = yield _this4.processFiles(files);
|
|
272
272
|
|
|
273
273
|
try {
|
package/package.json
CHANGED
package/src/nova/Ai.js
CHANGED
|
@@ -205,19 +205,18 @@ export default class AI {
|
|
|
205
205
|
async processFiles(files) {
|
|
206
206
|
let types = this.getSupportedFileTypes();
|
|
207
207
|
const outputDir = this.createUniqueDirectory();
|
|
208
|
+
let results = [];
|
|
209
|
+
|
|
210
|
+
for (const fileData of files) {
|
|
211
|
+
const imagePaths = await this.extractOrStoreFile(
|
|
212
|
+
fileData,
|
|
213
|
+
outputDir,
|
|
214
|
+
types
|
|
215
|
+
);
|
|
216
|
+
results.push(imagePaths);
|
|
217
|
+
}
|
|
208
218
|
|
|
209
|
-
return (
|
|
210
|
-
await Promise.all(
|
|
211
|
-
files.map(async (fileData) => {
|
|
212
|
-
const imagePaths = await this.extractOrStoreFile(
|
|
213
|
-
fileData,
|
|
214
|
-
outputDir,
|
|
215
|
-
types
|
|
216
|
-
);
|
|
217
|
-
return imagePaths;
|
|
218
|
-
})
|
|
219
|
-
)
|
|
220
|
-
).flat();
|
|
219
|
+
return results.flat();
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
getSupportedFileTypes(options) {
|