@smythos/sre 1.5.72 → 1.5.74

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smythos/sre",
3
- "version": "1.5.72",
3
+ "version": "1.5.74",
4
4
  "description": "Smyth Runtime Environment",
5
5
  "author": "Alaa-eddine KADDOURI",
6
6
  "license": "MIT",
@@ -47,7 +47,7 @@ export class JSONModelsProvider extends ModelsProviderConnector {
47
47
 
48
48
  this.models = JSON.parse(JSON.stringify(models));
49
49
  if (typeof this._settings.models === 'string') {
50
- this.initDirWatcher(this._settings.models);
50
+ this.initDirWatcher(this._settings.models); //this.started will be set to true when the watcher is ready
51
51
  } else if (typeof this._settings.models === 'object') {
52
52
  if (this._settings.mode === 'merge') this.models = { ...this.models, ...(this._settings.models as TLLMModelsList) };
53
53
  else this.models = this._settings.models as TLLMModelsList;
@@ -55,9 +55,9 @@ export class JSONModelsProvider extends ModelsProviderConnector {
55
55
  } else {
56
56
  const modelsFolder = this.findModelsFolder();
57
57
  if (modelsFolder) {
58
- this.initDirWatcher(modelsFolder);
58
+ this._settings.mode = 'merge'; //Force merge mode if using models from .smyth folder
59
+ this.initDirWatcher(modelsFolder); //this.started will be set to true when the watcher is ready
59
60
  }
60
- this.started = true;
61
61
  }
62
62
  }
63
63
  public async start() {
@@ -212,11 +212,14 @@ export class JSONModelsProvider extends ModelsProviderConnector {
212
212
  if (stats.isFile()) {
213
213
  //load the file
214
214
  const fileContent = fsSync.readFileSync(dir, 'utf-8');
215
- const modelData = JSON.parse(fileContent);
216
-
217
- if (this._settings?.mode === 'merge') this.models = { ...this.models, ...modelData };
218
- else this.models = modelData;
215
+ try {
216
+ const modelData = JSON.parse(fileContent);
219
217
 
218
+ if (this._settings?.mode === 'merge') this.models = { ...this.models, ...modelData };
219
+ else this.models = modelData;
220
+ } catch (error) {
221
+ console.error(`Error parsing model data from file "${dir}":`, error);
222
+ }
220
223
  this.started = true;
221
224
  return;
222
225
  }