@sprucelabs/sprucebot-llm 11.1.10 → 11.1.11

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.
@@ -8,6 +8,7 @@ export default class ResponseParser {
8
8
  private invokeCallbackAndDropInLegacyResults;
9
9
  private doesIncludeDoneToken;
10
10
  private parseState;
11
+ private assertAtMostOneCallback;
11
12
  }
12
13
  export interface ParsedResponse {
13
14
  isDone: boolean;
@@ -23,6 +23,7 @@ class ResponseParser {
23
23
  let message = response.replace(DONE_TOKEN, '').trim();
24
24
  let state;
25
25
  let callbackResults;
26
+ let callbacksInvoked = 0;
26
27
  for (const key of Object.keys(callbacks || {})) {
27
28
  const match = message.match(renderPlaceholder(key));
28
29
  if (match) {
@@ -42,6 +43,7 @@ class ResponseParser {
42
43
  : undefined;
43
44
  }
44
45
  if (xmlCallMatches) {
46
+ this.assertAtMostOneCallback(++callbacksInvoked);
45
47
  try {
46
48
  callbackResults = yield ((_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks[key]) === null || _a === void 0 ? void 0 : _a.cb(data));
47
49
  message = message.replace(xmlCallMatches[0], '').trim();
@@ -100,6 +102,11 @@ class ResponseParser {
100
102
  const match = stateMatches === null || stateMatches === void 0 ? void 0 : stateMatches[1];
101
103
  return { match, fullMatch: stateMatches === null || stateMatches === void 0 ? void 0 : stateMatches[0] };
102
104
  }
105
+ assertAtMostOneCallback(invocations) {
106
+ if (invocations > 1) {
107
+ throw new SpruceError({ code: 'CALLBACK_ERROR' });
108
+ }
109
+ }
103
110
  }
104
111
  ResponseParser.instance = new ResponseParser();
105
112
  export default ResponseParser;
@@ -8,6 +8,7 @@ export default class ResponseParser {
8
8
  private invokeCallbackAndDropInLegacyResults;
9
9
  private doesIncludeDoneToken;
10
10
  private parseState;
11
+ private assertAtMostOneCallback;
11
12
  }
12
13
  export interface ParsedResponse {
13
14
  isDone: boolean;
@@ -17,6 +17,7 @@ class ResponseParser {
17
17
  let message = response.replace(templates_1.DONE_TOKEN, '').trim();
18
18
  let state;
19
19
  let callbackResults;
20
+ let callbacksInvoked = 0;
20
21
  for (const key of Object.keys(callbacks || {})) {
21
22
  const match = message.match((0, renderPlaceholder_1.default)(key));
22
23
  if (match) {
@@ -36,6 +37,7 @@ class ResponseParser {
36
37
  : undefined;
37
38
  }
38
39
  if (xmlCallMatches) {
40
+ this.assertAtMostOneCallback(++callbacksInvoked);
39
41
  try {
40
42
  callbackResults = await callbacks?.[key]?.cb(data);
41
43
  message = message.replace(xmlCallMatches[0], '').trim();
@@ -90,6 +92,11 @@ class ResponseParser {
90
92
  const match = stateMatches?.[1];
91
93
  return { match, fullMatch: stateMatches?.[0] };
92
94
  }
95
+ assertAtMostOneCallback(invocations) {
96
+ if (invocations > 1) {
97
+ throw new SpruceError_1.default({ code: 'CALLBACK_ERROR' });
98
+ }
99
+ }
93
100
  }
94
101
  ResponseParser.instance = new ResponseParser();
95
102
  exports.default = ResponseParser;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "11.1.10",
11
+ "version": "11.1.11",
12
12
  "files": [
13
13
  "build"
14
14
  ],