@botonic/plugin-ai-agents 0.46.0 → 2.23.0
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/CHANGELOG.md +209 -0
- package/package.json +23 -41
- package/src/index.d.ts +2 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -0
- package/{lib/cjs → src/lib}/agent-builder.d.ts +5 -10
- package/{lib/cjs → src/lib}/agent-builder.js +31 -25
- package/src/lib/agent-builder.js.map +1 -0
- package/{lib/cjs → src/lib}/constants.d.ts +1 -3
- package/src/lib/constants.js +13 -0
- package/src/lib/constants.js.map +1 -0
- package/{lib/esm → src/lib}/debug-logger.d.ts +3 -5
- package/{lib/esm → src/lib}/debug-logger.js +44 -29
- package/src/lib/debug-logger.js.map +1 -0
- package/src/lib/guardrails/index.js +2 -0
- package/src/lib/guardrails/index.js.map +1 -0
- package/src/lib/guardrails/input.d.ts +3 -0
- package/src/lib/guardrails/input.js +29 -0
- package/src/lib/guardrails/input.js.map +1 -0
- package/{lib/cjs/services → src/lib}/hubtype-api-client.d.ts +13 -5
- package/src/lib/hubtype-api-client.js +206 -0
- package/src/lib/hubtype-api-client.js.map +1 -0
- package/{lib/cjs → src/lib}/index.d.ts +2 -7
- package/src/lib/index.js +111 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/openai.d.ts +1 -0
- package/src/lib/openai.js +21 -0
- package/src/lib/openai.js.map +1 -0
- package/src/lib/runner.d.ts +12 -0
- package/src/lib/runner.js +96 -0
- package/src/lib/runner.js.map +1 -0
- package/{lib/esm → src/lib}/structured-output/carousel.d.ts +1 -1
- package/src/lib/structured-output/carousel.js +19 -0
- package/src/lib/structured-output/carousel.js.map +1 -0
- package/{lib/cjs → src/lib}/structured-output/exit.d.ts +1 -1
- package/src/lib/structured-output/exit.js +7 -0
- package/src/lib/structured-output/exit.js.map +1 -0
- package/{lib/cjs → src/lib}/structured-output/index.d.ts +10 -73
- package/src/lib/structured-output/index.js +11 -0
- package/src/lib/structured-output/index.js.map +1 -0
- package/{lib/esm → src/lib}/structured-output/text-with-buttons.d.ts +8 -8
- package/src/lib/structured-output/text-with-buttons.js +14 -0
- package/src/lib/structured-output/text-with-buttons.js.map +1 -0
- package/{lib/esm → src/lib}/structured-output/text.d.ts +1 -1
- package/src/lib/structured-output/text.js +10 -0
- package/src/lib/structured-output/text.js.map +1 -0
- package/{lib/esm → src/lib}/tools/index.d.ts +1 -1
- package/src/lib/tools/index.js +3 -0
- package/src/lib/tools/index.js.map +1 -0
- package/{lib/cjs → src/lib}/tools/retrieve-knowledge.d.ts +2 -2
- package/src/lib/tools/retrieve-knowledge.js +30 -0
- package/src/lib/tools/retrieve-knowledge.js.map +1 -0
- package/{lib/esm → src/lib}/types.d.ts +11 -21
- package/src/lib/types.js +2 -0
- package/src/lib/types.js.map +1 -0
- package/README.md +0 -156
- package/lib/cjs/agent-builder.js.map +0 -1
- package/lib/cjs/bot-config-tools.d.ts +0 -7
- package/lib/cjs/bot-config-tools.js +0 -19
- package/lib/cjs/bot-config-tools.js.map +0 -1
- package/lib/cjs/constants.js +0 -17
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/debug-logger.d.ts +0 -33
- package/lib/cjs/debug-logger.js +0 -97
- package/lib/cjs/debug-logger.js.map +0 -1
- package/lib/cjs/guardrails/index.js +0 -5
- package/lib/cjs/guardrails/index.js.map +0 -1
- package/lib/cjs/guardrails/input.d.ts +0 -10
- package/lib/cjs/guardrails/input.js +0 -77
- package/lib/cjs/guardrails/input.js.map +0 -1
- package/lib/cjs/index.js +0 -133
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/llm-config.d.ts +0 -15
- package/lib/cjs/llm-config.js +0 -66
- package/lib/cjs/llm-config.js.map +0 -1
- package/lib/cjs/runner.d.ts +0 -18
- package/lib/cjs/runner.js +0 -181
- package/lib/cjs/runner.js.map +0 -1
- package/lib/cjs/services/hubtype-api-client.js +0 -206
- package/lib/cjs/services/hubtype-api-client.js.map +0 -1
- package/lib/cjs/services/types.d.ts +0 -85
- package/lib/cjs/services/types.js +0 -13
- package/lib/cjs/services/types.js.map +0 -1
- package/lib/cjs/structured-output/bot-executor.d.ts +0 -49
- package/lib/cjs/structured-output/bot-executor.js +0 -18
- package/lib/cjs/structured-output/bot-executor.js.map +0 -1
- package/lib/cjs/structured-output/carousel.d.ts +0 -90
- package/lib/cjs/structured-output/carousel.js +0 -22
- package/lib/cjs/structured-output/carousel.js.map +0 -1
- package/lib/cjs/structured-output/exit.js +0 -11
- package/lib/cjs/structured-output/exit.js.map +0 -1
- package/lib/cjs/structured-output/index.js +0 -21
- package/lib/cjs/structured-output/index.js.map +0 -1
- package/lib/cjs/structured-output/text-with-buttons.d.ts +0 -49
- package/lib/cjs/structured-output/text-with-buttons.js +0 -18
- package/lib/cjs/structured-output/text-with-buttons.js.map +0 -1
- package/lib/cjs/structured-output/text.d.ts +0 -23
- package/lib/cjs/structured-output/text.js +0 -13
- package/lib/cjs/structured-output/text.js.map +0 -1
- package/lib/cjs/tools/index.d.ts +0 -3
- package/lib/cjs/tools/index.js +0 -7
- package/lib/cjs/tools/index.js.map +0 -1
- package/lib/cjs/tools/retrieve-knowledge.js +0 -32
- package/lib/cjs/tools/retrieve-knowledge.js.map +0 -1
- package/lib/cjs/types.d.ts +0 -56
- package/lib/cjs/types.js +0 -3
- package/lib/cjs/types.js.map +0 -1
- package/lib/esm/agent-builder.d.ts +0 -34
- package/lib/esm/agent-builder.js +0 -105
- package/lib/esm/agent-builder.js.map +0 -1
- package/lib/esm/bot-config-tools.d.ts +0 -7
- package/lib/esm/bot-config-tools.js +0 -19
- package/lib/esm/bot-config-tools.js.map +0 -1
- package/lib/esm/constants.d.ts +0 -11
- package/lib/esm/constants.js +0 -17
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/debug-logger.js.map +0 -1
- package/lib/esm/guardrails/index.d.ts +0 -1
- package/lib/esm/guardrails/index.js +0 -5
- package/lib/esm/guardrails/index.js.map +0 -1
- package/lib/esm/guardrails/input.d.ts +0 -10
- package/lib/esm/guardrails/input.js +0 -77
- package/lib/esm/guardrails/input.js.map +0 -1
- package/lib/esm/index.d.ts +0 -18
- package/lib/esm/index.js +0 -133
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/llm-config.d.ts +0 -15
- package/lib/esm/llm-config.js +0 -66
- package/lib/esm/llm-config.js.map +0 -1
- package/lib/esm/runner.d.ts +0 -18
- package/lib/esm/runner.js +0 -181
- package/lib/esm/runner.js.map +0 -1
- package/lib/esm/services/hubtype-api-client.d.ts +0 -14
- package/lib/esm/services/hubtype-api-client.js +0 -206
- package/lib/esm/services/hubtype-api-client.js.map +0 -1
- package/lib/esm/services/types.d.ts +0 -85
- package/lib/esm/services/types.js +0 -13
- package/lib/esm/services/types.js.map +0 -1
- package/lib/esm/structured-output/bot-executor.d.ts +0 -49
- package/lib/esm/structured-output/bot-executor.js +0 -18
- package/lib/esm/structured-output/bot-executor.js.map +0 -1
- package/lib/esm/structured-output/carousel.js +0 -22
- package/lib/esm/structured-output/carousel.js.map +0 -1
- package/lib/esm/structured-output/exit.d.ts +0 -10
- package/lib/esm/structured-output/exit.js +0 -11
- package/lib/esm/structured-output/exit.js.map +0 -1
- package/lib/esm/structured-output/index.d.ts +0 -291
- package/lib/esm/structured-output/index.js +0 -21
- package/lib/esm/structured-output/index.js.map +0 -1
- package/lib/esm/structured-output/text-with-buttons.js +0 -18
- package/lib/esm/structured-output/text-with-buttons.js.map +0 -1
- package/lib/esm/structured-output/text.js +0 -13
- package/lib/esm/structured-output/text.js.map +0 -1
- package/lib/esm/tools/index.js +0 -7
- package/lib/esm/tools/index.js.map +0 -1
- package/lib/esm/tools/retrieve-knowledge.d.ts +0 -9
- package/lib/esm/tools/retrieve-knowledge.js +0 -32
- package/lib/esm/tools/retrieve-knowledge.js.map +0 -1
- package/lib/esm/types.js +0 -3
- package/lib/esm/types.js.map +0 -1
- package/src/agent-builder.ts +0 -179
- package/src/bot-config-tools.ts +0 -21
- package/src/constants.ts +0 -21
- package/src/debug-logger.ts +0 -166
- package/src/guardrails/index.ts +0 -1
- package/src/guardrails/input.ts +0 -122
- package/src/index.ts +0 -209
- package/src/llm-config.ts +0 -96
- package/src/runner.ts +0 -287
- package/src/services/hubtype-api-client.ts +0 -240
- package/src/services/types.ts +0 -106
- package/src/structured-output/bot-executor.ts +0 -21
- package/src/structured-output/carousel.ts +0 -24
- package/src/structured-output/exit.ts +0 -12
- package/src/structured-output/index.ts +0 -25
- package/src/structured-output/text-with-buttons.ts +0 -21
- package/src/structured-output/text.ts +0 -13
- package/src/tools/index.ts +0 -5
- package/src/tools/retrieve-knowledge.ts +0 -37
- package/src/types.ts +0 -110
- /package/{lib/cjs → src/lib}/guardrails/index.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { OutputMessage } from '@botonic/shared';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export interface Output {
|
|
4
4
|
messages: OutputMessage[];
|
|
@@ -29,25 +29,25 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
29
29
|
text: z.ZodString;
|
|
30
30
|
buttons: z.ZodArray<z.ZodObject<{
|
|
31
31
|
text: z.ZodString;
|
|
32
|
-
url: z.ZodOptional<z.
|
|
32
|
+
url: z.ZodOptional<z.ZodString>;
|
|
33
33
|
}, "strip", z.ZodTypeAny, {
|
|
34
34
|
text: string;
|
|
35
|
-
url?: string |
|
|
35
|
+
url?: string | undefined;
|
|
36
36
|
}, {
|
|
37
37
|
text: string;
|
|
38
|
-
url?: string |
|
|
38
|
+
url?: string | undefined;
|
|
39
39
|
}>, "many">;
|
|
40
40
|
}, "strip", z.ZodTypeAny, {
|
|
41
41
|
text: string;
|
|
42
42
|
buttons: {
|
|
43
43
|
text: string;
|
|
44
|
-
url?: string |
|
|
44
|
+
url?: string | undefined;
|
|
45
45
|
}[];
|
|
46
46
|
}, {
|
|
47
47
|
text: string;
|
|
48
48
|
buttons: {
|
|
49
49
|
text: string;
|
|
50
|
-
url?: string |
|
|
50
|
+
url?: string | undefined;
|
|
51
51
|
}[];
|
|
52
52
|
}>;
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -56,7 +56,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
56
56
|
text: string;
|
|
57
57
|
buttons: {
|
|
58
58
|
text: string;
|
|
59
|
-
url?: string |
|
|
59
|
+
url?: string | undefined;
|
|
60
60
|
}[];
|
|
61
61
|
};
|
|
62
62
|
}, {
|
|
@@ -65,7 +65,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
65
65
|
text: string;
|
|
66
66
|
buttons: {
|
|
67
67
|
text: string;
|
|
68
|
-
url?: string |
|
|
68
|
+
url?: string | undefined;
|
|
69
69
|
}[];
|
|
70
70
|
};
|
|
71
71
|
}>, z.ZodObject<{
|
|
@@ -160,63 +160,9 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
160
160
|
type: "exit";
|
|
161
161
|
}, {
|
|
162
162
|
type: "exit";
|
|
163
|
-
}>, z.ZodObject<{
|
|
164
|
-
type: z.ZodEnum<["botExecutor"]>;
|
|
165
|
-
content: z.ZodObject<{
|
|
166
|
-
text: z.ZodString;
|
|
167
|
-
buttons: z.ZodArray<z.ZodObject<{
|
|
168
|
-
text: z.ZodString;
|
|
169
|
-
payload: z.ZodString;
|
|
170
|
-
}, "strip", z.ZodTypeAny, {
|
|
171
|
-
text: string;
|
|
172
|
-
payload: string;
|
|
173
|
-
}, {
|
|
174
|
-
text: string;
|
|
175
|
-
payload: string;
|
|
176
|
-
}>, "many">;
|
|
177
|
-
}, "strip", z.ZodTypeAny, {
|
|
178
|
-
text: string;
|
|
179
|
-
buttons: {
|
|
180
|
-
text: string;
|
|
181
|
-
payload: string;
|
|
182
|
-
}[];
|
|
183
|
-
}, {
|
|
184
|
-
text: string;
|
|
185
|
-
buttons: {
|
|
186
|
-
text: string;
|
|
187
|
-
payload: string;
|
|
188
|
-
}[];
|
|
189
|
-
}>;
|
|
190
|
-
}, "strip", z.ZodTypeAny, {
|
|
191
|
-
type: "botExecutor";
|
|
192
|
-
content: {
|
|
193
|
-
text: string;
|
|
194
|
-
buttons: {
|
|
195
|
-
text: string;
|
|
196
|
-
payload: string;
|
|
197
|
-
}[];
|
|
198
|
-
};
|
|
199
|
-
}, {
|
|
200
|
-
type: "botExecutor";
|
|
201
|
-
content: {
|
|
202
|
-
text: string;
|
|
203
|
-
buttons: {
|
|
204
|
-
text: string;
|
|
205
|
-
payload: string;
|
|
206
|
-
}[];
|
|
207
|
-
};
|
|
208
163
|
}>]>, "many">;
|
|
209
164
|
}, "strip", z.ZodTypeAny, {
|
|
210
165
|
messages: ({
|
|
211
|
-
type: "botExecutor";
|
|
212
|
-
content: {
|
|
213
|
-
text: string;
|
|
214
|
-
buttons: {
|
|
215
|
-
text: string;
|
|
216
|
-
payload: string;
|
|
217
|
-
}[];
|
|
218
|
-
};
|
|
219
|
-
} | {
|
|
220
166
|
type: "carousel";
|
|
221
167
|
content: {
|
|
222
168
|
elements: {
|
|
@@ -243,21 +189,12 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
243
189
|
text: string;
|
|
244
190
|
buttons: {
|
|
245
191
|
text: string;
|
|
246
|
-
url?: string |
|
|
192
|
+
url?: string | undefined;
|
|
247
193
|
}[];
|
|
248
194
|
};
|
|
249
195
|
})[];
|
|
250
196
|
}, {
|
|
251
197
|
messages: ({
|
|
252
|
-
type: "botExecutor";
|
|
253
|
-
content: {
|
|
254
|
-
text: string;
|
|
255
|
-
buttons: {
|
|
256
|
-
text: string;
|
|
257
|
-
payload: string;
|
|
258
|
-
}[];
|
|
259
|
-
};
|
|
260
|
-
} | {
|
|
261
198
|
type: "carousel";
|
|
262
199
|
content: {
|
|
263
200
|
elements: {
|
|
@@ -284,7 +221,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
284
221
|
text: string;
|
|
285
222
|
buttons: {
|
|
286
223
|
text: string;
|
|
287
|
-
url?: string |
|
|
224
|
+
url?: string | undefined;
|
|
288
225
|
}[];
|
|
289
226
|
};
|
|
290
227
|
})[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CarouselSchema } from './carousel';
|
|
3
|
+
import { ExitSchema } from './exit';
|
|
4
|
+
import { TextSchema } from './text';
|
|
5
|
+
import { TextWithButtonsSchema } from './text-with-buttons';
|
|
6
|
+
export const OutputSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
messages: z.array(z.union([TextSchema, TextWithButtonsSchema, CarouselSchema, ExitSchema])),
|
|
9
|
+
})
|
|
10
|
+
.describe('The messages to be sent to the user');
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/structured-output/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAM3D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CACzE;CACF,CAAC;KACD,QAAQ,CAAC,qCAAqC,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TextWithButtonsMessage } from '@botonic/shared';
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
export type { TextWithButtonsMessage };
|
|
4
4
|
export declare const TextWithButtonsSchema: z.ZodObject<{
|
|
@@ -7,25 +7,25 @@ export declare const TextWithButtonsSchema: z.ZodObject<{
|
|
|
7
7
|
text: z.ZodString;
|
|
8
8
|
buttons: z.ZodArray<z.ZodObject<{
|
|
9
9
|
text: z.ZodString;
|
|
10
|
-
url: z.ZodOptional<z.
|
|
10
|
+
url: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
12
|
text: string;
|
|
13
|
-
url?: string |
|
|
13
|
+
url?: string | undefined;
|
|
14
14
|
}, {
|
|
15
15
|
text: string;
|
|
16
|
-
url?: string |
|
|
16
|
+
url?: string | undefined;
|
|
17
17
|
}>, "many">;
|
|
18
18
|
}, "strip", z.ZodTypeAny, {
|
|
19
19
|
text: string;
|
|
20
20
|
buttons: {
|
|
21
21
|
text: string;
|
|
22
|
-
url?: string |
|
|
22
|
+
url?: string | undefined;
|
|
23
23
|
}[];
|
|
24
24
|
}, {
|
|
25
25
|
text: string;
|
|
26
26
|
buttons: {
|
|
27
27
|
text: string;
|
|
28
|
-
url?: string |
|
|
28
|
+
url?: string | undefined;
|
|
29
29
|
}[];
|
|
30
30
|
}>;
|
|
31
31
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -34,7 +34,7 @@ export declare const TextWithButtonsSchema: z.ZodObject<{
|
|
|
34
34
|
text: string;
|
|
35
35
|
buttons: {
|
|
36
36
|
text: string;
|
|
37
|
-
url?: string |
|
|
37
|
+
url?: string | undefined;
|
|
38
38
|
}[];
|
|
39
39
|
};
|
|
40
40
|
}, {
|
|
@@ -43,7 +43,7 @@ export declare const TextWithButtonsSchema: z.ZodObject<{
|
|
|
43
43
|
text: string;
|
|
44
44
|
buttons: {
|
|
45
45
|
text: string;
|
|
46
|
-
url?: string |
|
|
46
|
+
url?: string | undefined;
|
|
47
47
|
}[];
|
|
48
48
|
};
|
|
49
49
|
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export const TextWithButtonsSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
type: z.enum(['textWithButtons']),
|
|
5
|
+
content: z.object({
|
|
6
|
+
text: z.string(),
|
|
7
|
+
buttons: z.array(z.object({
|
|
8
|
+
text: z.string(),
|
|
9
|
+
url: z.string().optional(),
|
|
10
|
+
})),
|
|
11
|
+
}),
|
|
12
|
+
})
|
|
13
|
+
.describe('A text message with buttons to allow the user to use quick replies');
|
|
14
|
+
//# sourceMappingURL=text-with-buttons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-with-buttons.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/structured-output/text-with-buttons.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAA;AAInB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC3B,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CACP,oEAAoE,CACrE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/structured-output/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACjB,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,MAAM,CAAC,MAAM,cAAc,GAAW,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
3
|
-
export declare const retrieveKnowledge: import("@openai/agents").FunctionTool<
|
|
2
|
+
import { AiAgentContext } from '../types';
|
|
3
|
+
export declare const retrieveKnowledge: import("@openai/agents").FunctionTool<AiAgentContext<import("dist/libs/botonic/shared/src").ResolvedPlugins, import("dist/libs/botonic/shared/src").UserExtraData>, z.ZodObject<{
|
|
4
4
|
query: z.ZodString;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
|
6
6
|
query: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { tool } from '@openai/agents';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { HubtypeApiClient } from '../hubtype-api-client';
|
|
5
|
+
export const retrieveKnowledge = tool({
|
|
6
|
+
name: 'retrieve_knowledge',
|
|
7
|
+
description: 'Consult the knowledge base for information before answering. Use this tool to make sure the information you provide is faithful.',
|
|
8
|
+
parameters: z.object({
|
|
9
|
+
query: z.string().describe('The query to search the knowledge base for'),
|
|
10
|
+
}),
|
|
11
|
+
execute: (input, runContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const context = runContext === null || runContext === void 0 ? void 0 : runContext.context;
|
|
13
|
+
const query = input.query;
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error('Context is required');
|
|
16
|
+
}
|
|
17
|
+
const sourceIds = context.sourceIds;
|
|
18
|
+
const client = new HubtypeApiClient(context.authToken);
|
|
19
|
+
const chunks = yield client.retrieveSimilarChunks(query, sourceIds);
|
|
20
|
+
const chunkTexts = chunks.map(chunk => chunk.text);
|
|
21
|
+
context.knowledgeUsed = {
|
|
22
|
+
query,
|
|
23
|
+
sourceIds,
|
|
24
|
+
chunksIds: chunks.map(chunk => chunk.id),
|
|
25
|
+
chunkTexts,
|
|
26
|
+
};
|
|
27
|
+
return chunkTexts;
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=retrieve-knowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-knowledge.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/tools/retrieve-knowledge.ts"],"names":[],"mappings":";AAAA,OAAO,EAAc,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAGxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACT,kIAAkI;IACpI,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;KACzE,CAAC;IACF,OAAO,EAAE,CACP,KAAwB,EACxB,UAAuC,EACpB,EAAE;QACrB,MAAM,OAAO,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,CAAA;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACzB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QACnC,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACnE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAElD,OAAO,CAAC,aAAa,GAAG;YACtB,KAAK;YACL,SAAS;YACT,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,UAAU;SACX,CAAA;QAED,OAAO,UAAU,CAAA;IACnB,CAAC,CAAA;CACF,CAAC,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AgenticOutputMessage, AiAgentArgs,
|
|
1
|
+
import type { AgenticOutputMessage, AiAgentArgs, BotContext, GuardrailRule, InferenceResponse, ResolvedPlugins, RunResult, UserExtraData } from '@botonic/shared';
|
|
2
2
|
import type { Agent, AgentInputItem, AgentOutputType, RunContext as OpenAIRunContext, Tool as OpenAITool } from '@openai/agents';
|
|
3
3
|
import type { ZodSchema } from 'zod';
|
|
4
4
|
import type { OutputSchema } from './structured-output';
|
|
5
|
-
export interface
|
|
5
|
+
export interface AiAgentContext<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
|
|
6
6
|
authToken: string;
|
|
7
7
|
sourceIds: string[];
|
|
8
8
|
knowledgeUsed: {
|
|
@@ -11,10 +11,10 @@ export interface Context<TPlugins extends ResolvedPlugins = ResolvedPlugins, TEx
|
|
|
11
11
|
chunksIds: string[];
|
|
12
12
|
chunkTexts: string[];
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
botonicContext: BotContext<TPlugins, TExtraData>;
|
|
15
15
|
}
|
|
16
|
-
export type RunContext<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData =
|
|
17
|
-
export interface CustomTool<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData =
|
|
16
|
+
export type RunContext<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> = OpenAIRunContext<AiAgentContext<TPlugins, TExtraData>>;
|
|
17
|
+
export interface CustomTool<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
|
|
18
18
|
name: string;
|
|
19
19
|
description: string;
|
|
20
20
|
schema: ZodSchema;
|
|
@@ -24,8 +24,9 @@ export interface Chunk {
|
|
|
24
24
|
id: string;
|
|
25
25
|
text: string;
|
|
26
26
|
}
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
27
|
+
export type ContactInfo = Record<string, string>;
|
|
28
|
+
export type Tool<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> = OpenAITool<AiAgentContext<TPlugins, TExtraData>>;
|
|
29
|
+
export type AIAgent<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> = Agent<AiAgentContext<TPlugins, TExtraData>, AgentOutputType<typeof OutputSchema>>;
|
|
29
30
|
export type MessageHistoryApiVersion = 'v1' | 'v2';
|
|
30
31
|
export interface MemoryOptions {
|
|
31
32
|
maxMessages?: number;
|
|
@@ -33,24 +34,13 @@ export interface MemoryOptions {
|
|
|
33
34
|
maxFullToolResults?: number;
|
|
34
35
|
debugMode?: boolean;
|
|
35
36
|
}
|
|
36
|
-
export interface PluginAiAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData =
|
|
37
|
-
authToken?: string;
|
|
37
|
+
export interface PluginAiAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
|
|
38
38
|
customTools?: CustomTool<TPlugins, TExtraData>[];
|
|
39
|
-
maxRetries?: number;
|
|
40
39
|
timeout?: number;
|
|
41
|
-
|
|
40
|
+
maxRetries?: number;
|
|
42
41
|
messageHistoryApiVersion?: MessageHistoryApiVersion;
|
|
43
|
-
/** Options for V2 message history API. Only used when messageHistoryApiVersion is 'v2'. */
|
|
44
42
|
memory?: MemoryOptions;
|
|
45
|
-
/** Enable debug logging for AI agent configuration and execution details. */
|
|
46
43
|
enableDebug?: boolean;
|
|
47
44
|
}
|
|
48
|
-
export interface ResultRawResponse {
|
|
49
|
-
usage: {
|
|
50
|
-
inputTokens: number;
|
|
51
|
-
outputTokens: number;
|
|
52
|
-
};
|
|
53
|
-
providerData?: Record<string, unknown>;
|
|
54
|
-
}
|
|
55
45
|
export type AgenticInputMessage = AgentInputItem;
|
|
56
|
-
export { AgenticOutputMessage, AiAgentArgs, GuardrailRule, InferenceResponse, RunResult, };
|
|
46
|
+
export type { AgenticOutputMessage, AiAgentArgs, GuardrailRule, InferenceResponse, RunResult, };
|
package/src/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/types.ts"],"names":[],"mappings":""}
|
package/README.md
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
# Botonic Plugin AI Agents
|
|
2
|
-
|
|
3
|
-
## env variables
|
|
4
|
-
|
|
5
|
-
- It is necessary to add the following variables to an `.env` file:
|
|
6
|
-
- `AZURE_OPENAI_API_KEY`
|
|
7
|
-
- `AZURE_OPENAI_API_BASE`
|
|
8
|
-
- `AZURE_OPENAI_API_DEPLOYMENT_NAME`
|
|
9
|
-
- `AZURE_OPENAI_API_VERSION`
|
|
10
|
-
- Add these env variables to build using rspack, for target NODE and DEV.
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
...
|
|
14
|
-
import { config } from 'dotenv'
|
|
15
|
-
config()
|
|
16
|
-
...
|
|
17
|
-
const plugins = [
|
|
18
|
-
new rspack.EnvironmentPlugin({
|
|
19
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
20
|
-
HUBTYPE_API_URL: process.env.HUBTYPE_API_URL || HUBTYPE_DEFAULTS.API_URL,
|
|
21
|
-
BOTONIC_TARGET: BotonicTarget.NODE,
|
|
22
|
-
WEBCHAT_PUSHER_KEY:
|
|
23
|
-
process.env.WEBCHAT_PUSHER_KEY || HUBTYPE_DEFAULTS.WEBCHAT_PUSHER_KEY,
|
|
24
|
-
ENVIRONMENT: process.env.ENVIRONMENT,
|
|
25
|
-
AZURE_OPENAI_API_KEY: isNodeOrDev
|
|
26
|
-
? process.env.AZURE_OPENAI_API_KEY
|
|
27
|
-
: undefined,
|
|
28
|
-
AZURE_OPENAI_API_DEPLOYMENT_NAME: isNodeOrDev
|
|
29
|
-
? process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
|
|
30
|
-
: undefined,
|
|
31
|
-
AZURE_OPENAI_API_VERSION: isNodeOrDev
|
|
32
|
-
? process.env.AZURE_OPENAI_API_VERSION
|
|
33
|
-
: undefined,
|
|
34
|
-
AZURE_OPENAI_API_BASE: isNodeOrDev
|
|
35
|
-
? process.env.AZURE_OPENAI_API_BASE
|
|
36
|
-
: undefined,
|
|
37
|
-
}),
|
|
38
|
-
new rspack.ProgressPlugin(),
|
|
39
|
-
]
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Custom Tools
|
|
43
|
-
|
|
44
|
-
- It is possible to add tools from the bot code. To do this:
|
|
45
|
-
- Add the `zod` dependency.
|
|
46
|
-
- Create and export the definition of the tools in a file, for example: `src/server/tools.ts`.
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
import { CustomTool } from '@botonic/plugin-ai-agents'
|
|
50
|
-
import axios from 'axios'
|
|
51
|
-
import z from 'zod'
|
|
52
|
-
|
|
53
|
-
export const customTools: CustomTool[] = [
|
|
54
|
-
{
|
|
55
|
-
name: 'get_current_weather',
|
|
56
|
-
description: 'Get current weather for a city',
|
|
57
|
-
schema: z.object({
|
|
58
|
-
cityName: z.string(),
|
|
59
|
-
}),
|
|
60
|
-
func: async (input: { cityName: string }) => {
|
|
61
|
-
const baseURL = 'http://api.weatherapi.com/v1'
|
|
62
|
-
const response = await axios.get(`${baseURL}/forecast.json`, {
|
|
63
|
-
params: {
|
|
64
|
-
key: 'WEATHER_API_TOKEN',
|
|
65
|
-
q: input.cityName,
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
const data = response.data
|
|
69
|
-
console.log('get_current_weather', { data })
|
|
70
|
-
return data
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
...
|
|
74
|
-
]
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
- Add these tools to:
|
|
78
|
-
- Update the `BotonicPluginFlowBuilderOptions`, as we did with the knowledge base, and add the `customTools`.
|
|
79
|
-
|
|
80
|
-
src/server/config.ts
|
|
81
|
-
|
|
82
|
-
```ts
|
|
83
|
-
import { PluginAiAgentOptions } from '@botonic/plugin-ai-agents'
|
|
84
|
-
import { customTools } from './tools'
|
|
85
|
-
|
|
86
|
-
...
|
|
87
|
-
function getFlowBuilderConfig(
|
|
88
|
-
env: ENVIRONMENT
|
|
89
|
-
): BotonicPluginFlowBuilderOptions<BotPlugins, UserData> {
|
|
90
|
-
return {
|
|
91
|
-
...
|
|
92
|
-
getAiAgentResponse: async (
|
|
93
|
-
request: BotRequest,
|
|
94
|
-
aiAgentArgs: {
|
|
95
|
-
name: string
|
|
96
|
-
instructions: string
|
|
97
|
-
}
|
|
98
|
-
) => {
|
|
99
|
-
const aiAgentPlugin = request.plugins.aiAgents
|
|
100
|
-
return await aiAgentPlugin.getInference(request, aiAgentArgs)
|
|
101
|
-
},
|
|
102
|
-
...
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function getAiAgentsConfig(): PluginAiAgentOptions {
|
|
106
|
-
return {
|
|
107
|
-
authToken: 'AUTH_TOKEN', // Used locally
|
|
108
|
-
customTools: customTools,
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
...
|
|
112
|
-
|
|
113
|
-
interface Config {
|
|
114
|
-
// Use any for infer type for TPlugins and TExtraData
|
|
115
|
-
// to avoid type errors with circular dependencies
|
|
116
|
-
flowBuilder: BotonicPluginFlowBuilderOptions<any, any>
|
|
117
|
-
aiAgents: PluginAiAgentOptions
|
|
118
|
-
knowledgeBases: PluginKnowledgeBaseOptions
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const CONFIG: Record<ENVIRONMENT, Config> = {
|
|
122
|
-
[ENVIRONMENT.LOCAL]: {
|
|
123
|
-
flowBuilder: getFlowBuilderConfig(ENVIRONMENT.LOCAL),
|
|
124
|
-
aiAgents: getAiAgentsConfig(),
|
|
125
|
-
knowledgeBases: getKnowledgeBasesConfig(),
|
|
126
|
-
},
|
|
127
|
-
...
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Share customTools with flow builder frontend
|
|
132
|
-
|
|
133
|
-
- Create new `src/bot-config.ts` file and add customTools. This file is used so that every time a bot is deployed, the Flow Builder frontend can know which tools are in the deployed bot and enable or disable tools for each AI Agent node.
|
|
134
|
-
|
|
135
|
-
src/bot-config.ts
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
import { BotConfigJSON } from '@botonic/core'
|
|
139
|
-
|
|
140
|
-
import { customTools } from './server/tools'
|
|
141
|
-
|
|
142
|
-
const aiAgentTools =
|
|
143
|
-
customTools?.map(customTool => ({
|
|
144
|
-
name: customTool.name,
|
|
145
|
-
description: customTool.description,
|
|
146
|
-
})) || []
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* This is the configuration is shared with flow-builder-frontend.
|
|
150
|
-
*/
|
|
151
|
-
export const botConfig: BotConfigJSON = {
|
|
152
|
-
tools: aiAgentTools,
|
|
153
|
-
payloads: [],
|
|
154
|
-
webviews: [],
|
|
155
|
-
}
|
|
156
|
-
```
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AAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC,CAAA;IACpC,CAAC;CACF;AAlJD,wCAkJC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ToolConfigJSON } from '@botonic/core';
|
|
2
|
-
import type { CustomTool } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).
|
|
5
|
-
* Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getToolsForBotConfig(customTools: CustomTool[]): ToolConfigJSON[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getToolsForBotConfig = getToolsForBotConfig;
|
|
4
|
-
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
5
|
-
/**
|
|
6
|
-
* Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).
|
|
7
|
-
* Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.
|
|
8
|
-
*/
|
|
9
|
-
function getToolsForBotConfig(customTools) {
|
|
10
|
-
return customTools.map(tool => ({
|
|
11
|
-
name: tool.name,
|
|
12
|
-
description: tool.description,
|
|
13
|
-
// Cast to avoid TS "Type instantiation is excessively deep" with zodToJsonSchema + ZodSchema
|
|
14
|
-
schema: (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema, {
|
|
15
|
-
$refStrategy: 'none',
|
|
16
|
-
}),
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=bot-config-tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bot-config-tools.js","sourceRoot":"","sources":["../../src/bot-config-tools.ts"],"names":[],"mappings":";;AASA,oDAWC;AAnBD,2DAAoD;AAIpD;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,WAAyB;IAEzB,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,6FAA6F;QAC7F,MAAM,EAAE,IAAA,oCAAe,EAAC,IAAI,CAAC,MAAe,EAAE;YAC5C,YAAY,EAAE,MAAM;SACrB,CAA6B;KAC/B,CAAC,CAAC,CAAA;AACL,CAAC"}
|
package/lib/cjs/constants.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_TIMEOUT_16_SECONDS = exports.MAX_MEMORY_LENGTH = exports.isProd = exports.AZURE_OPENAI_API_VERSION = exports.AZURE_OPENAI_API_BASE = exports.AZURE_OPENAI_API_KEY = exports.OPENAI_PROVIDER = exports.OPENAI_MODEL = exports.OPENAI_API_KEY = exports.HUBTYPE_API_URL = void 0;
|
|
4
|
-
exports.HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
5
|
-
// OpenAI Provider Configuration
|
|
6
|
-
exports.OPENAI_API_KEY = process.env.OPENAI_API_KEY; // pragma: allowlist secret
|
|
7
|
-
exports.OPENAI_MODEL = process.env.OPENAI_MODEL || 'gpt-4.1-mini';
|
|
8
|
-
exports.OPENAI_PROVIDER = process.env.OPENAI_PROVIDER || 'azure';
|
|
9
|
-
// Azure OpenAI Configuration
|
|
10
|
-
exports.AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY; // pragma: allowlist secret
|
|
11
|
-
exports.AZURE_OPENAI_API_BASE = process.env.AZURE_OPENAI_API_BASE;
|
|
12
|
-
exports.AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION || '2025-01-01-preview';
|
|
13
|
-
exports.isProd = process.env.NODE_ENV === 'production';
|
|
14
|
-
exports.MAX_MEMORY_LENGTH = 25;
|
|
15
|
-
exports.DEFAULT_TIMEOUT_16_SECONDS = 16000;
|
|
16
|
-
exports.DEFAULT_MAX_RETRIES = 2;
|
|
17
|
-
//# sourceMappingURL=constants.js.map
|
package/lib/cjs/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAE1D,gCAAgC;AACnB,QAAA,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA,CAAC,2BAA2B;AACvE,QAAA,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,cAAc,CAAA;AACzD,QAAA,eAAe,GACzB,OAAO,CAAC,GAAG,CAAC,eAAsC,IAAI,OAAO,CAAA;AAEhE,6BAA6B;AAChB,QAAA,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA,CAAC,2BAA2B;AACnF,QAAA,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;AACzD,QAAA,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,oBAAoB,CAAA;AAEjD,QAAA,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AAE9C,QAAA,iBAAiB,GAAG,EAAE,CAAA;AAEtB,QAAA,0BAA0B,GAAG,KAAK,CAAA;AAClC,QAAA,mBAAmB,GAAG,CAAC,CAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { AiAgentArgs, ToolExecution } from '@botonic/core';
|
|
2
|
-
import type { ModelSettings } from '@openai/agents';
|
|
3
|
-
import type { AgenticInputMessage, MemoryOptions, RunResult } from './types';
|
|
4
|
-
export interface DebugLoggerConfig {
|
|
5
|
-
messageHistoryApiVersion: string;
|
|
6
|
-
maxRetries: number;
|
|
7
|
-
timeout: number;
|
|
8
|
-
customToolNames: string[];
|
|
9
|
-
memory: MemoryOptions;
|
|
10
|
-
}
|
|
11
|
-
export interface ModelSettingsInfo {
|
|
12
|
-
provider: string;
|
|
13
|
-
model: string | undefined;
|
|
14
|
-
reasoning?: {
|
|
15
|
-
effort: string;
|
|
16
|
-
};
|
|
17
|
-
text?: {
|
|
18
|
-
verbosity: string;
|
|
19
|
-
};
|
|
20
|
-
toolChoice?: string;
|
|
21
|
-
hasRetrieveKnowledge: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface DebugLogger {
|
|
24
|
-
logInitialConfig(config: DebugLoggerConfig): void;
|
|
25
|
-
logAgentDebugInfo(aiAgentArgs: AiAgentArgs, toolNames: string[], messages: AgenticInputMessage[]): void;
|
|
26
|
-
logModelSettings(settings: ModelSettingsInfo): void;
|
|
27
|
-
logRunnerStart(model: string, modelSettings: ModelSettings): void;
|
|
28
|
-
logRunResult(runResult: RunResult, startTime: number): void;
|
|
29
|
-
logGuardrailTriggered(): void;
|
|
30
|
-
logRunnerError(startTime: number, error: unknown): void;
|
|
31
|
-
logToolExecution(toolExecution: ToolExecution): void;
|
|
32
|
-
}
|
|
33
|
-
export declare function createDebugLogger(enableDebug: boolean): DebugLogger;
|