@sprucelabs/sprucebot-llm 13.1.4 → 13.1.6
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.
|
@@ -35,6 +35,7 @@ class TurnRequest {
|
|
|
35
35
|
isDone = parsed.isDone;
|
|
36
36
|
state = parsed.state;
|
|
37
37
|
callbackResults = parsed.callbackResults;
|
|
38
|
+
await this.optionallyUpdateState(state);
|
|
38
39
|
}
|
|
39
40
|
catch (err) {
|
|
40
41
|
this.trackMessage({
|
|
@@ -42,13 +43,13 @@ class TurnRequest {
|
|
|
42
43
|
message: llmResponse,
|
|
43
44
|
});
|
|
44
45
|
if (err.options?.code === 'INVALID_CALLBACK' ||
|
|
45
|
-
err.options?.code === 'CALLBACK_ERROR'
|
|
46
|
+
err.options?.code === 'CALLBACK_ERROR' ||
|
|
47
|
+
err.options?.code === 'VALIDATION_FAILED') {
|
|
46
48
|
return this.sendMessage({ from: 'Api', message: `Error: ${err.message}` }, cb);
|
|
47
49
|
}
|
|
48
50
|
throw err;
|
|
49
51
|
}
|
|
50
52
|
this.setDone(isDone);
|
|
51
|
-
await this.optionallyUpdateState(state);
|
|
52
53
|
this.trackMessage({
|
|
53
54
|
from: 'You',
|
|
54
55
|
message: llmResponse,
|
|
@@ -24,7 +24,7 @@ export default class TurnRequest {
|
|
|
24
24
|
}
|
|
25
25
|
sendMessage(llmMessage, cb) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
var _a, _b, _c, _d;
|
|
27
|
+
var _a, _b, _c, _d, _e;
|
|
28
28
|
this.trackMessage(llmMessage);
|
|
29
29
|
const { model, callbacks } = (_b = (_a = this.skill) === null || _a === void 0 ? void 0 : _a.serialize()) !== null && _b !== void 0 ? _b : {};
|
|
30
30
|
const llmResponse = yield this.sendMessageToAdapter(model);
|
|
@@ -41,6 +41,7 @@ export default class TurnRequest {
|
|
|
41
41
|
isDone = parsed.isDone;
|
|
42
42
|
state = parsed.state;
|
|
43
43
|
callbackResults = parsed.callbackResults;
|
|
44
|
+
yield this.optionallyUpdateState(state);
|
|
44
45
|
}
|
|
45
46
|
catch (err) {
|
|
46
47
|
this.trackMessage({
|
|
@@ -48,13 +49,13 @@ export default class TurnRequest {
|
|
|
48
49
|
message: llmResponse,
|
|
49
50
|
});
|
|
50
51
|
if (((_c = err.options) === null || _c === void 0 ? void 0 : _c.code) === 'INVALID_CALLBACK' ||
|
|
51
|
-
((_d = err.options) === null || _d === void 0 ? void 0 : _d.code) === 'CALLBACK_ERROR'
|
|
52
|
+
((_d = err.options) === null || _d === void 0 ? void 0 : _d.code) === 'CALLBACK_ERROR' ||
|
|
53
|
+
((_e = err.options) === null || _e === void 0 ? void 0 : _e.code) === 'VALIDATION_FAILED') {
|
|
52
54
|
return this.sendMessage({ from: 'Api', message: `Error: ${err.message}` }, cb);
|
|
53
55
|
}
|
|
54
56
|
throw err;
|
|
55
57
|
}
|
|
56
58
|
this.setDone(isDone);
|
|
57
|
-
yield this.optionallyUpdateState(state);
|
|
58
59
|
this.trackMessage({
|
|
59
60
|
from: 'You',
|
|
60
61
|
message: llmResponse,
|
|
@@ -18,7 +18,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
-
import { validateSchemaValues, } from '@sprucelabs/schema';
|
|
21
|
+
import { normalizeSchemaValues, validateSchemaValues, } from '@sprucelabs/schema';
|
|
22
22
|
import { DONE_TOKEN, STATE_BOUNDARY } from '../bots/templates.js';
|
|
23
23
|
import SpruceError from '../errors/SpruceError.js';
|
|
24
24
|
import renderPlaceholder from './renderPlaceholder.js';
|
|
@@ -78,6 +78,7 @@ class ResponseParser {
|
|
|
78
78
|
rest;
|
|
79
79
|
});
|
|
80
80
|
validateSchemaValues(schema, data);
|
|
81
|
+
data = normalizeSchemaValues(schema, data);
|
|
81
82
|
}
|
|
82
83
|
callbackResults = yield (callback === null || callback === void 0 ? void 0 : callback.cb(data));
|
|
83
84
|
message = message.replace(xmlCallMatches[0], '').trim();
|
|
@@ -61,6 +61,7 @@ class ResponseParser {
|
|
|
61
61
|
rest;
|
|
62
62
|
});
|
|
63
63
|
(0, schema_1.validateSchemaValues)(schema, data);
|
|
64
|
+
data = (0, schema_1.normalizeSchemaValues)(schema, data);
|
|
64
65
|
}
|
|
65
66
|
callbackResults = await callback?.cb(data);
|
|
66
67
|
message = message.replace(xmlCallMatches[0], '').trim();
|