@sprucelabs/sprucebot-llm 14.3.3 → 14.3.4

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.
@@ -1,5 +1,16 @@
1
1
  import { default as SchemaEntity } from '@sprucelabs/schema';
2
2
  import * as SpruceSchema from '@sprucelabs/schema';
3
+ export declare namespace SpruceErrors.SprucebotLlm {
4
+ interface StateUpdateFailed {
5
+ }
6
+ interface StateUpdateFailedSchema extends SpruceSchema.Schema {
7
+ id: 'stateUpdateFailed';
8
+ namespace: 'SprucebotLlm';
9
+ name: 'State Update Failed';
10
+ fields: {};
11
+ }
12
+ type StateUpdateFailedEntity = SchemaEntity<SpruceErrors.SprucebotLlm.StateUpdateFailedSchema>;
13
+ }
3
14
  export declare namespace SpruceErrors.SprucebotLlm {
4
15
  interface NoBotInstanceSet {
5
16
  }
@@ -1,5 +1,8 @@
1
1
  import { SpruceErrors } from "./errors.types";
2
2
  import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
3
+ export interface StateUpdateFailedErrorOptions extends SpruceErrors.SprucebotLlm.StateUpdateFailed, ISpruceErrorOptions {
4
+ code: 'STATE_UPDATE_FAILED';
5
+ }
3
6
  export interface NoBotInstanceSetErrorOptions extends SpruceErrors.SprucebotLlm.NoBotInstanceSet, ISpruceErrorOptions {
4
7
  code: 'NO_BOT_INSTANCE_SET';
5
8
  }
@@ -12,5 +15,5 @@ export interface InvalidCallbackErrorOptions extends SpruceErrors.SprucebotLlm.I
12
15
  export interface CallbackErrorErrorOptions extends SpruceErrors.SprucebotLlm.CallbackError, ISpruceErrorOptions {
13
16
  code: 'CALLBACK_ERROR';
14
17
  }
15
- type ErrorOptions = NoBotInstanceSetErrorOptions | InvalidLlmAdapterErrorOptions | InvalidCallbackErrorOptions | CallbackErrorErrorOptions;
18
+ type ErrorOptions = StateUpdateFailedErrorOptions | NoBotInstanceSetErrorOptions | InvalidLlmAdapterErrorOptions | InvalidCallbackErrorOptions | CallbackErrorErrorOptions;
16
19
  export default ErrorOptions;
@@ -0,0 +1,3 @@
1
+ import { SpruceErrors } from '../errors.types';
2
+ declare const stateUpdateFailedSchema: SpruceErrors.SprucebotLlm.StateUpdateFailedSchema;
3
+ export default stateUpdateFailedSchema;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ const stateUpdateFailedSchema = {
5
+ id: 'stateUpdateFailed',
6
+ namespace: 'SprucebotLlm',
7
+ name: 'State Update Failed',
8
+ fields: {}
9
+ };
10
+ schema_1.SchemaRegistry.getInstance().trackSchema(stateUpdateFailedSchema);
11
+ exports.default = stateUpdateFailedSchema;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
6
7
  const ResponseParser_1 = __importDefault(require("../parsingResponses/ResponseParser"));
7
8
  class TurnRequest {
8
9
  constructor(options) {
@@ -35,7 +36,16 @@ class TurnRequest {
35
36
  isDone = parsed.isDone;
36
37
  state = parsed.state;
37
38
  callbackResults = parsed.callbackResults;
38
- await this.optionallyUpdateState(state);
39
+ try {
40
+ await this.optionallyUpdateState(state);
41
+ }
42
+ catch (err) {
43
+ throw new SpruceError_1.default({
44
+ code: 'STATE_UPDATE_FAILED',
45
+ friendlyMessage: `Updating state failed with error: ${err.message}`,
46
+ originalError: err,
47
+ });
48
+ }
39
49
  }
40
50
  catch (err) {
41
51
  this.trackMessage({
@@ -44,7 +54,7 @@ class TurnRequest {
44
54
  });
45
55
  if (err.options?.code === 'INVALID_CALLBACK' ||
46
56
  err.options?.code === 'CALLBACK_ERROR' ||
47
- err.options?.code === 'VALIDATION_FAILED') {
57
+ err.options?.code === 'STATE_UPDATE_FAILED') {
48
58
  return this.sendMessage({ from: 'Api', message: `Error: ${err.message}` }, cb);
49
59
  }
50
60
  throw err;
@@ -42,6 +42,9 @@ ${options.validCallbacks.map((name, idx) => `${idx + 1}: ${name}`).join('\n')}`;
42
42
  case 'INVALID_LLM_ADAPTER':
43
43
  message = `SPRUCE_LLM_ADAPTER=${options.adapter} is not a valid adapter. Please set SPRUCE_LLM_ADAPTER to a valid adapter (OpenAi, Anthropic, Ollama) and try again.`;
44
44
  break;
45
+ case 'STATE_UPDATE_FAILED':
46
+ message = 'A State Update Failed just happened!';
47
+ break;
45
48
  default:
46
49
  message = super.friendlyMessage();
47
50
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ exports.default = (0, schema_1.buildErrorSchema)({
5
+ id: 'stateUpdateFailed',
6
+ name: 'State Update Failed',
7
+ fields: {},
8
+ });
@@ -1,5 +1,16 @@
1
1
  import { default as SchemaEntity } from '@sprucelabs/schema';
2
2
  import * as SpruceSchema from '@sprucelabs/schema';
3
+ export declare namespace SpruceErrors.SprucebotLlm {
4
+ interface StateUpdateFailed {
5
+ }
6
+ interface StateUpdateFailedSchema extends SpruceSchema.Schema {
7
+ id: 'stateUpdateFailed';
8
+ namespace: 'SprucebotLlm';
9
+ name: 'State Update Failed';
10
+ fields: {};
11
+ }
12
+ type StateUpdateFailedEntity = SchemaEntity<SpruceErrors.SprucebotLlm.StateUpdateFailedSchema>;
13
+ }
3
14
  export declare namespace SpruceErrors.SprucebotLlm {
4
15
  interface NoBotInstanceSet {
5
16
  }
@@ -1,5 +1,8 @@
1
1
  import { SpruceErrors } from "./errors.types";
2
2
  import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
3
+ export interface StateUpdateFailedErrorOptions extends SpruceErrors.SprucebotLlm.StateUpdateFailed, ISpruceErrorOptions {
4
+ code: 'STATE_UPDATE_FAILED';
5
+ }
3
6
  export interface NoBotInstanceSetErrorOptions extends SpruceErrors.SprucebotLlm.NoBotInstanceSet, ISpruceErrorOptions {
4
7
  code: 'NO_BOT_INSTANCE_SET';
5
8
  }
@@ -12,5 +15,5 @@ export interface InvalidCallbackErrorOptions extends SpruceErrors.SprucebotLlm.I
12
15
  export interface CallbackErrorErrorOptions extends SpruceErrors.SprucebotLlm.CallbackError, ISpruceErrorOptions {
13
16
  code: 'CALLBACK_ERROR';
14
17
  }
15
- type ErrorOptions = NoBotInstanceSetErrorOptions | InvalidLlmAdapterErrorOptions | InvalidCallbackErrorOptions | CallbackErrorErrorOptions;
18
+ type ErrorOptions = StateUpdateFailedErrorOptions | NoBotInstanceSetErrorOptions | InvalidLlmAdapterErrorOptions | InvalidCallbackErrorOptions | CallbackErrorErrorOptions;
16
19
  export default ErrorOptions;
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import SpruceError from '../errors/SpruceError.js';
10
11
  import ResponseParser from '../parsingResponses/ResponseParser.js';
11
12
  export default class TurnRequest {
12
13
  constructor(options) {
@@ -41,7 +42,16 @@ export default class TurnRequest {
41
42
  isDone = parsed.isDone;
42
43
  state = parsed.state;
43
44
  callbackResults = parsed.callbackResults;
44
- yield this.optionallyUpdateState(state);
45
+ try {
46
+ yield this.optionallyUpdateState(state);
47
+ }
48
+ catch (err) {
49
+ throw new SpruceError({
50
+ code: 'STATE_UPDATE_FAILED',
51
+ friendlyMessage: `Updating state failed with error: ${err.message}`,
52
+ originalError: err,
53
+ });
54
+ }
45
55
  }
46
56
  catch (err) {
47
57
  this.trackMessage({
@@ -50,7 +60,7 @@ export default class TurnRequest {
50
60
  });
51
61
  if (((_c = err.options) === null || _c === void 0 ? void 0 : _c.code) === 'INVALID_CALLBACK' ||
52
62
  ((_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') {
63
+ ((_e = err.options) === null || _e === void 0 ? void 0 : _e.code) === 'STATE_UPDATE_FAILED') {
54
64
  return this.sendMessage({ from: 'Api', message: `Error: ${err.message}` }, cb);
55
65
  }
56
66
  throw err;
@@ -37,6 +37,9 @@ ${options.validCallbacks.map((name, idx) => `${idx + 1}: ${name}`).join('\n')}`;
37
37
  case 'INVALID_LLM_ADAPTER':
38
38
  message = `SPRUCE_LLM_ADAPTER=${options.adapter} is not a valid adapter. Please set SPRUCE_LLM_ADAPTER to a valid adapter (OpenAi, Anthropic, Ollama) and try again.`;
39
39
  break;
40
+ case 'STATE_UPDATE_FAILED':
41
+ message = 'A State Update Failed just happened!';
42
+ break;
40
43
  default:
41
44
  message = super.friendlyMessage();
42
45
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { buildErrorSchema } from '@sprucelabs/schema';
2
+ export default buildErrorSchema({
3
+ id: 'stateUpdateFailed',
4
+ name: 'State Update Failed',
5
+ fields: {},
6
+ });
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "14.3.3",
11
+ "version": "14.3.4",
12
12
  "files": [
13
13
  "build"
14
14
  ],