@botonic/plugin-ai-agents 0.36.0-alpha.1 → 0.36.0-alpha.10
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/README.md +14 -0
- package/lib/cjs/agent-builder.d.ts +10 -0
- package/lib/cjs/agent-builder.js +43 -0
- package/lib/cjs/agent-builder.js.map +1 -0
- package/lib/cjs/constants.d.ts +3 -2
- package/lib/cjs/constants.js +5 -4
- package/lib/cjs/constants.js.map +1 -1
- package/lib/{esm/hubtype-client.d.ts → cjs/hubtype-api-client.d.ts} +3 -1
- package/lib/cjs/hubtype-api-client.js +76 -0
- package/lib/cjs/hubtype-api-client.js.map +1 -0
- package/lib/cjs/index.d.ts +5 -2
- package/lib/cjs/index.js +40 -17
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/openai.d.ts +1 -0
- package/lib/cjs/openai.js +23 -0
- package/lib/cjs/openai.js.map +1 -0
- package/lib/cjs/runner.d.ts +7 -0
- package/lib/cjs/runner.js +35 -0
- package/lib/cjs/runner.js.map +1 -0
- package/lib/cjs/structured-output/carousel.d.ts +100 -0
- package/lib/cjs/structured-output/carousel.js +21 -0
- package/lib/cjs/structured-output/carousel.js.map +1 -0
- package/lib/cjs/structured-output/exit.d.ts +12 -0
- package/lib/cjs/structured-output/exit.js +11 -0
- package/lib/cjs/structured-output/exit.js.map +1 -0
- package/lib/cjs/structured-output/index.d.ts +198 -0
- package/lib/cjs/structured-output/index.js +14 -0
- package/lib/cjs/structured-output/index.js.map +1 -0
- package/lib/cjs/structured-output/shared.d.ts +3 -0
- package/lib/cjs/structured-output/shared.js +3 -0
- package/lib/cjs/structured-output/shared.js.map +1 -0
- package/lib/cjs/structured-output/text-with-buttons.d.ts +34 -0
- package/lib/cjs/structured-output/text-with-buttons.js +15 -0
- package/lib/cjs/structured-output/text-with-buttons.js.map +1 -0
- package/lib/cjs/structured-output/text.d.ts +28 -0
- package/lib/cjs/structured-output/text.js +13 -0
- package/lib/cjs/structured-output/text.js.map +1 -0
- package/lib/cjs/tools/index.d.ts +2 -0
- package/lib/cjs/tools/index.js +5 -0
- package/lib/cjs/tools/index.js.map +1 -0
- package/lib/cjs/types.d.ts +20 -22
- package/lib/esm/agent-builder.d.ts +10 -0
- package/lib/esm/agent-builder.js +39 -0
- package/lib/esm/agent-builder.js.map +1 -0
- package/lib/esm/constants.d.ts +3 -2
- package/lib/esm/constants.js +4 -3
- package/lib/esm/constants.js.map +1 -1
- package/lib/{cjs/hubtype-client.d.ts → esm/hubtype-api-client.d.ts} +3 -1
- package/lib/esm/hubtype-api-client.js +72 -0
- package/lib/esm/hubtype-api-client.js.map +1 -0
- package/lib/esm/index.d.ts +5 -2
- package/lib/esm/index.js +39 -16
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/openai.d.ts +1 -0
- package/lib/esm/openai.js +19 -0
- package/lib/esm/openai.js.map +1 -0
- package/lib/esm/runner.d.ts +7 -0
- package/lib/esm/runner.js +31 -0
- package/lib/esm/runner.js.map +1 -0
- package/lib/esm/structured-output/carousel.d.ts +100 -0
- package/lib/esm/structured-output/carousel.js +18 -0
- package/lib/esm/structured-output/carousel.js.map +1 -0
- package/lib/esm/structured-output/exit.d.ts +12 -0
- package/lib/esm/structured-output/exit.js +7 -0
- package/lib/esm/structured-output/exit.js.map +1 -0
- package/lib/esm/structured-output/index.d.ts +198 -0
- package/lib/esm/structured-output/index.js +11 -0
- package/lib/esm/structured-output/index.js.map +1 -0
- package/lib/esm/structured-output/shared.d.ts +3 -0
- package/lib/esm/structured-output/shared.js +2 -0
- package/lib/esm/structured-output/shared.js.map +1 -0
- package/lib/esm/structured-output/text-with-buttons.d.ts +34 -0
- package/lib/esm/structured-output/text-with-buttons.js +11 -0
- package/lib/esm/structured-output/text-with-buttons.js.map +1 -0
- package/lib/esm/structured-output/text.d.ts +28 -0
- package/lib/esm/structured-output/text.js +10 -0
- package/lib/esm/structured-output/text.js.map +1 -0
- package/lib/esm/tools/index.d.ts +2 -0
- package/lib/esm/tools/index.js +2 -0
- package/lib/esm/tools/index.js.map +1 -0
- package/lib/esm/types.d.ts +20 -22
- package/package.json +7 -7
- package/src/agent-builder.ts +48 -0
- package/src/constants.ts +7 -4
- package/src/hubtype-api-client.ts +89 -0
- package/src/index.ts +56 -19
- package/src/openai.ts +30 -0
- package/src/runner.ts +43 -0
- package/src/structured-output/carousel.ts +36 -0
- package/src/structured-output/exit.ts +15 -0
- package/src/structured-output/index.ts +27 -0
- package/src/structured-output/shared.ts +3 -0
- package/src/structured-output/text-with-buttons.ts +23 -0
- package/src/structured-output/text.ts +19 -0
- package/src/tools/index.ts +3 -0
- package/src/types.ts +27 -29
- package/lib/cjs/ai-agent-client.d.ts +0 -11
- package/lib/cjs/ai-agent-client.js +0 -50
- package/lib/cjs/ai-agent-client.js.map +0 -1
- package/lib/cjs/errors.d.ts +0 -3
- package/lib/cjs/errors.js +0 -11
- package/lib/cjs/errors.js.map +0 -1
- package/lib/cjs/hubtype-client.js +0 -36
- package/lib/cjs/hubtype-client.js.map +0 -1
- package/lib/cjs/tools.d.ts +0 -6
- package/lib/cjs/tools.js +0 -41
- package/lib/cjs/tools.js.map +0 -1
- package/lib/cjs/utils.d.ts +0 -2
- package/lib/cjs/utils.js +0 -22
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/ai-agent-client.d.ts +0 -11
- package/lib/esm/ai-agent-client.js +0 -46
- package/lib/esm/ai-agent-client.js.map +0 -1
- package/lib/esm/errors.d.ts +0 -3
- package/lib/esm/errors.js +0 -7
- package/lib/esm/errors.js.map +0 -1
- package/lib/esm/hubtype-client.js +0 -32
- package/lib/esm/hubtype-client.js.map +0 -1
- package/lib/esm/tools.d.ts +0 -6
- package/lib/esm/tools.js +0 -38
- package/lib/esm/tools.js.map +0 -1
- package/lib/esm/utils.d.ts +0 -2
- package/lib/esm/utils.js +0 -18
- package/lib/esm/utils.js.map +0 -1
- package/src/ai-agent-client.ts +0 -73
- package/src/errors.ts +0 -6
- package/src/hubtype-client.ts +0 -43
- package/src/tools.ts +0 -51
- package/src/utils.ts +0 -24
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Botonic Plugin AI Agents
|
|
2
|
+
|
|
3
|
+
## env variables
|
|
4
|
+
|
|
5
|
+
You need this env variables when deploy a bot that use this plugin
|
|
6
|
+
|
|
7
|
+
.env
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
AZURE_OPENAI_API_KEY='FAKE_API_KEY' // pragma: allowlist secret
|
|
11
|
+
AZURE_OPENAI_API_BASE='FAKE_API_URL_BASE'
|
|
12
|
+
AZURE_OPENAI_API_DEPLOYMENT_NAME='gpt-4o-mini_p1'
|
|
13
|
+
AZURE_OPENAI_API_VERSION='2024-12-01-preview'
|
|
14
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AIAgent, Tool } from './types';
|
|
2
|
+
export declare class AIAgentBuilder {
|
|
3
|
+
private name;
|
|
4
|
+
private instructions;
|
|
5
|
+
private tools;
|
|
6
|
+
constructor(name: string, instructions: string, tools: Tool[]);
|
|
7
|
+
build(): AIAgent;
|
|
8
|
+
private addExtraInstructions;
|
|
9
|
+
private addHubtypeTools;
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIAgentBuilder = void 0;
|
|
4
|
+
const agents_1 = require("@openai/agents");
|
|
5
|
+
const structured_output_1 = require("./structured-output");
|
|
6
|
+
const tools_1 = require("./tools");
|
|
7
|
+
class AIAgentBuilder {
|
|
8
|
+
constructor(name, instructions, tools) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.instructions = this.addExtraInstructions(instructions);
|
|
11
|
+
this.tools = this.addHubtypeTools(tools);
|
|
12
|
+
}
|
|
13
|
+
build() {
|
|
14
|
+
return new agents_1.Agent({
|
|
15
|
+
name: this.name,
|
|
16
|
+
instructions: this.instructions,
|
|
17
|
+
tools: this.tools,
|
|
18
|
+
outputType: structured_output_1.OutputSchema,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
addExtraInstructions(instructions) {
|
|
22
|
+
const metadata = `Current Date: ${new Date().toISOString()}`;
|
|
23
|
+
const example = {
|
|
24
|
+
messages: [
|
|
25
|
+
{
|
|
26
|
+
type: 'text',
|
|
27
|
+
content: {
|
|
28
|
+
text: 'Hello, how can I help you today?',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
numMessages: 1,
|
|
33
|
+
};
|
|
34
|
+
const output = `Return a JSON that follows the output schema provided. Never return multiple output schemas concatenated by a line break.\n<example>\n${JSON.stringify(example)}\n</example>`;
|
|
35
|
+
return `<instructions>\n${instructions}\n</instructions>\n\n<metadata>\n${metadata}\n</metadata>\n\n<output>\n${output}\n</output>`;
|
|
36
|
+
}
|
|
37
|
+
addHubtypeTools(tools) {
|
|
38
|
+
const hubtypeTools = [...tools_1.mandatoryTools];
|
|
39
|
+
return [...hubtypeTools, ...tools];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.AIAgentBuilder = AIAgentBuilder;
|
|
43
|
+
//# sourceMappingURL=agent-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-builder.js","sourceRoot":"","sources":["../../src/agent-builder.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAEtC,2DAAkD;AAClD,mCAAwC;AAGxC,MAAa,cAAc;IAKzB,YAAY,IAAY,EAAE,YAAoB,EAAE,KAAa;QAC3D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAA;QAC3D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED,KAAK;QACH,OAAO,IAAI,cAAK,CAAC;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,gCAAY;SACzB,CAAC,CAAA;IACJ,CAAC;IAEO,oBAAoB,CAAC,YAAoB;QAC/C,MAAM,QAAQ,GAAG,iBAAiB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAA;QAC5D,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,kCAAkC;qBACzC;iBACF;aACF;YACD,WAAW,EAAE,CAAC;SACf,CAAA;QACD,MAAM,MAAM,GAAG,yIAAyI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,CAAA;QAC7L,OAAO,mBAAmB,YAAY,oCAAoC,QAAQ,8BAA8B,MAAM,aAAa,CAAA;IACrI,CAAC;IAEO,eAAe,CAAC,KAAa;QACnC,MAAM,YAAY,GAAW,CAAC,GAAG,sBAAc,CAAC,CAAA;QAChD,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC,CAAA;IACpC,CAAC;CACF;AAzCD,wCAyCC"}
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const HUBTYPE_API_URL: string;
|
|
2
2
|
export declare const AZURE_OPENAI_API_KEY: string | undefined;
|
|
3
|
-
export declare const AZURE_OPENAI_API_DEPLOYMENT_NAME: string | undefined;
|
|
4
|
-
export declare const AZURE_OPENAI_API_VERSION: string | undefined;
|
|
5
3
|
export declare const AZURE_OPENAI_API_BASE: string | undefined;
|
|
4
|
+
export declare const AZURE_OPENAI_API_DEPLOYMENT_NAME: string;
|
|
5
|
+
export declare const AZURE_OPENAI_API_VERSION: string;
|
|
6
|
+
export declare const isProd: boolean;
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isProd = exports.AZURE_OPENAI_API_VERSION = exports.AZURE_OPENAI_API_DEPLOYMENT_NAME = exports.AZURE_OPENAI_API_BASE = exports.AZURE_OPENAI_API_KEY = exports.HUBTYPE_API_URL = void 0;
|
|
4
4
|
exports.HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
5
|
-
exports.AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY;
|
|
6
|
-
exports.AZURE_OPENAI_API_DEPLOYMENT_NAME = process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME;
|
|
7
|
-
exports.AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION;
|
|
5
|
+
exports.AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY; // pragma: allowlist secret
|
|
8
6
|
exports.AZURE_OPENAI_API_BASE = process.env.AZURE_OPENAI_API_BASE;
|
|
7
|
+
exports.AZURE_OPENAI_API_DEPLOYMENT_NAME = process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || 'gpt-4o-mini_p1';
|
|
8
|
+
exports.AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION || '2024-12-01-preview';
|
|
9
|
+
exports.isProd = process.env.NODE_ENV === 'production';
|
|
9
10
|
//# sourceMappingURL=constants.js.map
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAE7C,QAAA,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAE7C,QAAA,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA,CAAC,2BAA2B;AACnF,QAAA,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;AACzD,QAAA,gCAAgC,GAC3C,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,gBAAgB,CAAA;AACrD,QAAA,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,oBAAoB,CAAA;AAEjD,QAAA,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BotContext } from '@botonic/core';
|
|
2
2
|
import { AgenticInputMessage } from './types';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class HubtypeApiClient {
|
|
4
4
|
private readonly authToken;
|
|
5
5
|
constructor(authToken: string);
|
|
6
|
+
getLocalMessages(memoryLength: number): Promise<AgenticInputMessage[]>;
|
|
6
7
|
getMessages(request: BotContext, memoryLength: number): Promise<AgenticInputMessage[]>;
|
|
8
|
+
private formatMessage;
|
|
7
9
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubtypeApiClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
class HubtypeApiClient {
|
|
8
|
+
constructor(authToken) {
|
|
9
|
+
this.authToken = authToken;
|
|
10
|
+
}
|
|
11
|
+
getLocalMessages(memoryLength) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const localBotonicState = localStorage.getItem('botonicState');
|
|
14
|
+
const botonicState = JSON.parse(localBotonicState || '{}');
|
|
15
|
+
const messages = botonicState.messages;
|
|
16
|
+
const filteredMessages = messages
|
|
17
|
+
.filter(message => message.data.text)
|
|
18
|
+
.map(message => ({
|
|
19
|
+
role: message.sentBy === 'user' ? 'user' : 'assistant',
|
|
20
|
+
content: message.data.text,
|
|
21
|
+
}))
|
|
22
|
+
.map(message => this.formatMessage(message));
|
|
23
|
+
return filteredMessages.slice(-memoryLength);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
getMessages(request, memoryLength) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const url = `${constants_1.HUBTYPE_API_URL}/external/v1/ai/agent/message_history/`;
|
|
29
|
+
const headers = {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
32
|
+
};
|
|
33
|
+
const params = {
|
|
34
|
+
last_message_id: request.input.message_id,
|
|
35
|
+
num_messages: memoryLength,
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
const response = yield axios_1.default.get(url, {
|
|
39
|
+
headers,
|
|
40
|
+
params,
|
|
41
|
+
});
|
|
42
|
+
const messages = response.data.messages;
|
|
43
|
+
return messages.map(message => this.formatMessage(message));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error(error);
|
|
47
|
+
throw new Error('Failed to get messages from Hubtype');
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
formatMessage(message) {
|
|
52
|
+
if (message.role === 'user') {
|
|
53
|
+
return {
|
|
54
|
+
content: message.content,
|
|
55
|
+
role: 'user',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else if (message.role === 'assistant') {
|
|
59
|
+
return {
|
|
60
|
+
role: 'assistant',
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: 'output_text',
|
|
64
|
+
text: message.content,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
status: 'completed',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error('Invalid message role');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.HubtypeApiClient = HubtypeApiClient;
|
|
76
|
+
//# sourceMappingURL=hubtype-api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hubtype-api-client.js","sourceRoot":"","sources":["../../src/hubtype-api-client.ts"],"names":[],"mappings":";;;;AAEA,0DAAyB;AAEzB,2CAA6C;AAe7C,MAAa,gBAAgB;IAG3B,YAAY,SAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEK,gBAAgB,CAAC,YAAoB;;YACzC,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;YAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAA;YAC1D,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAA;YACtC,MAAM,gBAAgB,GAAG,QAAQ;iBAC9B,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;iBACpC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACf,IAAI,EAAE,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW;gBACtD,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;aAC3B,CAAC,CAAC;iBACF,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;YAC9C,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAA;QAC9C,CAAC;KAAA;IAEK,WAAW,CACf,OAAmB,EACnB,YAAoB;;YAEpB,MAAM,GAAG,GAAG,GAAG,2BAAe,wCAAwC,CAAA;YACtE,MAAM,OAAO,GAAG;gBACd,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,IAAI,CAAC,SAAS,EAAE;aAC1C,CAAA;YACD,MAAM,MAAM,GAAG;gBACb,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU;gBACzC,YAAY,EAAE,YAAY;aAC3B,CAAA;YAED,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAiC,GAAG,EAAE;oBACpE,OAAO;oBACP,MAAM;iBACP,CAAC,CAAA;gBACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAA;gBACvC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;aAC5D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACpB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;aACvD;QACH,CAAC;KAAA;IAEO,aAAa,CAAC,OAAuB;QAC3C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;YAC3B,OAAO;gBACL,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,MAAM;aACb,CAAA;SACF;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE;YACvC,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE,OAAO,CAAC,OAAO;qBACtB;iBACF;gBACD,MAAM,EAAE,WAAW;aACpB,CAAA;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;SACxC;IACH,CAAC;CACF;AArED,4CAqEC"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { BotContext, Plugin } from '@botonic/core';
|
|
2
|
-
import { AgenticOutputMessage, AiAgentArgs, PluginAiAgentOptions } from './types';
|
|
2
|
+
import { AgenticOutputMessage, AiAgentArgs, CustomTool, PluginAiAgentOptions } from './types';
|
|
3
3
|
export default class BotonicPluginAiAgents implements Plugin {
|
|
4
4
|
private readonly authToken?;
|
|
5
|
+
toolDefinitions: CustomTool[];
|
|
5
6
|
constructor(options?: PluginAiAgentOptions);
|
|
6
7
|
pre(): void;
|
|
7
|
-
getInference(request: BotContext, aiAgentArgs: AiAgentArgs): Promise<AgenticOutputMessage | undefined>;
|
|
8
|
+
getInference(request: BotContext, aiAgentArgs: AiAgentArgs): Promise<AgenticOutputMessage[] | undefined>;
|
|
9
|
+
private getMessages;
|
|
10
|
+
private buildTools;
|
|
8
11
|
}
|
|
9
12
|
export * from './types';
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const agents_1 = require("@openai/agents");
|
|
5
|
+
const agent_builder_1 = require("./agent-builder");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const hubtype_api_client_1 = require("./hubtype-api-client");
|
|
8
|
+
const openai_1 = require("./openai");
|
|
9
|
+
const runner_1 = require("./runner");
|
|
9
10
|
class BotonicPluginAiAgents {
|
|
10
11
|
constructor(options) {
|
|
12
|
+
this.toolDefinitions = [];
|
|
13
|
+
(0, openai_1.setUpOpenAI)();
|
|
11
14
|
this.authToken = options === null || options === void 0 ? void 0 : options.authToken;
|
|
15
|
+
this.toolDefinitions = (options === null || options === void 0 ? void 0 : options.customTools) || [];
|
|
12
16
|
}
|
|
13
17
|
pre() {
|
|
14
18
|
return;
|
|
15
19
|
}
|
|
16
20
|
getInference(request, aiAgentArgs) {
|
|
21
|
+
var _a;
|
|
17
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
23
|
try {
|
|
19
|
-
const authToken = isProd ? request.session._access_token : this.authToken;
|
|
24
|
+
const authToken = constants_1.isProd ? request.session._access_token : this.authToken;
|
|
20
25
|
if (!authToken) {
|
|
21
26
|
throw new Error('Auth token is required');
|
|
22
27
|
}
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
...tools_1.MANDATORY_TOOLS,
|
|
32
|
-
]);
|
|
33
|
-
return yield aiAgentClient.runAgent(messages);
|
|
28
|
+
const tools = this.buildTools(((_a = aiAgentArgs.activeTools) === null || _a === void 0 ? void 0 : _a.map(tool => tool.name)) || []);
|
|
29
|
+
const agent = new agent_builder_1.AIAgentBuilder(aiAgentArgs.name, aiAgentArgs.instructions, tools).build();
|
|
30
|
+
const messages = yield this.getMessages(request, authToken, 25);
|
|
31
|
+
const context = {
|
|
32
|
+
authToken,
|
|
33
|
+
};
|
|
34
|
+
const runner = new runner_1.AIAgentRunner(agent);
|
|
35
|
+
return yield runner.run(messages, context);
|
|
34
36
|
}
|
|
35
37
|
catch (error) {
|
|
36
38
|
console.error('error plugin returns undefined', error);
|
|
@@ -38,6 +40,27 @@ class BotonicPluginAiAgents {
|
|
|
38
40
|
}
|
|
39
41
|
});
|
|
40
42
|
}
|
|
43
|
+
getMessages(request, authToken, memoryLength) {
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (constants_1.isProd) {
|
|
46
|
+
const hubtypeClient = new hubtype_api_client_1.HubtypeApiClient(authToken);
|
|
47
|
+
return yield hubtypeClient.getMessages(request, memoryLength);
|
|
48
|
+
}
|
|
49
|
+
const hubtypeClient = new hubtype_api_client_1.HubtypeApiClient(authToken);
|
|
50
|
+
return yield hubtypeClient.getLocalMessages(memoryLength);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
buildTools(activeToolNames) {
|
|
54
|
+
const availableTools = this.toolDefinitions.filter(tool => activeToolNames.includes(tool.name));
|
|
55
|
+
return availableTools.map(toolDefinition => {
|
|
56
|
+
return (0, agents_1.tool)({
|
|
57
|
+
name: toolDefinition.name,
|
|
58
|
+
description: toolDefinition.description,
|
|
59
|
+
parameters: toolDefinition.schema,
|
|
60
|
+
execute: toolDefinition.func,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
41
64
|
}
|
|
42
65
|
exports.default = BotonicPluginAiAgents;
|
|
43
66
|
tslib_1.__exportStar(require("./types"), exports);
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,2CAAqC;AAErC,mDAAgD;AAChD,2CAAoC;AACpC,6DAAuD;AACvD,qCAAsC;AACtC,qCAAwC;AAWxC,MAAqB,qBAAqB;IAIxC,YAAY,OAA8B;QAFnC,oBAAe,GAAiB,EAAE,CAAA;QAGvC,IAAA,oBAAW,GAAE,CAAA;QACb,IAAI,CAAC,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA;QACnC,IAAI,CAAC,eAAe,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,EAAE,CAAA;IACnD,CAAC;IAED,GAAG;QACD,OAAM;IACR,CAAC;IAEK,YAAY,CAChB,OAAmB,EACnB,WAAwB;;;YAExB,IAAI;gBACF,MAAM,SAAS,GAAG,kBAAM,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAA;gBACzE,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;iBAC1C;gBAED,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAC3B,CAAA,MAAA,WAAW,CAAC,WAAW,0CAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,EAAE,CACtD,CAAA;gBACD,MAAM,KAAK,GAAG,IAAI,8BAAc,CAC9B,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,YAAY,EACxB,KAAK,CACN,CAAC,KAAK,EAAE,CAAA;gBAET,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA;gBAC/D,MAAM,OAAO,GAAY;oBACvB,SAAS;iBACV,CAAA;gBAED,MAAM,MAAM,GAAG,IAAI,sBAAa,CAAC,KAAK,CAAC,CAAA;gBACvC,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;aAC3C;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAA;gBACtD,OAAO,SAAS,CAAA;aACjB;;KACF;IAEa,WAAW,CACvB,OAAmB,EACnB,SAAiB,EACjB,YAAoB;;YAEpB,IAAI,kBAAM,EAAE;gBACV,MAAM,aAAa,GAAG,IAAI,qCAAgB,CAAC,SAAS,CAAC,CAAA;gBACrD,OAAO,MAAM,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;aAC9D;YACD,MAAM,aAAa,GAAG,IAAI,qCAAgB,CAAC,SAAS,CAAC,CAAA;YACrD,OAAO,MAAM,aAAa,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAA;QAC3D,CAAC;KAAA;IAEO,UAAU,CAAC,eAAyB;QAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CACxD,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CACpC,CAAA;QACD,OAAO,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;YACzC,OAAO,IAAA,aAAI,EAAoB;gBAC7B,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,WAAW,EAAE,cAAc,CAAC,WAAW;gBACvC,UAAU,EAAE,cAAc,CAAC,MAAM;gBACjC,OAAO,EAAE,cAAc,CAAC,IAAI;aAC7B,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAxED,wCAwEC;AAED,kDAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setUpOpenAI(): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUpOpenAI = void 0;
|
|
4
|
+
const agents_1 = require("@openai/agents");
|
|
5
|
+
const openai_1 = require("openai");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
function setUpOpenAI() {
|
|
8
|
+
setAzureOpenAIClient();
|
|
9
|
+
(0, agents_1.setOpenAIAPI)('chat_completions');
|
|
10
|
+
(0, agents_1.setTracingDisabled)(true);
|
|
11
|
+
}
|
|
12
|
+
exports.setUpOpenAI = setUpOpenAI;
|
|
13
|
+
function setAzureOpenAIClient() {
|
|
14
|
+
const client = new openai_1.AzureOpenAI({
|
|
15
|
+
apiKey: constants_1.AZURE_OPENAI_API_KEY,
|
|
16
|
+
apiVersion: constants_1.AZURE_OPENAI_API_VERSION,
|
|
17
|
+
deployment: constants_1.AZURE_OPENAI_API_DEPLOYMENT_NAME,
|
|
18
|
+
baseURL: constants_1.AZURE_OPENAI_API_BASE,
|
|
19
|
+
dangerouslyAllowBrowser: !constants_1.isProd,
|
|
20
|
+
});
|
|
21
|
+
(0, agents_1.setDefaultOpenAIClient)(client);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/openai.ts"],"names":[],"mappings":";;;AAAA,2CAIuB;AACvB,mCAAoC;AACpC,2CAMoB;AAEpB,SAAgB,WAAW;IACzB,oBAAoB,EAAE,CAAA;IACtB,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAA;IAChC,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,kCAIC;AAED,SAAS,oBAAoB;IAC3B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC7B,MAAM,EAAE,gCAAoB;QAC5B,UAAU,EAAE,oCAAwB;QACpC,UAAU,EAAE,4CAAgC;QAC5C,OAAO,EAAE,iCAAqB;QAC9B,uBAAuB,EAAE,CAAC,kBAAM;KACjC,CAAC,CAAA;IACF,IAAA,+BAAsB,EAAC,MAAM,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AIAgent, AgenticInputMessage, AgenticOutputMessage, Context } from './types';
|
|
2
|
+
export declare class AIAgentRunner {
|
|
3
|
+
private agent;
|
|
4
|
+
constructor(agent: AIAgent);
|
|
5
|
+
run(messages: AgenticInputMessage[], context: Context, maxRetries?: number): Promise<AgenticOutputMessage[]>;
|
|
6
|
+
private runWithRetry;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIAgentRunner = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const agents_1 = require("@openai/agents");
|
|
6
|
+
class AIAgentRunner {
|
|
7
|
+
constructor(agent) {
|
|
8
|
+
this.agent = agent;
|
|
9
|
+
}
|
|
10
|
+
run(messages, context, maxRetries = 1) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
return this.runWithRetry(messages, context, maxRetries, 1);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
runWithRetry(messages, context, maxRetries, attempt) {
|
|
16
|
+
var _a;
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
const runner = new agents_1.Runner({
|
|
20
|
+
modelSettings: { temperature: 0 },
|
|
21
|
+
});
|
|
22
|
+
const result = yield runner.run(this.agent, messages, { context });
|
|
23
|
+
return ((_a = result.finalOutput) === null || _a === void 0 ? void 0 : _a.messages) || [];
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (attempt > maxRetries) {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
return this.runWithRetry(messages, context, maxRetries, attempt + 1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AIAgentRunner = AIAgentRunner;
|
|
35
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";;;;AAAA,2CAAuC;AAQvC,MAAa,aAAa;IAGxB,YAAY,KAAc;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,OAAgB,EAChB,aAAqB,CAAC;;YAEtB,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QAC5D,CAAC;KAAA;IAEa,YAAY,CACxB,QAA+B,EAC/B,OAAgB,EAChB,UAAkB,EAClB,OAAe;;;YAEf,IAAI;gBACF,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;oBACxB,aAAa,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;iBAClC,CAAC,CAAA;gBACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;gBAClE,OAAO,CAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,QAAQ,KAAI,EAAE,CAAA;aAC1C;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,OAAO,GAAG,UAAU,EAAE;oBACxB,MAAM,KAAK,CAAA;iBACZ;gBACD,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,CAAC,CAAC,CAAA;aACrE;;KACF;CACF;AAlCD,sCAkCC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseMessage } from './shared';
|
|
3
|
+
interface CarouselElement {
|
|
4
|
+
title: string;
|
|
5
|
+
subtitle: string;
|
|
6
|
+
image: string;
|
|
7
|
+
button: {
|
|
8
|
+
text: string;
|
|
9
|
+
url: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface CarouselMessage extends BaseMessage {
|
|
13
|
+
type: 'carousel';
|
|
14
|
+
content: {
|
|
15
|
+
elements: CarouselElement[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare const CarouselSchema: z.ZodObject<{
|
|
19
|
+
type: z.ZodEnum<["carousel"]>;
|
|
20
|
+
content: z.ZodObject<{
|
|
21
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
22
|
+
title: z.ZodString;
|
|
23
|
+
subtitle: z.ZodString;
|
|
24
|
+
image: z.ZodString;
|
|
25
|
+
button: z.ZodObject<{
|
|
26
|
+
text: z.ZodString;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
text: string;
|
|
30
|
+
url: string;
|
|
31
|
+
}, {
|
|
32
|
+
text: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
title: string;
|
|
37
|
+
subtitle: string;
|
|
38
|
+
image: string;
|
|
39
|
+
button: {
|
|
40
|
+
text: string;
|
|
41
|
+
url: string;
|
|
42
|
+
};
|
|
43
|
+
}, {
|
|
44
|
+
title: string;
|
|
45
|
+
subtitle: string;
|
|
46
|
+
image: string;
|
|
47
|
+
button: {
|
|
48
|
+
text: string;
|
|
49
|
+
url: string;
|
|
50
|
+
};
|
|
51
|
+
}>, "many">;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
elements: {
|
|
54
|
+
title: string;
|
|
55
|
+
subtitle: string;
|
|
56
|
+
image: string;
|
|
57
|
+
button: {
|
|
58
|
+
text: string;
|
|
59
|
+
url: string;
|
|
60
|
+
};
|
|
61
|
+
}[];
|
|
62
|
+
}, {
|
|
63
|
+
elements: {
|
|
64
|
+
title: string;
|
|
65
|
+
subtitle: string;
|
|
66
|
+
image: string;
|
|
67
|
+
button: {
|
|
68
|
+
text: string;
|
|
69
|
+
url: string;
|
|
70
|
+
};
|
|
71
|
+
}[];
|
|
72
|
+
}>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
type: "carousel";
|
|
75
|
+
content: {
|
|
76
|
+
elements: {
|
|
77
|
+
title: string;
|
|
78
|
+
subtitle: string;
|
|
79
|
+
image: string;
|
|
80
|
+
button: {
|
|
81
|
+
text: string;
|
|
82
|
+
url: string;
|
|
83
|
+
};
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
}, {
|
|
87
|
+
type: "carousel";
|
|
88
|
+
content: {
|
|
89
|
+
elements: {
|
|
90
|
+
title: string;
|
|
91
|
+
subtitle: string;
|
|
92
|
+
image: string;
|
|
93
|
+
button: {
|
|
94
|
+
text: string;
|
|
95
|
+
url: string;
|
|
96
|
+
};
|
|
97
|
+
}[];
|
|
98
|
+
};
|
|
99
|
+
}>;
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarouselSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.CarouselSchema = zod_1.z
|
|
6
|
+
.object({
|
|
7
|
+
type: zod_1.z.enum(['carousel']),
|
|
8
|
+
content: zod_1.z.object({
|
|
9
|
+
elements: zod_1.z.array(zod_1.z.object({
|
|
10
|
+
title: zod_1.z.string(),
|
|
11
|
+
subtitle: zod_1.z.string(),
|
|
12
|
+
image: zod_1.z.string(),
|
|
13
|
+
button: zod_1.z.object({
|
|
14
|
+
text: zod_1.z.string(),
|
|
15
|
+
url: zod_1.z.string(),
|
|
16
|
+
}),
|
|
17
|
+
})),
|
|
18
|
+
}),
|
|
19
|
+
})
|
|
20
|
+
.describe('A carousel message containing a list of elements');
|
|
21
|
+
//# sourceMappingURL=carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAkBV,QAAA,cAAc,GAAG,OAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,MAAM,CAAC;YACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;YACpB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;gBAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;aAChB,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { BaseMessage } from './shared';
|
|
3
|
+
export interface ExitMessage extends BaseMessage {
|
|
4
|
+
type: 'exit';
|
|
5
|
+
}
|
|
6
|
+
export declare const ExitSchema: z.ZodObject<{
|
|
7
|
+
type: z.ZodEnum<["exit"]>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
type: "exit";
|
|
10
|
+
}, {
|
|
11
|
+
type: "exit";
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExitSchema = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const zod_1 = tslib_1.__importDefault(require("zod"));
|
|
6
|
+
exports.ExitSchema = zod_1.default
|
|
7
|
+
.object({
|
|
8
|
+
type: zod_1.default.enum(['exit']),
|
|
9
|
+
})
|
|
10
|
+
.describe('An exit message. This message should only be used to exit the agent due to out of context or the user asking to exit the conversation');
|
|
11
|
+
//# sourceMappingURL=exit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../../../src/structured-output/exit.ts"],"names":[],"mappings":";;;;AAAA,sDAAmB;AAQN,QAAA,UAAU,GAAG,aAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;CACvB,CAAC;KACD,QAAQ,CACP,uIAAuI,CACxI,CAAA"}
|