backend-manager 3.2.39 → 3.2.40
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
|
@@ -93,13 +93,30 @@ OpenAI.prototype.request = function (options) {
|
|
|
93
93
|
// console.log('*** input!!!', input.content.slice(0, 50), input.path);
|
|
94
94
|
// console.log('*** input.content', input.content.slice(0, 50));
|
|
95
95
|
// console.log('*** input.path', input.path);
|
|
96
|
-
_log('Loading', input);
|
|
96
|
+
// _log('Loading', input);
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)
|
|
102
|
-
|
|
98
|
+
let content = '';
|
|
99
|
+
|
|
100
|
+
// Load content
|
|
101
|
+
if (input.path) {
|
|
102
|
+
if (!jetpack.exists(input.path)) {
|
|
103
|
+
return new Error(`Path ${input.path} not found`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (jetpack.isDirectory(input.path)) {
|
|
107
|
+
return new Error(`Path ${input.path} is a directory`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
content = jetpack.read(input.path);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return new Error(`Error reading file ${input.path}: ${e}`);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
content = input.content;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return powertools.template(content, input.settings).trim();
|
|
103
120
|
}
|
|
104
121
|
|
|
105
122
|
// Log
|
|
@@ -119,6 +136,15 @@ OpenAI.prototype.request = function (options) {
|
|
|
119
136
|
_log('Message', message);
|
|
120
137
|
_log('User', user);
|
|
121
138
|
|
|
139
|
+
// Check for errors
|
|
140
|
+
if (prompt instanceof Error) {
|
|
141
|
+
return reject(assistant.errorify(`Error loading prompt: ${prompt}`, {code: 400}));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (message instanceof Error) {
|
|
145
|
+
return reject(assistant.errorify(`Error loading message: ${message}`, {code: 400}));
|
|
146
|
+
}
|
|
147
|
+
|
|
122
148
|
function _request(mode, options) {
|
|
123
149
|
return new Promise(async function(resolve, reject) {
|
|
124
150
|
let resultPath = '';
|