@smythos/sre 1.5.71 → 1.5.73
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/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.d.ts +1 -0
- package/package.json +1 -1
- package/src/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.ts +18 -2
|
@@ -26,6 +26,7 @@ export declare class JSONModelsProvider extends ModelsProviderConnector {
|
|
|
26
26
|
private models;
|
|
27
27
|
constructor(_settings?: SmythModelsProviderConfig);
|
|
28
28
|
start(): Promise<void>;
|
|
29
|
+
private findModelsFolder;
|
|
29
30
|
addModels(acRequest: AccessRequest, models: TLLMModelsList): Promise<void>;
|
|
30
31
|
getModels(acRequest: AccessRequest): Promise<any>;
|
|
31
32
|
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
package/package.json
CHANGED
package/src/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.ts
CHANGED
|
@@ -14,6 +14,7 @@ import chokidar from 'chokidar';
|
|
|
14
14
|
import fs from 'fs/promises';
|
|
15
15
|
import fsSync from 'fs';
|
|
16
16
|
import path from 'path';
|
|
17
|
+
import { findSmythPath } from '@sre/helpers/Sysconfig.helper';
|
|
17
18
|
|
|
18
19
|
const console = Logger('SmythModelsProvider');
|
|
19
20
|
|
|
@@ -46,19 +47,34 @@ export class JSONModelsProvider extends ModelsProviderConnector {
|
|
|
46
47
|
|
|
47
48
|
this.models = JSON.parse(JSON.stringify(models));
|
|
48
49
|
if (typeof this._settings.models === 'string') {
|
|
49
|
-
this.initDirWatcher(this._settings.models);
|
|
50
|
+
this.initDirWatcher(this._settings.models); //this.started will be set to true when the watcher is ready
|
|
50
51
|
} else if (typeof this._settings.models === 'object') {
|
|
51
52
|
if (this._settings.mode === 'merge') this.models = { ...this.models, ...(this._settings.models as TLLMModelsList) };
|
|
52
53
|
else this.models = this._settings.models as TLLMModelsList;
|
|
53
54
|
this.started = true;
|
|
54
55
|
} else {
|
|
55
|
-
|
|
56
|
+
const modelsFolder = this.findModelsFolder();
|
|
57
|
+
if (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
|
|
60
|
+
}
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
public async start() {
|
|
59
64
|
super.start();
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
private findModelsFolder() {
|
|
68
|
+
const _modelsFolder = findSmythPath('models');
|
|
69
|
+
|
|
70
|
+
if (fsSync.existsSync(_modelsFolder)) {
|
|
71
|
+
console.warn('Using default models folder : ', _modelsFolder);
|
|
72
|
+
return _modelsFolder;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
@SecureConnector.AccessControl
|
|
63
79
|
public async addModels(acRequest: AccessRequest, models: TLLMModelsList): Promise<void> {
|
|
64
80
|
await this.ready();
|