openkbs 0.0.21 → 0.0.22
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 +1 -1
- package/src/utils.js +11 -8
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -160,7 +160,7 @@ function makePostRequest(url, data) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
163
|
-
const data = JSON.parse(body);
|
|
163
|
+
const data = body?.length ? JSON.parse(body) : body;
|
|
164
164
|
resolve(data);
|
|
165
165
|
} else {
|
|
166
166
|
try {
|
|
@@ -334,18 +334,20 @@ async function modifyKB(kbToken, kbData, prompt, files, options) {
|
|
|
334
334
|
try {
|
|
335
335
|
const fileContentString = fileContents.map(file => `${file.filePath}\n---\n${file.content}`).join('\n\n\n');
|
|
336
336
|
const { onRequestHandler, onResponseHandler, chatModel, instructions, verbose, preserveChat } = options;
|
|
337
|
-
|
|
338
|
-
const payload = {
|
|
337
|
+
const operationParams = {
|
|
339
338
|
operation: 'modify',
|
|
339
|
+
...(chatModel && { operationModel: chatModel }),
|
|
340
|
+
...(instructions && { operationInstructions: instructions }),
|
|
341
|
+
...(onRequestHandler && { operationRequestHandler: await fs.readFile(onRequestHandler, 'utf8') }),
|
|
342
|
+
...(onResponseHandler && { operationResponseHandler: await fs.readFile(onResponseHandler, 'utf8') })
|
|
343
|
+
}
|
|
344
|
+
const payload = {
|
|
340
345
|
token: kbToken,
|
|
341
346
|
message: encrypt(prompt + '\n\n###\n\n' + fileContentString, key),
|
|
342
347
|
chatTitle: 'operation request',
|
|
343
348
|
encrypted: true,
|
|
344
349
|
AESKey: key,
|
|
345
|
-
...
|
|
346
|
-
...(instructions && { operationInstructions: instructions }),
|
|
347
|
-
...(onRequestHandler && { operationRequestHandler: await fs.readFile(onRequestHandler, 'utf8') }),
|
|
348
|
-
...(onResponseHandler && { operationResponseHandler: await fs.readFile(onResponseHandler, 'utf8') })
|
|
350
|
+
...operationParams
|
|
349
351
|
};
|
|
350
352
|
|
|
351
353
|
startLoading();
|
|
@@ -374,7 +376,8 @@ async function modifyKB(kbToken, kbData, prompt, files, options) {
|
|
|
374
376
|
message: encrypt(message, key),
|
|
375
377
|
chatId: createdChatId,
|
|
376
378
|
encrypted: true,
|
|
377
|
-
AESKey: key
|
|
379
|
+
AESKey: key,
|
|
380
|
+
...operationParams
|
|
378
381
|
});
|
|
379
382
|
};
|
|
380
383
|
|