@botonic/plugin-ai-agents 0.36.0-alpha.6 → 0.36.0-alpha.8
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 +10 -0
- package/lib/cjs/runner.js +75 -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 +10 -0
- package/lib/esm/runner.js +71 -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 +97 -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
|
@@ -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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/structured-output/shared.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { BaseMessage } from './shared';
|
|
3
|
+
export interface TextWithButtonsMessage extends BaseMessage {
|
|
4
|
+
type: 'textWithButtons';
|
|
5
|
+
content: {
|
|
6
|
+
text: string;
|
|
7
|
+
buttons: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const TextWithButtonsSchema: z.ZodObject<{
|
|
11
|
+
type: z.ZodEnum<["textWithButtons"]>;
|
|
12
|
+
content: z.ZodObject<{
|
|
13
|
+
text: z.ZodString;
|
|
14
|
+
buttons: z.ZodArray<z.ZodString, "many">;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
text: string;
|
|
17
|
+
buttons: string[];
|
|
18
|
+
}, {
|
|
19
|
+
text: string;
|
|
20
|
+
buttons: string[];
|
|
21
|
+
}>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
type: "textWithButtons";
|
|
24
|
+
content: {
|
|
25
|
+
text: string;
|
|
26
|
+
buttons: string[];
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
type: "textWithButtons";
|
|
30
|
+
content: {
|
|
31
|
+
text: string;
|
|
32
|
+
buttons: string[];
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextWithButtonsSchema = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const zod_1 = tslib_1.__importDefault(require("zod"));
|
|
6
|
+
exports.TextWithButtonsSchema = zod_1.default
|
|
7
|
+
.object({
|
|
8
|
+
type: zod_1.default.enum(['textWithButtons']),
|
|
9
|
+
content: zod_1.default.object({
|
|
10
|
+
text: zod_1.default.string(),
|
|
11
|
+
buttons: zod_1.default.array(zod_1.default.string()),
|
|
12
|
+
}),
|
|
13
|
+
})
|
|
14
|
+
.describe('A text message with buttons to allow the user to use quick replies');
|
|
15
|
+
//# sourceMappingURL=text-with-buttons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-with-buttons.js","sourceRoot":"","sources":["../../../src/structured-output/text-with-buttons.ts"],"names":[],"mappings":";;;;AAAA,sDAAmB;AAYN,QAAA,qBAAqB,GAAG,aAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACjC,OAAO,EAAE,aAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,aAAC,CAAC,KAAK,CAAC,aAAC,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC;KACD,QAAQ,CACP,oEAAoE,CACrE,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseMessage } from './shared';
|
|
3
|
+
export interface TextMessage extends BaseMessage {
|
|
4
|
+
type: 'text';
|
|
5
|
+
content: {
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const TextSchema: z.ZodObject<{
|
|
10
|
+
type: z.ZodEnum<["text"]>;
|
|
11
|
+
content: z.ZodObject<{
|
|
12
|
+
text: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
text: string;
|
|
15
|
+
}, {
|
|
16
|
+
text: string;
|
|
17
|
+
}>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
type: "text";
|
|
20
|
+
content: {
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
type: "text";
|
|
25
|
+
content: {
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.TextSchema = zod_1.z
|
|
6
|
+
.object({
|
|
7
|
+
type: zod_1.z.enum(['text']),
|
|
8
|
+
content: zod_1.z.object({
|
|
9
|
+
text: zod_1.z.string(),
|
|
10
|
+
}),
|
|
11
|
+
})
|
|
12
|
+
.describe('A text message');
|
|
13
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/structured-output/text.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAWV,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;KACjB,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,gBAAgB,CAAC,CAAA"}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentInputItem } from '@openai/agents';
|
|
2
|
+
import { ZodObject } from 'zod';
|
|
3
|
+
import { OutputMessage } from './structured-output';
|
|
2
4
|
export interface PluginAiAgentOptions {
|
|
3
5
|
authToken?: string;
|
|
4
6
|
customTools?: CustomTool[];
|
|
@@ -6,8 +8,7 @@ export interface PluginAiAgentOptions {
|
|
|
6
8
|
export interface CustomTool {
|
|
7
9
|
name: string;
|
|
8
10
|
description: string;
|
|
9
|
-
schema:
|
|
10
|
-
returnDirect?: boolean;
|
|
11
|
+
schema: ZodObject<any>;
|
|
11
12
|
func: (input?: any) => Promise<any>;
|
|
12
13
|
}
|
|
13
14
|
export interface AiAgentArgs {
|
|
@@ -17,25 +18,5 @@ export interface AiAgentArgs {
|
|
|
17
18
|
name: string;
|
|
18
19
|
}[];
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
export interface AssistantMessage extends AgenticBaseMessage {
|
|
24
|
-
role: 'assistant';
|
|
25
|
-
content: string;
|
|
26
|
-
}
|
|
27
|
-
export interface UserMessage extends AgenticBaseMessage {
|
|
28
|
-
role: 'user';
|
|
29
|
-
content: string;
|
|
30
|
-
}
|
|
31
|
-
export interface ToolMessage extends AgenticBaseMessage {
|
|
32
|
-
role: 'tool';
|
|
33
|
-
toolName: string;
|
|
34
|
-
toolOutput: string | null;
|
|
35
|
-
}
|
|
36
|
-
export interface ExitMessage extends AgenticBaseMessage {
|
|
37
|
-
role: 'exit';
|
|
38
|
-
}
|
|
39
|
-
export type AgenticInputMessage = AssistantMessage | UserMessage;
|
|
40
|
-
export type AgenticOutputMessage = AssistantMessage | ToolMessage | ExitMessage;
|
|
41
|
-
export type AgenticMessage = AssistantMessage | UserMessage | ToolMessage | ExitMessage;
|
|
21
|
+
export type AgenticInputMessage = AgentInputItem;
|
|
22
|
+
export type AgenticOutputMessage = OutputMessage;
|
package/lib/esm/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/esm/constants.js
CHANGED
|
@@ -3,4 +3,5 @@ export const AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY; // pragma:
|
|
|
3
3
|
export const AZURE_OPENAI_API_BASE = process.env.AZURE_OPENAI_API_BASE;
|
|
4
4
|
export const AZURE_OPENAI_API_DEPLOYMENT_NAME = process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || 'gpt-4o-mini_p1';
|
|
5
5
|
export const AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION || '2024-12-01-preview';
|
|
6
|
+
export const isProd = process.env.NODE_ENV === 'production';
|
|
6
7
|
//# sourceMappingURL=constants.js.map
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA,CAAC,2BAA2B;AAChG,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;AACtE,MAAM,CAAC,MAAM,gCAAgC,GAC3C,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,gBAAgB,CAAA;AAClE,MAAM,CAAC,MAAM,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA,CAAC,2BAA2B;AAChG,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;AACtE,MAAM,CAAC,MAAM,gCAAgC,GAC3C,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,gBAAgB,CAAA;AAClE,MAAM,CAAC,MAAM,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,oBAAoB,CAAA;AAE9D,MAAM,CAAC,MAAM,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
|
}
|
|
@@ -5,6 +5,21 @@ export class HubtypeApiClient {
|
|
|
5
5
|
constructor(authToken) {
|
|
6
6
|
this.authToken = authToken;
|
|
7
7
|
}
|
|
8
|
+
getLocalMessages(memoryLength) {
|
|
9
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const localBotonicState = localStorage.getItem('botonicState');
|
|
11
|
+
const botonicState = JSON.parse(localBotonicState || '{}');
|
|
12
|
+
const messages = botonicState.messages;
|
|
13
|
+
const filteredMessages = messages
|
|
14
|
+
.filter(message => message.data.text)
|
|
15
|
+
.map(message => ({
|
|
16
|
+
role: message.sentBy === 'user' ? 'user' : 'assistant',
|
|
17
|
+
content: message.data.text,
|
|
18
|
+
}))
|
|
19
|
+
.map(message => this.formatMessage(message));
|
|
20
|
+
return filteredMessages.slice(-memoryLength);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
8
23
|
getMessages(request, memoryLength) {
|
|
9
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10
25
|
const url = `${HUBTYPE_API_URL}/external/v1/ai/agent/message_history/`;
|
|
@@ -17,11 +32,12 @@ export class HubtypeApiClient {
|
|
|
17
32
|
num_messages: memoryLength,
|
|
18
33
|
};
|
|
19
34
|
try {
|
|
20
|
-
const
|
|
35
|
+
const response = yield axios.get(url, {
|
|
21
36
|
headers,
|
|
22
37
|
params,
|
|
23
38
|
});
|
|
24
|
-
|
|
39
|
+
const messages = response.data.messages;
|
|
40
|
+
return messages.map(message => this.formatMessage(message));
|
|
25
41
|
}
|
|
26
42
|
catch (error) {
|
|
27
43
|
console.error(error);
|
|
@@ -29,5 +45,28 @@ export class HubtypeApiClient {
|
|
|
29
45
|
}
|
|
30
46
|
});
|
|
31
47
|
}
|
|
48
|
+
formatMessage(message) {
|
|
49
|
+
if (message.role === 'user') {
|
|
50
|
+
return {
|
|
51
|
+
content: message.content,
|
|
52
|
+
role: 'user',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else if (message.role === 'assistant') {
|
|
56
|
+
return {
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
type: 'output_text',
|
|
61
|
+
text: message.content,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
status: 'completed',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new Error('Invalid message role');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
32
71
|
}
|
|
33
72
|
//# 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,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAe7C,MAAM,OAAO,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,eAAe,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,KAAK,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"}
|
package/lib/esm/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/esm/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { tool } from '@openai/agents';
|
|
3
|
+
import { isProd } from './constants';
|
|
3
4
|
import { HubtypeApiClient } from './hubtype-api-client';
|
|
4
|
-
import {
|
|
5
|
-
import { MANDATORY_TOOLS } from './tools/default';
|
|
6
|
-
import { AiProvider, loadChatModel } from './utils';
|
|
7
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
5
|
+
import { AIAgentRunner } from './runner';
|
|
8
6
|
export default class BotonicPluginAiAgents {
|
|
9
7
|
constructor(options) {
|
|
10
8
|
this.customTools = [];
|
|
@@ -22,12 +20,12 @@ export default class BotonicPluginAiAgents {
|
|
|
22
20
|
throw new Error('Auth token is required');
|
|
23
21
|
}
|
|
24
22
|
const messages = yield this.getMessages(request, authToken, 10);
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
return
|
|
23
|
+
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); });
|
|
24
|
+
const tools = this.createTools(availableTools);
|
|
25
|
+
const runner = new AIAgentRunner(aiAgentArgs.name, aiAgentArgs.instructions, tools);
|
|
26
|
+
const output = yield runner.run(messages);
|
|
27
|
+
console.log('\n\nOutput:', output);
|
|
28
|
+
return output;
|
|
31
29
|
}
|
|
32
30
|
catch (error) {
|
|
33
31
|
console.error('error plugin returns undefined', error);
|
|
@@ -41,20 +39,19 @@ export default class BotonicPluginAiAgents {
|
|
|
41
39
|
const hubtypeClient = new HubtypeApiClient(authToken);
|
|
42
40
|
return yield hubtypeClient.getMessages(request, memoryLength);
|
|
43
41
|
}
|
|
44
|
-
|
|
42
|
+
const hubtypeClient = new HubtypeApiClient(authToken);
|
|
43
|
+
return yield hubtypeClient.getLocalMessages(memoryLength);
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}));
|
|
57
|
-
return filteredMessages.slice(-memoryLength);
|
|
46
|
+
createTools(customTools) {
|
|
47
|
+
return customTools.map(customTool => {
|
|
48
|
+
return tool({
|
|
49
|
+
name: customTool.name,
|
|
50
|
+
description: customTool.description,
|
|
51
|
+
parameters: customTool.schema,
|
|
52
|
+
execute: customTool.func,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
export * from './types';
|
package/lib/esm/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,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AASxC,MAAM,CAAC,OAAO,OAAO,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,MAAM,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,aAAa,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,MAAM,EAAE;gBACV,MAAM,aAAa,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAA;gBACrD,OAAO,MAAM,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;aAC9D;YACD,MAAM,aAAa,GAAG,IAAI,gBAAgB,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,IAAI,CAAC;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;AAED,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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[], maxRetries?: number): Promise<OutputMessage[]>;
|
|
8
|
+
private runWithRetry;
|
|
9
|
+
private addExtraInstructions;
|
|
10
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Agent, ModelBehaviorError, Runner, setDefaultOpenAIClient, setOpenAIAPI, setTracingDisabled, } from '@openai/agents';
|
|
3
|
+
import { AzureOpenAI } from 'openai';
|
|
4
|
+
import { AZURE_OPENAI_API_BASE, AZURE_OPENAI_API_DEPLOYMENT_NAME, AZURE_OPENAI_API_KEY, AZURE_OPENAI_API_VERSION, isProd, } from './constants';
|
|
5
|
+
import { OutputSchema } from './structured-output';
|
|
6
|
+
export class AIAgentRunner {
|
|
7
|
+
constructor(name, instructions, tools) {
|
|
8
|
+
if (AZURE_OPENAI_API_KEY) {
|
|
9
|
+
const client = new AzureOpenAI({
|
|
10
|
+
apiKey: AZURE_OPENAI_API_KEY,
|
|
11
|
+
apiVersion: AZURE_OPENAI_API_VERSION,
|
|
12
|
+
deployment: AZURE_OPENAI_API_DEPLOYMENT_NAME,
|
|
13
|
+
baseURL: AZURE_OPENAI_API_BASE,
|
|
14
|
+
dangerouslyAllowBrowser: !isProd,
|
|
15
|
+
});
|
|
16
|
+
setDefaultOpenAIClient(client);
|
|
17
|
+
setOpenAIAPI('chat_completions');
|
|
18
|
+
setTracingDisabled(true);
|
|
19
|
+
}
|
|
20
|
+
this.agent = new Agent({
|
|
21
|
+
name: name,
|
|
22
|
+
instructions: this.addExtraInstructions(instructions),
|
|
23
|
+
tools: tools,
|
|
24
|
+
outputType: OutputSchema,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
run(messages, maxRetries = 1) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return this.runWithRetry(messages, maxRetries, 1);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
runWithRetry(messages, maxRetries, attempt) {
|
|
33
|
+
var _a;
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
try {
|
|
36
|
+
const runner = new Runner({
|
|
37
|
+
modelSettings: { temperature: 0 },
|
|
38
|
+
});
|
|
39
|
+
const result = yield runner.run(this.agent, messages);
|
|
40
|
+
return ((_a = result.finalOutput) === null || _a === void 0 ? void 0 : _a.messages) || [];
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (!(error instanceof ModelBehaviorError)) {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
if (attempt > maxRetries) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
console.warn(`AI Agent execution failed due to ModelBehaviorError. Retrying... (Attempt ${attempt}/${maxRetries})`);
|
|
50
|
+
return this.runWithRetry(messages, maxRetries, attempt + 1);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
addExtraInstructions(instructions) {
|
|
55
|
+
const metadata = `Current Date: ${new Date().toISOString()}`;
|
|
56
|
+
const outputExample = JSON.stringify({
|
|
57
|
+
messages: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
content: {
|
|
61
|
+
text: 'Hello, how can I help you today?',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
numMessages: 1,
|
|
66
|
+
});
|
|
67
|
+
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>`;
|
|
68
|
+
return `<instructions>\n${instructions}\n</instructions>\n\n<metadata>\n${metadata}\n</metadata>\n\n<output>\n${output}\n</output>`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,MAAM,EACN,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,GAEnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EAChC,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,GACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGjE,MAAM,OAAO,aAAa;IAGxB,YAAY,IAAY,EAAE,YAAoB,EAAE,KAAa;QAC3D,IAAI,oBAAoB,EAAE;YACxB,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC;gBAC7B,MAAM,EAAE,oBAAoB;gBAC5B,UAAU,EAAE,wBAAwB;gBACpC,UAAU,EAAE,gCAAgC;gBAC5C,OAAO,EAAE,qBAAqB;gBAC9B,uBAAuB,EAAE,CAAC,MAAM;aACjC,CAAC,CAAA;YACF,sBAAsB,CAAC,MAAa,CAAC,CAAA;YACrC,YAAY,CAAC,kBAAkB,CAAC,CAAA;YAChC,kBAAkB,CAAC,IAAI,CAAC,CAAA;SACzB;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC;YACrB,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC;YACrD,KAAK,EAAE,KAAK;YACZ,UAAU,EAAE,YAAY;SACzB,CAAC,CAAA;IACJ,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,aAAqB,CAAC;;YAEtB,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QACnD,CAAC;KAAA;IAEa,YAAY,CACxB,QAA+B,EAC/B,UAAkB,EAClB,OAAe;;;YAEf,IAAI;gBACF,MAAM,MAAM,GAAG,IAAI,MAAM,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,CAAC,CAAA;gBACrD,OAAO,CAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,QAAQ,KAAI,EAAE,CAAA;aAC1C;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,CAAC,CAAC,KAAK,YAAY,kBAAkB,CAAC,EAAE;oBAC1C,MAAM,KAAK,CAAA;iBACZ;gBACD,IAAI,OAAO,GAAG,UAAU,EAAE;oBACxB,MAAM,KAAK,CAAA;iBACZ;gBACD,OAAO,CAAC,IAAI,CACV,6EAA6E,OAAO,IAAI,UAAU,GAAG,CACtG,CAAA;gBACD,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,GAAG,CAAC,CAAC,CAAA;aAC5D;;KACF;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"}
|
|
@@ -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,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CarouselSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
type: z.enum(['carousel']),
|
|
5
|
+
content: z.object({
|
|
6
|
+
elements: z.array(z.object({
|
|
7
|
+
title: z.string(),
|
|
8
|
+
subtitle: z.string(),
|
|
9
|
+
image: z.string(),
|
|
10
|
+
button: z.object({
|
|
11
|
+
text: z.string(),
|
|
12
|
+
url: z.string(),
|
|
13
|
+
}),
|
|
14
|
+
})),
|
|
15
|
+
}),
|
|
16
|
+
})
|
|
17
|
+
.describe('A carousel message containing a list of elements');
|
|
18
|
+
//# sourceMappingURL=carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAkBvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,CAAC,CAAC,MAAM,CAAC;YACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;YACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;YACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;gBAChB,GAAG,EAAE,CAAC,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,7 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export const ExitSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
type: z.enum(['exit']),
|
|
5
|
+
})
|
|
6
|
+
.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');
|
|
7
|
+
//# sourceMappingURL=exit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../../../src/structured-output/exit.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAQnB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;CACvB,CAAC;KACD,QAAQ,CACP,uIAAuI,CACxI,CAAA"}
|