@sprucelabs/sprucebot-llm 11.1.14 → 11.1.16
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/build/.spruce/errors/errors.types.js +0 -1
- package/build/.spruce/errors/options.types.js +0 -1
- package/build/.spruce/errors/sprucebotLlm/callbackError.schema.js +0 -1
- package/build/.spruce/errors/sprucebotLlm/invalidCallback.schema.js +0 -1
- package/build/.spruce/errors/sprucebotLlm/noBotInstanceSet.schema.js +0 -1
- package/build/.spruce/schemas/fields/fieldClassMap.js +0 -1
- package/build/.spruce/schemas/fields/fields.types.js +0 -1
- package/build/bots/PromptGenerator.js +0 -1
- package/build/bots/SprucebotLlmBotImpl.js +0 -1
- package/build/bots/SprucebotLlmFactory.js +0 -1
- package/build/bots/SprucebotLlmSkillImpl.js +0 -1
- package/build/bots/adapters/OpenAi.js +0 -1
- package/build/bots/adapters/OpenAiMessageBuilder.js +0 -1
- package/build/bots/adapters/SpyOpenAiApi.js +0 -1
- package/build/bots/templates.js +0 -1
- package/build/chat.js +0 -1
- package/build/chatWithImages.js +0 -1
- package/build/errors/SpruceError.js +0 -1
- package/build/errors/callbackError.builder.js +0 -1
- package/build/errors/invalidCallback.builder.js +0 -1
- package/build/errors/noBotInstanceSet.builder.js +0 -1
- package/build/esm/.spruce/errors/errors.types.d.ts +52 -0
- package/build/esm/.spruce/errors/errors.types.js +1 -0
- package/build/esm/.spruce/errors/options.types.d.ts +13 -0
- package/build/esm/.spruce/errors/options.types.js +1 -0
- package/build/esm/bots/PromptGenerator.d.ts +22 -0
- package/build/esm/bots/PromptGenerator.js +74 -0
- package/build/esm/bots/SprucebotLlmBotImpl.d.ts +26 -0
- package/build/esm/bots/SprucebotLlmBotImpl.js +163 -0
- package/build/esm/bots/SprucebotLlmFactory.d.ts +15 -0
- package/build/esm/bots/SprucebotLlmFactory.js +41 -0
- package/build/esm/bots/SprucebotLlmSkillImpl.d.ts +12 -0
- package/build/esm/bots/SprucebotLlmSkillImpl.js +47 -0
- package/build/esm/bots/adapters/OpenAi.d.ts +11 -0
- package/build/esm/bots/adapters/OpenAi.js +46 -0
- package/build/esm/bots/adapters/OpenAiMessageBuilder.d.ts +18 -0
- package/build/esm/bots/adapters/OpenAiMessageBuilder.js +153 -0
- package/build/esm/bots/adapters/SpyOpenAiApi.d.ts +19 -0
- package/build/esm/bots/adapters/SpyOpenAiApi.js +49 -0
- package/build/esm/bots/templates.d.ts +4 -0
- package/build/esm/bots/templates.js +68 -0
- package/build/esm/chat.d.ts +1 -0
- package/build/esm/chat.js +53 -0
- package/build/esm/chatWithImages.d.ts +1 -0
- package/build/esm/chatWithImages.js +46 -0
- package/build/esm/errors/SpruceError.d.ts +6 -0
- package/build/esm/errors/SpruceError.js +25 -0
- package/build/esm/errors/callbackError.builder.d.ts +6 -0
- package/build/esm/errors/callbackError.builder.js +6 -0
- package/build/esm/errors/invalidCallback.builder.d.ts +17 -0
- package/build/esm/errors/invalidCallback.builder.js +17 -0
- package/build/esm/errors/noBotInstanceSet.builder.d.ts +6 -0
- package/build/esm/errors/noBotInstanceSet.builder.js +6 -0
- package/build/esm/examples/buildCallbackSkill.d.ts +2 -0
- package/build/esm/examples/buildCallbackSkill.js +57 -0
- package/build/esm/examples/buildFileTransformerSkill.d.ts +2 -0
- package/build/esm/examples/buildFileTransformerSkill.js +25 -0
- package/build/esm/examples/buildJokeSkill.d.ts +2 -0
- package/build/esm/examples/buildJokeSkill.js +12 -0
- package/build/esm/examples/buildProfileSkill.d.ts +2 -0
- package/build/esm/examples/buildProfileSkill.js +30 -0
- package/build/esm/examples/buildReceptionistSkill.d.ts +2 -0
- package/build/esm/examples/buildReceptionistSkill.js +16 -0
- package/build/esm/fineTuningSprucebot/constants/DIRECTORY_SHARES.d.ts +1 -0
- package/build/esm/fineTuningSprucebot/constants/DIRECTORY_SHARES.js +7 -0
- package/build/esm/fineTuningSprucebot/constants/FIRST_MESSAGES.d.ts +1 -0
- package/build/esm/fineTuningSprucebot/constants/FIRST_MESSAGES.js +17 -0
- package/build/esm/fineTuningSprucebot/constants/GREETINGS.d.ts +1 -0
- package/build/esm/fineTuningSprucebot/constants/GREETINGS.js +22 -0
- package/build/esm/fineTuningSprucebot/constants/OFF_THE_RAILS_CONVERSATIONS.d.ts +2 -0
- package/build/esm/fineTuningSprucebot/constants/OFF_THE_RAILS_CONVERSATIONS.js +32 -0
- package/build/esm/fineTuningSprucebot/constants/TOPICS.d.ts +2 -0
- package/build/esm/fineTuningSprucebot/constants/TOPICS.js +314 -0
- package/build/esm/fineTuningSprucebot/generateSamples.d.ts +1 -0
- package/build/esm/fineTuningSprucebot/generateSamples.js +41 -0
- package/build/esm/fineTuningSprucebot/support.d.ts +12 -0
- package/build/esm/fineTuningSprucebot/support.js +60 -0
- package/build/esm/fineTuningSprucebot/types.d.ts +15 -0
- package/build/esm/fineTuningSprucebot/types.js +1 -0
- package/build/esm/index.d.ts +10 -0
- package/build/esm/index.js +10 -0
- package/build/esm/llm.types.d.ts +84 -0
- package/build/esm/llm.types.js +6 -0
- package/build/esm/parsingResponses/ResponseParser.d.ts +18 -0
- package/build/esm/parsingResponses/ResponseParser.js +115 -0
- package/build/esm/parsingResponses/renderPlaceholder.d.ts +1 -0
- package/build/esm/parsingResponses/renderPlaceholder.js +4 -0
- package/build/esm/tests/MockLlmSkill.d.ts +14 -0
- package/build/esm/tests/MockLlmSkill.js +60 -0
- package/build/esm/tests/SpyAdapter.d.ts +9 -0
- package/build/esm/tests/SpyAdapter.js +24 -0
- package/build/esm/tests/SpyLlmBot.d.ts +12 -0
- package/build/esm/tests/SpyLlmBot.js +20 -0
- package/build/examples/buildCallbackSkill.js +0 -1
- package/build/examples/buildFileTransformerSkill.js +0 -1
- package/build/examples/buildJokeSkill.js +0 -1
- package/build/examples/buildProfileSkill.js +0 -1
- package/build/examples/buildReceptionistSkill.js +0 -1
- package/build/fineTuningSprucebot/constants/DIRECTORY_SHARES.js +0 -1
- package/build/fineTuningSprucebot/constants/FIRST_MESSAGES.js +0 -1
- package/build/fineTuningSprucebot/constants/GREETINGS.js +0 -1
- package/build/fineTuningSprucebot/constants/OFF_THE_RAILS_CONVERSATIONS.js +0 -1
- package/build/fineTuningSprucebot/constants/TOPICS.js +0 -1
- package/build/fineTuningSprucebot/generateSamples.js +0 -1
- package/build/fineTuningSprucebot/support.js +0 -1
- package/build/fineTuningSprucebot/types.js +0 -1
- package/build/index.js +0 -1
- package/build/llm.types.js +0 -1
- package/build/parsingResponses/ResponseParser.js +0 -1
- package/build/parsingResponses/renderPlaceholder.js +0 -1
- package/build/tests/MockLlmSkill.js +0 -1
- package/build/tests/SpyAdapter.d.ts +1 -0
- package/build/tests/SpyAdapter.js +3 -1
- package/build/tests/SpyLlmBot.js +0 -1
- package/package.json +1 -1
- package/build/.spruce/errors/errors.types.js.map +0 -1
- package/build/.spruce/errors/options.types.js.map +0 -1
- package/build/.spruce/errors/sprucebotLlm/callbackError.schema.js.map +0 -1
- package/build/.spruce/errors/sprucebotLlm/invalidCallback.schema.js.map +0 -1
- package/build/.spruce/errors/sprucebotLlm/noBotInstanceSet.schema.js.map +0 -1
- package/build/.spruce/event-cache.json +0 -1
- package/build/.spruce/schemas/fields/fieldClassMap.js.map +0 -1
- package/build/.spruce/schemas/fields/fields.types.js.map +0 -1
- package/build/__tests__/behavioral/LlmBot.test.d.ts +0 -55
- package/build/__tests__/behavioral/LlmBot.test.js +0 -607
- package/build/__tests__/behavioral/LlmBot.test.js.map +0 -1
- package/build/__tests__/behavioral/SprucebotLlmFactory.test.d.ts +0 -16
- package/build/__tests__/behavioral/SprucebotLlmFactory.test.js +0 -132
- package/build/__tests__/behavioral/SprucebotLlmFactory.test.js.map +0 -1
- package/build/__tests__/behavioral/adapters/OpenAi.test.d.ts +0 -52
- package/build/__tests__/behavioral/adapters/OpenAi.test.js +0 -699
- package/build/__tests__/behavioral/adapters/OpenAi.test.js.map +0 -1
- package/build/__tests__/behavioral/prompts/PromptGenerator.test.d.ts +0 -20
- package/build/__tests__/behavioral/prompts/PromptGenerator.test.js +0 -211
- package/build/__tests__/behavioral/prompts/PromptGenerator.test.js.map +0 -1
- package/build/__tests__/behavioral/prompts/ResponseParser.test.d.ts +0 -35
- package/build/__tests__/behavioral/prompts/ResponseParser.test.js +0 -312
- package/build/__tests__/behavioral/prompts/ResponseParser.test.js.map +0 -1
- package/build/__tests__/behavioral/skills/Skill.test.d.ts +0 -19
- package/build/__tests__/behavioral/skills/Skill.test.js +0 -188
- package/build/__tests__/behavioral/skills/Skill.test.js.map +0 -1
- package/build/__tests__/behavioral/testing/MockLlmSkill.test.d.ts +0 -37
- package/build/__tests__/behavioral/testing/MockLlmSkill.test.js +0 -340
- package/build/__tests__/behavioral/testing/MockLlmSkill.test.js.map +0 -1
- package/build/__tests__/behavioral/testing/SpyLlmBot.test.d.ts +0 -4
- package/build/__tests__/behavioral/testing/SpyLlmBot.test.js +0 -34
- package/build/__tests__/behavioral/testing/SpyLlmBot.test.js.map +0 -1
- package/build/__tests__/support/AbstractLlmTest.d.ts +0 -14
- package/build/__tests__/support/AbstractLlmTest.js +0 -67
- package/build/__tests__/support/AbstractLlmTest.js.map +0 -1
- package/build/__tests__/support/schemas/carSchema.d.ts +0 -16
- package/build/__tests__/support/schemas/carSchema.js +0 -19
- package/build/__tests__/support/schemas/carSchema.js.map +0 -1
- package/build/__tests__/support/schemas/personSchema.d.ts +0 -23
- package/build/__tests__/support/schemas/personSchema.js +0 -37
- package/build/__tests__/support/schemas/personSchema.js.map +0 -1
- package/build/__tests__/support/schemas/personWithDefaultsSchema.d.ts +0 -13
- package/build/__tests__/support/schemas/personWithDefaultsSchema.js +0 -18
- package/build/__tests__/support/schemas/personWithDefaultsSchema.js.map +0 -1
- package/build/bots/PromptGenerator.js.map +0 -1
- package/build/bots/SprucebotLlmBotImpl.js.map +0 -1
- package/build/bots/SprucebotLlmFactory.js.map +0 -1
- package/build/bots/SprucebotLlmSkillImpl.js.map +0 -1
- package/build/bots/adapters/OpenAi.js.map +0 -1
- package/build/bots/adapters/OpenAiMessageBuilder.js.map +0 -1
- package/build/bots/adapters/SpyOpenAiApi.js.map +0 -1
- package/build/bots/templates.js.map +0 -1
- package/build/chat.js.map +0 -1
- package/build/chatWithImages.js.map +0 -1
- package/build/errors/SpruceError.js.map +0 -1
- package/build/errors/callbackError.builder.js.map +0 -1
- package/build/errors/invalidCallback.builder.js.map +0 -1
- package/build/errors/noBotInstanceSet.builder.js.map +0 -1
- package/build/examples/buildCallbackSkill.js.map +0 -1
- package/build/examples/buildFileTransformerSkill.js.map +0 -1
- package/build/examples/buildJokeSkill.js.map +0 -1
- package/build/examples/buildProfileSkill.js.map +0 -1
- package/build/examples/buildReceptionistSkill.js.map +0 -1
- package/build/fineTuningSprucebot/constants/DIRECTORY_SHARES.js.map +0 -1
- package/build/fineTuningSprucebot/constants/FIRST_MESSAGES.js.map +0 -1
- package/build/fineTuningSprucebot/constants/GREETINGS.js.map +0 -1
- package/build/fineTuningSprucebot/constants/OFF_THE_RAILS_CONVERSATIONS.js.map +0 -1
- package/build/fineTuningSprucebot/constants/TOPICS.js.map +0 -1
- package/build/fineTuningSprucebot/generateSamples.js.map +0 -1
- package/build/fineTuningSprucebot/support.js.map +0 -1
- package/build/fineTuningSprucebot/types.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/llm.types.js.map +0 -1
- package/build/parsingResponses/ResponseParser.js.map +0 -1
- package/build/parsingResponses/renderPlaceholder.js.map +0 -1
- package/build/tests/MockLlmSkill.js.map +0 -1
- package/build/tests/SpyAdapter.js.map +0 -1
- package/build/tests/SpyLlmBot.js.map +0 -1
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import AbstractLlmTest from '../support/AbstractLlmTest';
|
|
2
|
-
export default class LlmBotTest extends AbstractLlmTest {
|
|
3
|
-
private bot;
|
|
4
|
-
private parser;
|
|
5
|
-
protected beforeEach(): Promise<void>;
|
|
6
|
-
protected throwsWhenSendingBadMessage(): Promise<void>;
|
|
7
|
-
protected sendsItselfToTheLlmAdapter(): Promise<void>;
|
|
8
|
-
protected serializesAsExpected(): Promise<void>;
|
|
9
|
-
protected canUpdateState(): Promise<void>;
|
|
10
|
-
protected updatingStateMixesIn(): Promise<void>;
|
|
11
|
-
protected stateHonorsDefaultValues(): Promise<void>;
|
|
12
|
-
protected updatingStateEmitsDidUpdateState(): Promise<void>;
|
|
13
|
-
protected knowsWhenDone(): Promise<void>;
|
|
14
|
-
protected sendMessageReturnsResponseFromAdapter(): Promise<void>;
|
|
15
|
-
protected tracksMessageHistory(): Promise<void>;
|
|
16
|
-
protected trackedMessageUsesResponseFromAdapterNotParser(): Promise<void>;
|
|
17
|
-
protected isDoneWhenParsesSaysSo(): Promise<void>;
|
|
18
|
-
protected notDoneUntilDone(): Promise<void>;
|
|
19
|
-
protected botActuallySendsResponseToParser(): Promise<void>;
|
|
20
|
-
protected enheritesStateSchemaFromSkillWhenSerializing(): Promise<void>;
|
|
21
|
-
protected inheritsStateFromSkillWhenSerializing(skillState: Record<string, any>): Promise<void>;
|
|
22
|
-
protected stateIsSentBackToBotWhenParsing(state: Record<string, any>): Promise<void>;
|
|
23
|
-
protected emitsDidUpdateStateWhenStateIsUpdated(): Promise<void>;
|
|
24
|
-
protected shouldNotEmitUpdateItNoStatePassed(): Promise<void>;
|
|
25
|
-
protected setsStateInResponseToSkillIfSkillHasState(state: Record<string, any>): Promise<void>;
|
|
26
|
-
protected doesntEmitDidChangeOnSkillIfStateIsNotOnSkill(): Promise<void>;
|
|
27
|
-
protected passesCallbacksToParserOnResponse(): Promise<void>;
|
|
28
|
-
protected canSwapSkillMidWayThrough(): Promise<void>;
|
|
29
|
-
protected defaultLimitsMessagesTo10(): Promise<void>;
|
|
30
|
-
protected canSetMemory(): Promise<void>;
|
|
31
|
-
protected settingSkillToBotSetsToNotDone(): Promise<void>;
|
|
32
|
-
protected canClearMessageHistory(): Promise<void>;
|
|
33
|
-
protected botRespondingCallsMessageCallback(): Promise<void>;
|
|
34
|
-
protected messageCallbackFiredAfterAllMessagesTracked(): Promise<void>;
|
|
35
|
-
protected ifParserRespondsWithCallbackResultsTheyAreSentImmediately(): Promise<void>;
|
|
36
|
-
protected handleParserRespondingWithImage(): Promise<void>;
|
|
37
|
-
protected sendsMessageBackToBotIfParserThrows(): Promise<void>;
|
|
38
|
-
protected sendsMessageBackToBotIfCallbackThrows(): Promise<void>;
|
|
39
|
-
protected responseThatThrowsIsStillTracked(): Promise<void>;
|
|
40
|
-
protected canSendImage(): Promise<void>;
|
|
41
|
-
private setParserResponseCallbackResults;
|
|
42
|
-
private get parserResponse();
|
|
43
|
-
private setParserResponseMessage;
|
|
44
|
-
private setParserResponseIsDone;
|
|
45
|
-
private assertTotalMessagesTracked;
|
|
46
|
-
private get messages();
|
|
47
|
-
private setupBotWithSkill;
|
|
48
|
-
private sendMessageWithResponseState;
|
|
49
|
-
private sendRandomMessage;
|
|
50
|
-
private setStateInResponse;
|
|
51
|
-
private sendMessage;
|
|
52
|
-
private serialize;
|
|
53
|
-
private updateState;
|
|
54
|
-
private assertSerializedStateEquals;
|
|
55
|
-
}
|
|
@@ -1,607 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
|
-
const SprucebotLlmBotImpl_1 = __importDefault(require("../../bots/SprucebotLlmBotImpl"));
|
|
14
|
-
const SpruceError_1 = __importDefault(require("../../errors/SpruceError"));
|
|
15
|
-
const ResponseParser_1 = __importDefault(require("../../parsingResponses/ResponseParser"));
|
|
16
|
-
const AbstractLlmTest_1 = __importDefault(require("../support/AbstractLlmTest"));
|
|
17
|
-
const carSchema_1 = require("../support/schemas/carSchema");
|
|
18
|
-
const personSchema_1 = require("../support/schemas/personSchema");
|
|
19
|
-
const personWithDefaultsSchema_1 = require("../support/schemas/personWithDefaultsSchema");
|
|
20
|
-
let LlmBotTest = class LlmBotTest extends AbstractLlmTest_1.default {
|
|
21
|
-
async beforeEach() {
|
|
22
|
-
await super.beforeEach();
|
|
23
|
-
this.bot = this.Bot({
|
|
24
|
-
stateSchema: personSchema_1.personSchema,
|
|
25
|
-
});
|
|
26
|
-
this.parser = new FakeResponseParser();
|
|
27
|
-
ResponseParser_1.default.setInstance(this.parser);
|
|
28
|
-
}
|
|
29
|
-
async throwsWhenSendingBadMessage() {
|
|
30
|
-
//@ts-ignore
|
|
31
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => this.bot.sendMessage());
|
|
32
|
-
test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
33
|
-
parameters: ['message'],
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async sendsItselfToTheLlmAdapter() {
|
|
37
|
-
const message = (0, test_utils_1.generateId)();
|
|
38
|
-
await this.sendMessage(message);
|
|
39
|
-
test_utils_1.assert.isEqual(this.adapter.lastBot, this.bot);
|
|
40
|
-
}
|
|
41
|
-
async serializesAsExpected() {
|
|
42
|
-
const youAre = (0, test_utils_1.generateId)();
|
|
43
|
-
const state = {
|
|
44
|
-
favoriteColor: 'red',
|
|
45
|
-
firstName: (0, test_utils_1.generateId)(),
|
|
46
|
-
};
|
|
47
|
-
this.bot = this.Bot({
|
|
48
|
-
youAre,
|
|
49
|
-
stateSchema: personSchema_1.personSchema,
|
|
50
|
-
state,
|
|
51
|
-
});
|
|
52
|
-
test_utils_1.assert.isEqualDeep(this.bot.serialize(), {
|
|
53
|
-
youAre,
|
|
54
|
-
stateSchema: personSchema_1.personSchema,
|
|
55
|
-
state,
|
|
56
|
-
messages: [],
|
|
57
|
-
skill: undefined,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
async canUpdateState() {
|
|
61
|
-
const newState = {
|
|
62
|
-
favoriteColor: 'blue',
|
|
63
|
-
firstName: (0, test_utils_1.generateId)(),
|
|
64
|
-
};
|
|
65
|
-
await this.updateState(newState);
|
|
66
|
-
this.assertSerializedStateEquals(newState);
|
|
67
|
-
}
|
|
68
|
-
async updatingStateMixesIn() {
|
|
69
|
-
const state = {
|
|
70
|
-
make: 'Ford',
|
|
71
|
-
};
|
|
72
|
-
this.bot = this.Bot({
|
|
73
|
-
stateSchema: carSchema_1.carSchema,
|
|
74
|
-
state,
|
|
75
|
-
});
|
|
76
|
-
const newState = {
|
|
77
|
-
model: 'F-150',
|
|
78
|
-
};
|
|
79
|
-
await this.updateState(newState);
|
|
80
|
-
const expected = {
|
|
81
|
-
...state,
|
|
82
|
-
...newState,
|
|
83
|
-
};
|
|
84
|
-
this.assertSerializedStateEquals(expected);
|
|
85
|
-
}
|
|
86
|
-
async stateHonorsDefaultValues() {
|
|
87
|
-
this.bot = this.Bot({
|
|
88
|
-
stateSchema: personWithDefaultsSchema_1.personWithDefaultsSchema,
|
|
89
|
-
});
|
|
90
|
-
this.assertSerializedStateEquals({
|
|
91
|
-
firstName: 'John',
|
|
92
|
-
lastName: 'Doe',
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
async updatingStateEmitsDidUpdateState() {
|
|
96
|
-
let wasHit = false;
|
|
97
|
-
await this.bot.on('did-update-state', () => {
|
|
98
|
-
wasHit = true;
|
|
99
|
-
});
|
|
100
|
-
await this.updateState({
|
|
101
|
-
favoriteColor: 'blue',
|
|
102
|
-
});
|
|
103
|
-
test_utils_1.assert.isTrue(wasHit);
|
|
104
|
-
}
|
|
105
|
-
async knowsWhenDone() {
|
|
106
|
-
test_utils_1.assert.isFalse(this.bot.getIsDone());
|
|
107
|
-
this.bot.markAsDone();
|
|
108
|
-
test_utils_1.assert.isTrue(this.bot.getIsDone());
|
|
109
|
-
}
|
|
110
|
-
async sendMessageReturnsResponseFromAdapter() {
|
|
111
|
-
this.adapter.messageResponse = (0, test_utils_1.generateId)();
|
|
112
|
-
const message = (0, test_utils_1.generateId)();
|
|
113
|
-
const response = await this.sendMessage(message);
|
|
114
|
-
test_utils_1.assert.isEqual(response, this.adapter.messageResponse);
|
|
115
|
-
}
|
|
116
|
-
async tracksMessageHistory() {
|
|
117
|
-
const message = (0, test_utils_1.generateId)();
|
|
118
|
-
this.adapter.messageResponse = (0, test_utils_1.generateId)();
|
|
119
|
-
await this.sendMessage(message);
|
|
120
|
-
const { messages } = this.bot.serialize();
|
|
121
|
-
test_utils_1.assert.isEqualDeep(messages, [
|
|
122
|
-
{
|
|
123
|
-
from: 'Me',
|
|
124
|
-
message,
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
from: 'You',
|
|
128
|
-
message: this.adapter.messageResponse,
|
|
129
|
-
},
|
|
130
|
-
]);
|
|
131
|
-
}
|
|
132
|
-
async trackedMessageUsesResponseFromAdapterNotParser() {
|
|
133
|
-
this.setupBotWithSkill({
|
|
134
|
-
callbacks: {
|
|
135
|
-
helloWorld: {
|
|
136
|
-
cb: () => 'Hello, World!',
|
|
137
|
-
useThisWhenever: 'Hello, World!',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
this.adapter.messageResponse =
|
|
142
|
-
'should use this response to track message history';
|
|
143
|
-
this.parser.response.message = (0, test_utils_1.generateId)();
|
|
144
|
-
await this.sendMessage((0, test_utils_1.generateId)());
|
|
145
|
-
const { messages } = this.bot.serialize();
|
|
146
|
-
test_utils_1.assert.isEqual(messages[1].message, 'should use this response to track message history');
|
|
147
|
-
}
|
|
148
|
-
async isDoneWhenParsesSaysSo() {
|
|
149
|
-
this.setParserResponseIsDone(true);
|
|
150
|
-
await this.sendMessage((0, test_utils_1.generateId)());
|
|
151
|
-
test_utils_1.assert.isTrue(this.bot.getIsDone());
|
|
152
|
-
}
|
|
153
|
-
async notDoneUntilDone() {
|
|
154
|
-
this.setParserResponseIsDone(false);
|
|
155
|
-
await this.sendMessage((0, test_utils_1.generateId)());
|
|
156
|
-
test_utils_1.assert.isFalse(this.bot.getIsDone());
|
|
157
|
-
}
|
|
158
|
-
async botActuallySendsResponseToParser() {
|
|
159
|
-
this.adapter.messageResponse = (0, test_utils_1.generateId)();
|
|
160
|
-
await this.sendMessage((0, test_utils_1.generateId)());
|
|
161
|
-
test_utils_1.assert.isEqual(this.parser.lastMessage, this.adapter.messageResponse);
|
|
162
|
-
}
|
|
163
|
-
async enheritesStateSchemaFromSkillWhenSerializing() {
|
|
164
|
-
this.setupBotWithSkill({
|
|
165
|
-
stateSchema: personSchema_1.personSchema,
|
|
166
|
-
});
|
|
167
|
-
const { stateSchema } = this.serialize();
|
|
168
|
-
test_utils_1.assert.isEqualDeep(stateSchema, personSchema_1.personSchema);
|
|
169
|
-
}
|
|
170
|
-
async inheritsStateFromSkillWhenSerializing(skillState) {
|
|
171
|
-
this.setupBotWithSkill({
|
|
172
|
-
stateSchema: personSchema_1.personSchema,
|
|
173
|
-
state: skillState,
|
|
174
|
-
});
|
|
175
|
-
const { state } = this.bot.serialize();
|
|
176
|
-
test_utils_1.assert.isEqualDeep(state, skillState);
|
|
177
|
-
}
|
|
178
|
-
async stateIsSentBackToBotWhenParsing(state) {
|
|
179
|
-
this.bot = this.Bot({
|
|
180
|
-
stateSchema: personSchema_1.personSchema,
|
|
181
|
-
});
|
|
182
|
-
await this.sendMessageWithResponseState(state);
|
|
183
|
-
this.assertSerializedStateEquals(state);
|
|
184
|
-
}
|
|
185
|
-
async emitsDidUpdateStateWhenStateIsUpdated() {
|
|
186
|
-
this.bot = this.Bot({
|
|
187
|
-
stateSchema: personSchema_1.personSchema,
|
|
188
|
-
});
|
|
189
|
-
let wasHit = false;
|
|
190
|
-
await this.bot.on('did-update-state', () => {
|
|
191
|
-
wasHit = true;
|
|
192
|
-
});
|
|
193
|
-
await this.sendMessageWithResponseState({
|
|
194
|
-
favoriteColor: 'blue',
|
|
195
|
-
});
|
|
196
|
-
test_utils_1.assert.isTrue(wasHit);
|
|
197
|
-
}
|
|
198
|
-
async shouldNotEmitUpdateItNoStatePassed() {
|
|
199
|
-
let wasHit = false;
|
|
200
|
-
await this.bot.on('did-update-state', () => {
|
|
201
|
-
wasHit = true;
|
|
202
|
-
});
|
|
203
|
-
await this.sendRandomMessage();
|
|
204
|
-
test_utils_1.assert.isFalse(wasHit);
|
|
205
|
-
}
|
|
206
|
-
async setsStateInResponseToSkillIfSkillHasState(state) {
|
|
207
|
-
const skill = this.setupBotWithSkill({
|
|
208
|
-
stateSchema: personSchema_1.personSchema,
|
|
209
|
-
});
|
|
210
|
-
await this.sendMessageWithResponseState(state);
|
|
211
|
-
test_utils_1.assert.isEqualDeep(skill.serialize().state, state);
|
|
212
|
-
test_utils_1.assert.isUndefined(this.bot.getState());
|
|
213
|
-
}
|
|
214
|
-
async doesntEmitDidChangeOnSkillIfStateIsNotOnSkill() {
|
|
215
|
-
const skill = this.setupBotWithSkill({});
|
|
216
|
-
let wasHit = false;
|
|
217
|
-
await skill.on('did-update-state', () => {
|
|
218
|
-
wasHit = true;
|
|
219
|
-
});
|
|
220
|
-
await this.sendRandomMessage();
|
|
221
|
-
test_utils_1.assert.isFalse(wasHit);
|
|
222
|
-
}
|
|
223
|
-
async passesCallbacksToParserOnResponse() {
|
|
224
|
-
const callbacks = {
|
|
225
|
-
foo: {
|
|
226
|
-
cb: () => 'hey',
|
|
227
|
-
useThisWhenever: 'hey',
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
this.setupBotWithSkill({
|
|
231
|
-
callbacks,
|
|
232
|
-
});
|
|
233
|
-
await this.sendRandomMessage();
|
|
234
|
-
test_utils_1.assert.isEqual(this.parser.lastCallbacks, callbacks, 'did not pass callbacks to parser');
|
|
235
|
-
}
|
|
236
|
-
async canSwapSkillMidWayThrough() {
|
|
237
|
-
this.setupBotWithSkill({});
|
|
238
|
-
const skill2 = this.Skill();
|
|
239
|
-
this.bot.setSkill(skill2);
|
|
240
|
-
test_utils_1.assert.isEqual(this.bot.getSkill(), skill2);
|
|
241
|
-
}
|
|
242
|
-
async defaultLimitsMessagesTo10() {
|
|
243
|
-
await this.sendRandomMessage();
|
|
244
|
-
this.assertTotalMessagesTracked(2);
|
|
245
|
-
await this.sendRandomMessage();
|
|
246
|
-
this.assertTotalMessagesTracked(4);
|
|
247
|
-
await this.sendRandomMessage();
|
|
248
|
-
await this.sendRandomMessage();
|
|
249
|
-
await this.sendRandomMessage();
|
|
250
|
-
const body = await this.sendRandomMessage();
|
|
251
|
-
this.assertTotalMessagesTracked(10);
|
|
252
|
-
test_utils_1.assert.doesInclude(this.messages, { message: body });
|
|
253
|
-
}
|
|
254
|
-
async canSetMemory() {
|
|
255
|
-
SprucebotLlmBotImpl_1.default.messageMemoryLimit = 5;
|
|
256
|
-
await this.sendRandomMessage();
|
|
257
|
-
this.assertTotalMessagesTracked(2);
|
|
258
|
-
await this.sendRandomMessage();
|
|
259
|
-
this.assertTotalMessagesTracked(4);
|
|
260
|
-
await this.sendRandomMessage();
|
|
261
|
-
await this.sendRandomMessage();
|
|
262
|
-
await this.sendRandomMessage();
|
|
263
|
-
this.assertTotalMessagesTracked(5);
|
|
264
|
-
}
|
|
265
|
-
async settingSkillToBotSetsToNotDone() {
|
|
266
|
-
this.bot.markAsDone();
|
|
267
|
-
this.bot.setSkill(this.Skill());
|
|
268
|
-
test_utils_1.assert.isFalse(this.bot.getIsDone());
|
|
269
|
-
}
|
|
270
|
-
async canClearMessageHistory() {
|
|
271
|
-
await this.sendRandomMessage();
|
|
272
|
-
this.bot.clearMessageHistory();
|
|
273
|
-
test_utils_1.assert.isLength(this.messages, 0);
|
|
274
|
-
}
|
|
275
|
-
async botRespondingCallsMessageCallback() {
|
|
276
|
-
this.setParserResponseMessage();
|
|
277
|
-
let passedMessage;
|
|
278
|
-
await this.sendMessage((0, test_utils_1.generateId)(), (message) => {
|
|
279
|
-
passedMessage = message;
|
|
280
|
-
});
|
|
281
|
-
test_utils_1.assert.isEqual(passedMessage, this.parserResponse);
|
|
282
|
-
}
|
|
283
|
-
async messageCallbackFiredAfterAllMessagesTracked() {
|
|
284
|
-
await this.sendMessage((0, test_utils_1.generateId)(), () => {
|
|
285
|
-
this.assertTotalMessagesTracked(2);
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
async ifParserRespondsWithCallbackResultsTheyAreSentImmediately() {
|
|
289
|
-
const functionCallResponse = (0, test_utils_1.generateId)();
|
|
290
|
-
const response1 = (0, test_utils_1.generateId)();
|
|
291
|
-
const response2 = (0, test_utils_1.generateId)();
|
|
292
|
-
this.adapter.messageResponse = response1;
|
|
293
|
-
this.setParserResponseCallbackResults(functionCallResponse);
|
|
294
|
-
let passedMessages = [];
|
|
295
|
-
const message = await this.sendRandomMessage((message) => {
|
|
296
|
-
passedMessages.push(message);
|
|
297
|
-
this.setParserResponseCallbackResults(undefined);
|
|
298
|
-
this.adapter.messageResponse = response2;
|
|
299
|
-
});
|
|
300
|
-
test_utils_1.assert.isEqualDeep(this.messages, [
|
|
301
|
-
{
|
|
302
|
-
from: 'Me',
|
|
303
|
-
message,
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
from: 'You',
|
|
307
|
-
message: response1,
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
from: 'Api',
|
|
311
|
-
message: `API Results: ${functionCallResponse}`,
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
from: 'You',
|
|
315
|
-
message: response2,
|
|
316
|
-
},
|
|
317
|
-
]);
|
|
318
|
-
test_utils_1.assert.isEqualDeep(passedMessages, [response1, response2], 'Messages passed to callback do not match');
|
|
319
|
-
}
|
|
320
|
-
async handleParserRespondingWithImage() {
|
|
321
|
-
const base64Image = (0, test_utils_1.generateId)();
|
|
322
|
-
const description = (0, test_utils_1.generateId)();
|
|
323
|
-
const functionResponse = {
|
|
324
|
-
imageBase64: base64Image,
|
|
325
|
-
imageDescription: description,
|
|
326
|
-
};
|
|
327
|
-
this.setParserResponseCallbackResults(functionResponse);
|
|
328
|
-
await this.sendRandomMessage(() => {
|
|
329
|
-
this.setParserResponseCallbackResults(undefined);
|
|
330
|
-
});
|
|
331
|
-
test_utils_1.assert.isEqualDeep(this.messages[2], {
|
|
332
|
-
from: 'Api',
|
|
333
|
-
message: `API Results: ${description}`,
|
|
334
|
-
imageBase64: base64Image,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
async sendsMessageBackToBotIfParserThrows() {
|
|
338
|
-
const passedMessages = [];
|
|
339
|
-
const error = (0, test_utils_1.generateId)();
|
|
340
|
-
const parserResponse = (0, test_utils_1.generateId)();
|
|
341
|
-
this.setParserResponseMessage(parserResponse);
|
|
342
|
-
this.parser.invalidParseErrorOnNextParse = error;
|
|
343
|
-
await this.sendMessage((0, test_utils_1.generateId)(), (message) => {
|
|
344
|
-
passedMessages.push(message);
|
|
345
|
-
});
|
|
346
|
-
test_utils_1.assert.isEqual(this.messages[2].message, 'Error: ' + error);
|
|
347
|
-
test_utils_1.assert.isEqualDeep(passedMessages, [parserResponse]);
|
|
348
|
-
}
|
|
349
|
-
async sendsMessageBackToBotIfCallbackThrows() {
|
|
350
|
-
const passedMessages = [];
|
|
351
|
-
const error = (0, test_utils_1.generateId)();
|
|
352
|
-
const parserResponse = (0, test_utils_1.generateId)();
|
|
353
|
-
this.setParserResponseMessage(parserResponse);
|
|
354
|
-
this.parser.callbackErrorOnNextParse = error;
|
|
355
|
-
await this.sendMessage((0, test_utils_1.generateId)(), (message) => {
|
|
356
|
-
passedMessages.push(message);
|
|
357
|
-
});
|
|
358
|
-
test_utils_1.assert.isEqual(this.messages[2].message, 'Error: A Callback error just happened!');
|
|
359
|
-
test_utils_1.assert.isEqualDeep(passedMessages, [parserResponse]);
|
|
360
|
-
}
|
|
361
|
-
async responseThatThrowsIsStillTracked() {
|
|
362
|
-
const error = (0, test_utils_1.generateId)();
|
|
363
|
-
this.adapter.messageResponse = (0, test_utils_1.generateId)();
|
|
364
|
-
this.parser.invalidParseErrorOnNextParse = error;
|
|
365
|
-
const initialMessage = (0, test_utils_1.generateId)();
|
|
366
|
-
await this.sendMessage(initialMessage);
|
|
367
|
-
test_utils_1.assert.isEqualDeep(this.messages, [
|
|
368
|
-
{
|
|
369
|
-
from: 'Me',
|
|
370
|
-
message: initialMessage,
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
from: 'You',
|
|
374
|
-
message: this.adapter.messageResponse,
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
from: 'Api',
|
|
378
|
-
message: 'Error: ' + error,
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
from: 'You',
|
|
382
|
-
message: this.adapter.messageResponse,
|
|
383
|
-
},
|
|
384
|
-
], 'Messages');
|
|
385
|
-
}
|
|
386
|
-
async canSendImage() {
|
|
387
|
-
const base64 = (0, test_utils_1.generateId)();
|
|
388
|
-
const description = (0, test_utils_1.generateId)();
|
|
389
|
-
await this.sendMessage({
|
|
390
|
-
imageBase64: base64,
|
|
391
|
-
imageDescription: description,
|
|
392
|
-
});
|
|
393
|
-
test_utils_1.assert.isEqualDeep(this.messages[0], {
|
|
394
|
-
from: 'Me',
|
|
395
|
-
message: description,
|
|
396
|
-
imageBase64: base64,
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
setParserResponseCallbackResults(results) {
|
|
400
|
-
this.parser.response.callbackResults = results;
|
|
401
|
-
}
|
|
402
|
-
get parserResponse() {
|
|
403
|
-
return this.parser.response.message;
|
|
404
|
-
}
|
|
405
|
-
setParserResponseMessage(message) {
|
|
406
|
-
this.parser.response.message = message ?? (0, test_utils_1.generateId)();
|
|
407
|
-
}
|
|
408
|
-
setParserResponseIsDone(isDone) {
|
|
409
|
-
this.parser.response.isDone = isDone;
|
|
410
|
-
}
|
|
411
|
-
assertTotalMessagesTracked(expected) {
|
|
412
|
-
test_utils_1.assert.isLength(this.messages, expected);
|
|
413
|
-
}
|
|
414
|
-
get messages() {
|
|
415
|
-
return this.bot.getMessages();
|
|
416
|
-
}
|
|
417
|
-
setupBotWithSkill(options) {
|
|
418
|
-
const skill = this.Skill(options);
|
|
419
|
-
this.bot = this.Bot({
|
|
420
|
-
skill,
|
|
421
|
-
});
|
|
422
|
-
return skill;
|
|
423
|
-
}
|
|
424
|
-
async sendMessageWithResponseState(state) {
|
|
425
|
-
this.setStateInResponse(state);
|
|
426
|
-
await this.sendRandomMessage();
|
|
427
|
-
}
|
|
428
|
-
async sendRandomMessage(cb) {
|
|
429
|
-
const body = (0, test_utils_1.generateId)();
|
|
430
|
-
await this.sendMessage(body, cb);
|
|
431
|
-
return body;
|
|
432
|
-
}
|
|
433
|
-
setStateInResponse(state) {
|
|
434
|
-
this.parser.response.state = state;
|
|
435
|
-
}
|
|
436
|
-
async sendMessage(message, cb) {
|
|
437
|
-
return await this.bot.sendMessage(message, cb);
|
|
438
|
-
}
|
|
439
|
-
serialize() {
|
|
440
|
-
return this.bot.serialize();
|
|
441
|
-
}
|
|
442
|
-
async updateState(updates) {
|
|
443
|
-
await this.bot.updateState(updates);
|
|
444
|
-
}
|
|
445
|
-
assertSerializedStateEquals(expected) {
|
|
446
|
-
test_utils_1.assert.isEqualDeep(this.bot.serialize().state, expected);
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
__decorate([
|
|
450
|
-
(0, test_utils_1.test)()
|
|
451
|
-
], LlmBotTest.prototype, "throwsWhenSendingBadMessage", null);
|
|
452
|
-
__decorate([
|
|
453
|
-
(0, test_utils_1.test)()
|
|
454
|
-
], LlmBotTest.prototype, "sendsItselfToTheLlmAdapter", null);
|
|
455
|
-
__decorate([
|
|
456
|
-
(0, test_utils_1.test)()
|
|
457
|
-
], LlmBotTest.prototype, "serializesAsExpected", null);
|
|
458
|
-
__decorate([
|
|
459
|
-
(0, test_utils_1.test)()
|
|
460
|
-
], LlmBotTest.prototype, "canUpdateState", null);
|
|
461
|
-
__decorate([
|
|
462
|
-
(0, test_utils_1.test)()
|
|
463
|
-
], LlmBotTest.prototype, "updatingStateMixesIn", null);
|
|
464
|
-
__decorate([
|
|
465
|
-
(0, test_utils_1.test)()
|
|
466
|
-
], LlmBotTest.prototype, "stateHonorsDefaultValues", null);
|
|
467
|
-
__decorate([
|
|
468
|
-
(0, test_utils_1.test)()
|
|
469
|
-
], LlmBotTest.prototype, "updatingStateEmitsDidUpdateState", null);
|
|
470
|
-
__decorate([
|
|
471
|
-
(0, test_utils_1.test)()
|
|
472
|
-
], LlmBotTest.prototype, "knowsWhenDone", null);
|
|
473
|
-
__decorate([
|
|
474
|
-
(0, test_utils_1.test)()
|
|
475
|
-
], LlmBotTest.prototype, "sendMessageReturnsResponseFromAdapter", null);
|
|
476
|
-
__decorate([
|
|
477
|
-
(0, test_utils_1.test)()
|
|
478
|
-
], LlmBotTest.prototype, "tracksMessageHistory", null);
|
|
479
|
-
__decorate([
|
|
480
|
-
(0, test_utils_1.test)()
|
|
481
|
-
], LlmBotTest.prototype, "trackedMessageUsesResponseFromAdapterNotParser", null);
|
|
482
|
-
__decorate([
|
|
483
|
-
(0, test_utils_1.test)()
|
|
484
|
-
], LlmBotTest.prototype, "isDoneWhenParsesSaysSo", null);
|
|
485
|
-
__decorate([
|
|
486
|
-
(0, test_utils_1.test)()
|
|
487
|
-
], LlmBotTest.prototype, "notDoneUntilDone", null);
|
|
488
|
-
__decorate([
|
|
489
|
-
(0, test_utils_1.test)()
|
|
490
|
-
], LlmBotTest.prototype, "botActuallySendsResponseToParser", null);
|
|
491
|
-
__decorate([
|
|
492
|
-
(0, test_utils_1.test)()
|
|
493
|
-
], LlmBotTest.prototype, "enheritesStateSchemaFromSkillWhenSerializing", null);
|
|
494
|
-
__decorate([
|
|
495
|
-
(0, test_utils_1.test)('inherits state from skill when serializing', {
|
|
496
|
-
favoriteColor: 'blue',
|
|
497
|
-
}),
|
|
498
|
-
(0, test_utils_1.test)('inherits state from skill when serializing 2', {
|
|
499
|
-
firstName: (0, test_utils_1.generateId)(),
|
|
500
|
-
})
|
|
501
|
-
], LlmBotTest.prototype, "inheritsStateFromSkillWhenSerializing", null);
|
|
502
|
-
__decorate([
|
|
503
|
-
(0, test_utils_1.test)('inherits state from bot when parsing response', {
|
|
504
|
-
favoriteColor: 'red',
|
|
505
|
-
}),
|
|
506
|
-
(0, test_utils_1.test)('inherits state from bot when parsing response 2', {
|
|
507
|
-
firstName: (0, test_utils_1.generateId)(),
|
|
508
|
-
})
|
|
509
|
-
], LlmBotTest.prototype, "stateIsSentBackToBotWhenParsing", null);
|
|
510
|
-
__decorate([
|
|
511
|
-
(0, test_utils_1.test)()
|
|
512
|
-
], LlmBotTest.prototype, "emitsDidUpdateStateWhenStateIsUpdated", null);
|
|
513
|
-
__decorate([
|
|
514
|
-
(0, test_utils_1.test)()
|
|
515
|
-
], LlmBotTest.prototype, "shouldNotEmitUpdateItNoStatePassed", null);
|
|
516
|
-
__decorate([
|
|
517
|
-
(0, test_utils_1.test)('sets state in response to skill if skill has state 1', {
|
|
518
|
-
favoriteColor: 'blue',
|
|
519
|
-
}),
|
|
520
|
-
(0, test_utils_1.test)('sets state in response to skill if skill has state 2', {
|
|
521
|
-
firstName: (0, test_utils_1.generateId)(),
|
|
522
|
-
})
|
|
523
|
-
], LlmBotTest.prototype, "setsStateInResponseToSkillIfSkillHasState", null);
|
|
524
|
-
__decorate([
|
|
525
|
-
(0, test_utils_1.test)()
|
|
526
|
-
], LlmBotTest.prototype, "doesntEmitDidChangeOnSkillIfStateIsNotOnSkill", null);
|
|
527
|
-
__decorate([
|
|
528
|
-
(0, test_utils_1.test)()
|
|
529
|
-
], LlmBotTest.prototype, "passesCallbacksToParserOnResponse", null);
|
|
530
|
-
__decorate([
|
|
531
|
-
(0, test_utils_1.test)()
|
|
532
|
-
], LlmBotTest.prototype, "canSwapSkillMidWayThrough", null);
|
|
533
|
-
__decorate([
|
|
534
|
-
(0, test_utils_1.test)()
|
|
535
|
-
], LlmBotTest.prototype, "defaultLimitsMessagesTo10", null);
|
|
536
|
-
__decorate([
|
|
537
|
-
(0, test_utils_1.test)()
|
|
538
|
-
], LlmBotTest.prototype, "canSetMemory", null);
|
|
539
|
-
__decorate([
|
|
540
|
-
(0, test_utils_1.test)()
|
|
541
|
-
], LlmBotTest.prototype, "settingSkillToBotSetsToNotDone", null);
|
|
542
|
-
__decorate([
|
|
543
|
-
(0, test_utils_1.test)()
|
|
544
|
-
], LlmBotTest.prototype, "canClearMessageHistory", null);
|
|
545
|
-
__decorate([
|
|
546
|
-
(0, test_utils_1.test)()
|
|
547
|
-
], LlmBotTest.prototype, "botRespondingCallsMessageCallback", null);
|
|
548
|
-
__decorate([
|
|
549
|
-
(0, test_utils_1.test)()
|
|
550
|
-
], LlmBotTest.prototype, "messageCallbackFiredAfterAllMessagesTracked", null);
|
|
551
|
-
__decorate([
|
|
552
|
-
(0, test_utils_1.test)()
|
|
553
|
-
], LlmBotTest.prototype, "ifParserRespondsWithCallbackResultsTheyAreSentImmediately", null);
|
|
554
|
-
__decorate([
|
|
555
|
-
(0, test_utils_1.test)()
|
|
556
|
-
], LlmBotTest.prototype, "handleParserRespondingWithImage", null);
|
|
557
|
-
__decorate([
|
|
558
|
-
(0, test_utils_1.test)()
|
|
559
|
-
], LlmBotTest.prototype, "sendsMessageBackToBotIfParserThrows", null);
|
|
560
|
-
__decorate([
|
|
561
|
-
(0, test_utils_1.test)()
|
|
562
|
-
], LlmBotTest.prototype, "sendsMessageBackToBotIfCallbackThrows", null);
|
|
563
|
-
__decorate([
|
|
564
|
-
(0, test_utils_1.test)()
|
|
565
|
-
], LlmBotTest.prototype, "responseThatThrowsIsStillTracked", null);
|
|
566
|
-
__decorate([
|
|
567
|
-
(0, test_utils_1.test)()
|
|
568
|
-
], LlmBotTest.prototype, "canSendImage", null);
|
|
569
|
-
LlmBotTest = __decorate([
|
|
570
|
-
(0, test_utils_1.suite)()
|
|
571
|
-
], LlmBotTest);
|
|
572
|
-
exports.default = LlmBotTest;
|
|
573
|
-
class FakeResponseParser extends ResponseParser_1.default {
|
|
574
|
-
constructor() {
|
|
575
|
-
super(...arguments);
|
|
576
|
-
this.response = {
|
|
577
|
-
isDone: false,
|
|
578
|
-
state: undefined,
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
async parse(message, callbacks) {
|
|
582
|
-
if (this.invalidParseErrorOnNextParse) {
|
|
583
|
-
const invalidParse = this.invalidParseErrorOnNextParse;
|
|
584
|
-
delete this.invalidParseErrorOnNextParse;
|
|
585
|
-
throw new SpruceError_1.default({
|
|
586
|
-
code: 'INVALID_CALLBACK',
|
|
587
|
-
matchedCallback: (0, test_utils_1.generateId)(),
|
|
588
|
-
validCallbacks: [],
|
|
589
|
-
friendlyMessage: invalidParse,
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
if (this.callbackErrorOnNextParse) {
|
|
593
|
-
delete this.callbackErrorOnNextParse;
|
|
594
|
-
throw new SpruceError_1.default({
|
|
595
|
-
code: 'CALLBACK_ERROR',
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
this.lastMessage = message;
|
|
599
|
-
this.lastCallbacks = callbacks;
|
|
600
|
-
return {
|
|
601
|
-
message,
|
|
602
|
-
isDone: false,
|
|
603
|
-
...this.response,
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
//# sourceMappingURL=LlmBot.test.js.map
|