@botonic/plugin-ai-agents 0.36.0-alpha.6 → 0.36.0-alpha.7
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/lib/cjs/constants.d.ts +1 -0
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/hubtype-api-client.d.ts +2 -0
- package/lib/cjs/hubtype-api-client.js +41 -2
- package/lib/cjs/hubtype-api-client.js.map +1 -1
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +22 -25
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/runner.d.ts +9 -0
- package/lib/cjs/runner.js +58 -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/types.d.ts +6 -25
- package/lib/esm/constants.d.ts +1 -0
- package/lib/esm/constants.js +1 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/hubtype-api-client.d.ts +2 -0
- package/lib/esm/hubtype-api-client.js +41 -2
- package/lib/esm/hubtype-api-client.js.map +1 -1
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +20 -23
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/runner.d.ts +9 -0
- package/lib/esm/runner.js +54 -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/types.d.ts +6 -25
- package/package.json +3 -4
- package/src/constants.ts +2 -0
- package/src/hubtype-api-client.ts +55 -9
- package/src/index.ts +25 -32
- package/src/runner.ts +74 -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/types.ts +7 -34
- package/lib/cjs/ai-agent-client.d.ts +0 -9
- package/lib/cjs/ai-agent-client.js +0 -49
- 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/tools/custom.d.ts +0 -3
- package/lib/cjs/tools/custom.js +0 -14
- package/lib/cjs/tools/custom.js.map +0 -1
- package/lib/cjs/tools/default.d.ts +0 -6
- package/lib/cjs/tools/default.js +0 -41
- package/lib/cjs/tools/default.js.map +0 -1
- package/lib/cjs/utils.d.ts +0 -5
- package/lib/cjs/utils.js +0 -26
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/ai-agent-client.d.ts +0 -9
- package/lib/esm/ai-agent-client.js +0 -45
- 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/tools/custom.d.ts +0 -3
- package/lib/esm/tools/custom.js +0 -10
- package/lib/esm/tools/custom.js.map +0 -1
- package/lib/esm/tools/default.d.ts +0 -6
- package/lib/esm/tools/default.js +0 -38
- package/lib/esm/tools/default.js.map +0 -1
- package/lib/esm/utils.d.ts +0 -5
- package/lib/esm/utils.js +0 -22
- package/lib/esm/utils.js.map +0 -1
- package/src/ai-agent-client.ts +0 -69
- package/src/errors.ts +0 -6
- package/src/tools/custom.ts +0 -14
- package/src/tools/default.ts +0 -52
- package/src/utils.ts +0 -28
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const AZURE_OPENAI_API_KEY: string | undefined;
|
|
|
3
3
|
export declare const AZURE_OPENAI_API_BASE: string | undefined;
|
|
4
4
|
export declare const AZURE_OPENAI_API_DEPLOYMENT_NAME: string;
|
|
5
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.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;
|
|
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
5
|
exports.AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY; // pragma: allowlist secret
|
|
6
6
|
exports.AZURE_OPENAI_API_BASE = process.env.AZURE_OPENAI_API_BASE;
|
|
7
7
|
exports.AZURE_OPENAI_API_DEPLOYMENT_NAME = process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || 'gpt-4o-mini_p1';
|
|
8
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,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"}
|
|
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"}
|
|
@@ -3,5 +3,7 @@ import { AgenticInputMessage } from './types';
|
|
|
3
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
|
}
|
|
@@ -8,6 +8,21 @@ class HubtypeApiClient {
|
|
|
8
8
|
constructor(authToken) {
|
|
9
9
|
this.authToken = authToken;
|
|
10
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
|
+
}
|
|
11
26
|
getMessages(request, memoryLength) {
|
|
12
27
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
28
|
const url = `${constants_1.HUBTYPE_API_URL}/external/v1/ai/agent/message_history/`;
|
|
@@ -20,11 +35,12 @@ class HubtypeApiClient {
|
|
|
20
35
|
num_messages: memoryLength,
|
|
21
36
|
};
|
|
22
37
|
try {
|
|
23
|
-
const
|
|
38
|
+
const response = yield axios_1.default.get(url, {
|
|
24
39
|
headers,
|
|
25
40
|
params,
|
|
26
41
|
});
|
|
27
|
-
|
|
42
|
+
const messages = response.data.messages;
|
|
43
|
+
return messages.map(message => this.formatMessage(message));
|
|
28
44
|
}
|
|
29
45
|
catch (error) {
|
|
30
46
|
console.error(error);
|
|
@@ -32,6 +48,29 @@ class HubtypeApiClient {
|
|
|
32
48
|
}
|
|
33
49
|
});
|
|
34
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
|
+
}
|
|
35
74
|
}
|
|
36
75
|
exports.HubtypeApiClient = HubtypeApiClient;
|
|
37
76
|
//# sourceMappingURL=hubtype-api-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hubtype-api-client.js","sourceRoot":"","sources":["../../src/hubtype-api-client.ts"],"names":[],"mappings":";;;;
|
|
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
|
@@ -5,8 +5,8 @@ export default class BotonicPluginAiAgents implements Plugin {
|
|
|
5
5
|
customTools: CustomTool[];
|
|
6
6
|
constructor(options?: PluginAiAgentOptions);
|
|
7
7
|
pre(): void;
|
|
8
|
-
getInference(request: BotContext, aiAgentArgs: AiAgentArgs): Promise<AgenticOutputMessage | undefined>;
|
|
8
|
+
getInference(request: BotContext, aiAgentArgs: AiAgentArgs): Promise<AgenticOutputMessage[] | undefined>;
|
|
9
9
|
private getMessages;
|
|
10
|
-
private
|
|
10
|
+
private createTools;
|
|
11
11
|
}
|
|
12
12
|
export * from './types';
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const agents_1 = require("@openai/agents");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
5
6
|
const hubtype_api_client_1 = require("./hubtype-api-client");
|
|
6
|
-
const
|
|
7
|
-
const default_1 = require("./tools/default");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
7
|
+
const runner_1 = require("./runner");
|
|
10
8
|
class BotonicPluginAiAgents {
|
|
11
9
|
constructor(options) {
|
|
12
10
|
this.customTools = [];
|
|
@@ -19,17 +17,17 @@ class BotonicPluginAiAgents {
|
|
|
19
17
|
getInference(request, aiAgentArgs) {
|
|
20
18
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
19
|
try {
|
|
22
|
-
const authToken = isProd ? request.session._access_token : this.authToken;
|
|
20
|
+
const authToken = constants_1.isProd ? request.session._access_token : this.authToken;
|
|
23
21
|
if (!authToken) {
|
|
24
22
|
throw new Error('Auth token is required');
|
|
25
23
|
}
|
|
26
24
|
const messages = yield this.getMessages(request, authToken, 10);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
return
|
|
25
|
+
const availableTools = this.customTools.filter(tool => { var _a; return (_a = aiAgentArgs.activeTools) === null || _a === void 0 ? void 0 : _a.map(tool => tool.name).includes(tool.name); });
|
|
26
|
+
const tools = this.createTools(availableTools);
|
|
27
|
+
const runner = new runner_1.AIAgentRunner(aiAgentArgs.name, aiAgentArgs.instructions, tools);
|
|
28
|
+
const output = yield runner.run(messages);
|
|
29
|
+
console.log('\n\nOutput:', output);
|
|
30
|
+
return output;
|
|
33
31
|
}
|
|
34
32
|
catch (error) {
|
|
35
33
|
console.error('error plugin returns undefined', error);
|
|
@@ -39,24 +37,23 @@ class BotonicPluginAiAgents {
|
|
|
39
37
|
}
|
|
40
38
|
getMessages(request, authToken, memoryLength) {
|
|
41
39
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
if (isProd) {
|
|
40
|
+
if (constants_1.isProd) {
|
|
43
41
|
const hubtypeClient = new hubtype_api_client_1.HubtypeApiClient(authToken);
|
|
44
42
|
return yield hubtypeClient.getMessages(request, memoryLength);
|
|
45
43
|
}
|
|
46
|
-
|
|
44
|
+
const hubtypeClient = new hubtype_api_client_1.HubtypeApiClient(authToken);
|
|
45
|
+
return yield hubtypeClient.getLocalMessages(memoryLength);
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}));
|
|
59
|
-
return filteredMessages.slice(-memoryLength);
|
|
48
|
+
createTools(customTools) {
|
|
49
|
+
return customTools.map(customTool => {
|
|
50
|
+
return (0, agents_1.tool)({
|
|
51
|
+
name: customTool.name,
|
|
52
|
+
description: customTool.description,
|
|
53
|
+
parameters: customTool.schema,
|
|
54
|
+
execute: customTool.func,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
exports.default = BotonicPluginAiAgents;
|
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,2CAAoC;AACpC,6DAAuD;AACvD,qCAAwC;AASxC,MAAqB,qBAAqB;IAIxC,YAAY,OAA8B;QAFnC,gBAAW,GAAiB,EAAE,CAAA;QAGnC,IAAI,CAAC,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA;QACnC,IAAI,CAAC,WAAW,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,EAAE,CAAA;IAC/C,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,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA;gBAC/D,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WACpD,OAAA,MAAA,WAAW,CAAC,WAAW,0CAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CACpE,CAAA;gBACD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAA;gBAE9C,MAAM,MAAM,GAAG,IAAI,sBAAa,CAC9B,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,YAAY,EACxB,KAAK,CACN,CAAA;gBACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;gBACzC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;gBAElC,OAAO,MAAM,CAAA;aACd;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAA;gBACtD,OAAO,SAAS,CAAA;aACjB;QACH,CAAC;KAAA;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,WAAW,CAAC,WAAyB;QAC3C,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAClC,OAAO,IAAA,aAAI,EAAC;gBACV,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,WAAW,EAAE,UAAU,CAAC,WAAW;gBACnC,UAAU,EAAE,UAAU,CAAC,MAAM;gBAC7B,OAAO,EAAE,UAAU,CAAC,IAAI;aACzB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAnED,wCAmEC;AAED,kDAAuB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tool } from '@openai/agents';
|
|
2
|
+
import { OutputMessage } from './structured-output';
|
|
3
|
+
import { AgenticInputMessage } from './types';
|
|
4
|
+
export declare class AIAgentRunner {
|
|
5
|
+
private agent;
|
|
6
|
+
constructor(name: string, instructions: string, tools: Tool[]);
|
|
7
|
+
run(messages: AgenticInputMessage[]): Promise<OutputMessage[]>;
|
|
8
|
+
private addExtraInstructions;
|
|
9
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
const openai_1 = require("openai");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const structured_output_1 = require("./structured-output");
|
|
9
|
+
class AIAgentRunner {
|
|
10
|
+
constructor(name, instructions, tools) {
|
|
11
|
+
if (constants_1.AZURE_OPENAI_API_KEY) {
|
|
12
|
+
const client = new openai_1.AzureOpenAI({
|
|
13
|
+
apiKey: constants_1.AZURE_OPENAI_API_KEY,
|
|
14
|
+
apiVersion: constants_1.AZURE_OPENAI_API_VERSION,
|
|
15
|
+
deployment: constants_1.AZURE_OPENAI_API_DEPLOYMENT_NAME,
|
|
16
|
+
baseURL: constants_1.AZURE_OPENAI_API_BASE,
|
|
17
|
+
dangerouslyAllowBrowser: !constants_1.isProd,
|
|
18
|
+
});
|
|
19
|
+
(0, agents_1.setDefaultOpenAIClient)(client);
|
|
20
|
+
(0, agents_1.setOpenAIAPI)('chat_completions');
|
|
21
|
+
(0, agents_1.setTracingDisabled)(true);
|
|
22
|
+
}
|
|
23
|
+
this.agent = new agents_1.Agent({
|
|
24
|
+
name: name,
|
|
25
|
+
instructions: this.addExtraInstructions(instructions),
|
|
26
|
+
tools: tools,
|
|
27
|
+
outputType: structured_output_1.OutputSchema,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
run(messages) {
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const runner = new agents_1.Runner({
|
|
33
|
+
modelSettings: { temperature: 0 },
|
|
34
|
+
});
|
|
35
|
+
const result = yield runner.run(this.agent, messages);
|
|
36
|
+
const finalOutput = result.finalOutput;
|
|
37
|
+
return (finalOutput === null || finalOutput === void 0 ? void 0 : finalOutput.messages) || [];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
addExtraInstructions(instructions) {
|
|
41
|
+
const metadata = `Current Date: ${new Date().toISOString()}`;
|
|
42
|
+
const outputExample = JSON.stringify({
|
|
43
|
+
messages: [
|
|
44
|
+
{
|
|
45
|
+
type: 'text',
|
|
46
|
+
content: {
|
|
47
|
+
text: 'Hello, how can I help you today?',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
numMessages: 1,
|
|
52
|
+
});
|
|
53
|
+
const output = `Return a JSON that follows the output schema provided. Never return multiple output schemas concatenated by a line break.\n<example>\n${outputExample}\n</example>`;
|
|
54
|
+
return `<instructions>\n${instructions}\n</instructions>\n\n<metadata>\n${metadata}\n</metadata>\n\n<output>\n${output}\n</output>`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.AIAgentRunner = AIAgentRunner;
|
|
58
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";;;;AAAA,2CAOuB;AACvB,mCAAoC;AAEpC,2CAMoB;AACpB,2DAAiE;AAGjE,MAAa,aAAa;IAGxB,YAAY,IAAY,EAAE,YAAoB,EAAE,KAAa;QAC3D,IAAI,gCAAoB,EAAE;YACxB,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;gBAC7B,MAAM,EAAE,gCAAoB;gBAC5B,UAAU,EAAE,oCAAwB;gBACpC,UAAU,EAAE,4CAAgC;gBAC5C,OAAO,EAAE,iCAAqB;gBAC9B,uBAAuB,EAAE,CAAC,kBAAM;aACjC,CAAC,CAAA;YACF,IAAA,+BAAsB,EAAC,MAAa,CAAC,CAAA;YACrC,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAA;YAChC,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAA;SACzB;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,cAAK,CAAC;YACrB,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC;YACrD,KAAK,EAAE,KAAK;YACZ,UAAU,EAAE,gCAAY;SACzB,CAAC,CAAA;IACJ,CAAC;IAEK,GAAG,CAAC,QAA+B;;YACvC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;gBACxB,aAAa,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;aAClC,CAAC,CAAA;YACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACrD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;YAEtC,OAAO,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,KAAI,EAAE,CAAA;QACpC,CAAC;KAAA;IAEO,oBAAoB,CAAC,YAAoB;QAC/C,MAAM,QAAQ,GAAG,iBAAiB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAA;QAE5D,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC;YACnC,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,kCAAkC;qBACzC;iBACF;aACF;YACD,WAAW,EAAE,CAAC;SACf,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,yIAAyI,aAAa,cAAc,CAAA;QAEnL,OAAO,mBAAmB,YAAY,oCAAoC,QAAQ,8BAA8B,MAAM,aAAa,CAAA;IACrI,CAAC;CACF;AArDD,sCAqDC"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CarouselMessage } from './carousel';
|
|
3
|
+
import { ExitMessage } from './exit';
|
|
4
|
+
import { TextMessage } from './text';
|
|
5
|
+
import { TextWithButtonsMessage } from './text-with-buttons';
|
|
6
|
+
export type OutputMessage = TextMessage | TextWithButtonsMessage | CarouselMessage | ExitMessage;
|
|
7
|
+
export interface Output {
|
|
8
|
+
messages: OutputMessage[];
|
|
9
|
+
}
|
|
10
|
+
export declare const OutputSchema: z.ZodObject<{
|
|
11
|
+
messages: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
12
|
+
type: z.ZodEnum<["text"]>;
|
|
13
|
+
content: z.ZodObject<{
|
|
14
|
+
text: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
text: string;
|
|
17
|
+
}, {
|
|
18
|
+
text: string;
|
|
19
|
+
}>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
type: "text";
|
|
22
|
+
content: {
|
|
23
|
+
text: string;
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
type: "text";
|
|
27
|
+
content: {
|
|
28
|
+
text: string;
|
|
29
|
+
};
|
|
30
|
+
}>, z.ZodObject<{
|
|
31
|
+
type: z.ZodEnum<["textWithButtons"]>;
|
|
32
|
+
content: z.ZodObject<{
|
|
33
|
+
text: z.ZodString;
|
|
34
|
+
buttons: z.ZodArray<z.ZodString, "many">;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
text: string;
|
|
37
|
+
buttons: string[];
|
|
38
|
+
}, {
|
|
39
|
+
text: string;
|
|
40
|
+
buttons: string[];
|
|
41
|
+
}>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
type: "textWithButtons";
|
|
44
|
+
content: {
|
|
45
|
+
text: string;
|
|
46
|
+
buttons: string[];
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
type: "textWithButtons";
|
|
50
|
+
content: {
|
|
51
|
+
text: string;
|
|
52
|
+
buttons: string[];
|
|
53
|
+
};
|
|
54
|
+
}>, z.ZodObject<{
|
|
55
|
+
type: z.ZodEnum<["carousel"]>;
|
|
56
|
+
content: z.ZodObject<{
|
|
57
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
58
|
+
title: z.ZodString;
|
|
59
|
+
subtitle: z.ZodString;
|
|
60
|
+
image: z.ZodString;
|
|
61
|
+
button: z.ZodObject<{
|
|
62
|
+
text: z.ZodString;
|
|
63
|
+
url: z.ZodString;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
text: string;
|
|
66
|
+
url: string;
|
|
67
|
+
}, {
|
|
68
|
+
text: string;
|
|
69
|
+
url: string;
|
|
70
|
+
}>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
title: string;
|
|
73
|
+
subtitle: string;
|
|
74
|
+
image: string;
|
|
75
|
+
button: {
|
|
76
|
+
text: string;
|
|
77
|
+
url: string;
|
|
78
|
+
};
|
|
79
|
+
}, {
|
|
80
|
+
title: string;
|
|
81
|
+
subtitle: string;
|
|
82
|
+
image: string;
|
|
83
|
+
button: {
|
|
84
|
+
text: string;
|
|
85
|
+
url: string;
|
|
86
|
+
};
|
|
87
|
+
}>, "many">;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
elements: {
|
|
90
|
+
title: string;
|
|
91
|
+
subtitle: string;
|
|
92
|
+
image: string;
|
|
93
|
+
button: {
|
|
94
|
+
text: string;
|
|
95
|
+
url: string;
|
|
96
|
+
};
|
|
97
|
+
}[];
|
|
98
|
+
}, {
|
|
99
|
+
elements: {
|
|
100
|
+
title: string;
|
|
101
|
+
subtitle: string;
|
|
102
|
+
image: string;
|
|
103
|
+
button: {
|
|
104
|
+
text: string;
|
|
105
|
+
url: string;
|
|
106
|
+
};
|
|
107
|
+
}[];
|
|
108
|
+
}>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
type: "carousel";
|
|
111
|
+
content: {
|
|
112
|
+
elements: {
|
|
113
|
+
title: string;
|
|
114
|
+
subtitle: string;
|
|
115
|
+
image: string;
|
|
116
|
+
button: {
|
|
117
|
+
text: string;
|
|
118
|
+
url: string;
|
|
119
|
+
};
|
|
120
|
+
}[];
|
|
121
|
+
};
|
|
122
|
+
}, {
|
|
123
|
+
type: "carousel";
|
|
124
|
+
content: {
|
|
125
|
+
elements: {
|
|
126
|
+
title: string;
|
|
127
|
+
subtitle: string;
|
|
128
|
+
image: string;
|
|
129
|
+
button: {
|
|
130
|
+
text: string;
|
|
131
|
+
url: string;
|
|
132
|
+
};
|
|
133
|
+
}[];
|
|
134
|
+
};
|
|
135
|
+
}>, z.ZodObject<{
|
|
136
|
+
type: z.ZodEnum<["exit"]>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
type: "exit";
|
|
139
|
+
}, {
|
|
140
|
+
type: "exit";
|
|
141
|
+
}>]>, "many">;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
messages: ({
|
|
144
|
+
type: "carousel";
|
|
145
|
+
content: {
|
|
146
|
+
elements: {
|
|
147
|
+
title: string;
|
|
148
|
+
subtitle: string;
|
|
149
|
+
image: string;
|
|
150
|
+
button: {
|
|
151
|
+
text: string;
|
|
152
|
+
url: string;
|
|
153
|
+
};
|
|
154
|
+
}[];
|
|
155
|
+
};
|
|
156
|
+
} | {
|
|
157
|
+
type: "exit";
|
|
158
|
+
} | {
|
|
159
|
+
type: "text";
|
|
160
|
+
content: {
|
|
161
|
+
text: string;
|
|
162
|
+
};
|
|
163
|
+
} | {
|
|
164
|
+
type: "textWithButtons";
|
|
165
|
+
content: {
|
|
166
|
+
text: string;
|
|
167
|
+
buttons: string[];
|
|
168
|
+
};
|
|
169
|
+
})[];
|
|
170
|
+
}, {
|
|
171
|
+
messages: ({
|
|
172
|
+
type: "carousel";
|
|
173
|
+
content: {
|
|
174
|
+
elements: {
|
|
175
|
+
title: string;
|
|
176
|
+
subtitle: string;
|
|
177
|
+
image: string;
|
|
178
|
+
button: {
|
|
179
|
+
text: string;
|
|
180
|
+
url: string;
|
|
181
|
+
};
|
|
182
|
+
}[];
|
|
183
|
+
};
|
|
184
|
+
} | {
|
|
185
|
+
type: "exit";
|
|
186
|
+
} | {
|
|
187
|
+
type: "text";
|
|
188
|
+
content: {
|
|
189
|
+
text: string;
|
|
190
|
+
};
|
|
191
|
+
} | {
|
|
192
|
+
type: "textWithButtons";
|
|
193
|
+
content: {
|
|
194
|
+
text: string;
|
|
195
|
+
buttons: string[];
|
|
196
|
+
};
|
|
197
|
+
})[];
|
|
198
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutputSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const carousel_1 = require("./carousel");
|
|
6
|
+
const exit_1 = require("./exit");
|
|
7
|
+
const text_1 = require("./text");
|
|
8
|
+
const text_with_buttons_1 = require("./text-with-buttons");
|
|
9
|
+
exports.OutputSchema = zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
messages: zod_1.z.array(zod_1.z.union([text_1.TextSchema, text_with_buttons_1.TextWithButtonsSchema, carousel_1.CarouselSchema, exit_1.ExitSchema])),
|
|
12
|
+
})
|
|
13
|
+
.describe('The messages to be sent to the user');
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structured-output/index.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEvB,yCAA4D;AAC5D,iCAAgD;AAChD,iCAAgD;AAChD,2DAG4B;AAYf,QAAA,YAAY,GAAG,OAAC;KAC1B,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,KAAK,CAAC,CAAC,iBAAU,EAAE,yCAAqB,EAAE,yBAAc,EAAE,iBAAU,CAAC,CAAC,CACzE;CACF,CAAC;KACD,QAAQ,CAAC,qCAAqC,CAAC,CAAA"}
|