@botonic/plugin-ai-agents 0.42.0-alpha.3 → 0.42.0-alpha.4
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/openai.js +1 -0
- package/lib/cjs/openai.js.map +1 -1
- package/lib/cjs/runner.d.ts +1 -2
- package/lib/cjs/runner.js +4 -12
- package/lib/cjs/runner.js.map +1 -1
- package/lib/cjs/structured-output/carousel.d.ts +5 -0
- package/lib/cjs/structured-output/carousel.js +1 -0
- package/lib/cjs/structured-output/carousel.js.map +1 -1
- package/lib/cjs/structured-output/index.d.ts +7 -0
- package/lib/esm/openai.js +1 -0
- package/lib/esm/openai.js.map +1 -1
- package/lib/esm/runner.d.ts +1 -2
- package/lib/esm/runner.js +4 -12
- package/lib/esm/runner.js.map +1 -1
- package/lib/esm/structured-output/carousel.d.ts +5 -0
- package/lib/esm/structured-output/carousel.js +1 -0
- package/lib/esm/structured-output/carousel.js.map +1 -1
- package/lib/esm/structured-output/index.d.ts +7 -0
- package/package.json +2 -2
- package/src/openai.ts +1 -0
- package/src/runner.ts +4 -17
- package/src/structured-output/carousel.ts +1 -0
package/lib/cjs/openai.js
CHANGED
|
@@ -16,6 +16,7 @@ function setAzureOpenAIClient() {
|
|
|
16
16
|
apiVersion: constants_1.AZURE_OPENAI_API_VERSION,
|
|
17
17
|
deployment: constants_1.AZURE_OPENAI_API_DEPLOYMENT_NAME,
|
|
18
18
|
baseURL: constants_1.AZURE_OPENAI_API_BASE,
|
|
19
|
+
timeout: 8000,
|
|
19
20
|
dangerouslyAllowBrowser: !constants_1.isProd,
|
|
20
21
|
});
|
|
21
22
|
(0, agents_1.setDefaultOpenAIClient)(client);
|
package/lib/cjs/openai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/openai.ts"],"names":[],"mappings":";;;AAAA,2CAIuB;AACvB,mCAAoC;AAEpC,2CAMoB;AAEpB,SAAgB,WAAW;IACzB,oBAAoB,EAAE,CAAA;IACtB,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAA;IAChC,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,kCAIC;AAED,SAAS,oBAAoB;IAC3B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC7B,MAAM,EAAE,gCAAoB;QAC5B,UAAU,EAAE,oCAAwB;QACpC,UAAU,EAAE,4CAAgC;QAC5C,OAAO,EAAE,iCAAqB;QAC9B,uBAAuB,EAAE,CAAC,kBAAM;KACjC,CAAC,CAAA;IACF,IAAA,+BAAsB,EAAC,MAAM,CAAC,CAAA;AAChC,CAAC"}
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/openai.ts"],"names":[],"mappings":";;;AAAA,2CAIuB;AACvB,mCAAoC;AAEpC,2CAMoB;AAEpB,SAAgB,WAAW;IACzB,oBAAoB,EAAE,CAAA;IACtB,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAA;IAChC,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,kCAIC;AAED,SAAS,oBAAoB;IAC3B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC7B,MAAM,EAAE,gCAAoB;QAC5B,UAAU,EAAE,oCAAwB;QACpC,UAAU,EAAE,4CAAgC;QAC5C,OAAO,EAAE,iCAAqB;QAC9B,OAAO,EAAE,IAAI;QACb,uBAAuB,EAAE,CAAC,kBAAM;KACjC,CAAC,CAAA;IACF,IAAA,+BAAsB,EAAC,MAAM,CAAC,CAAA;AAChC,CAAC"}
|
package/lib/cjs/runner.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { AgenticInputMessage, AIAgent, Context, RunResult } from './types';
|
|
|
3
3
|
export declare class AIAgentRunner<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
|
|
4
4
|
private agent;
|
|
5
5
|
constructor(agent: AIAgent<TPlugins, TExtraData>);
|
|
6
|
-
run(messages: AgenticInputMessage[], context: Context<TPlugins, TExtraData
|
|
7
|
-
private runWithRetry;
|
|
6
|
+
run(messages: AgenticInputMessage[], context: Context<TPlugins, TExtraData>): Promise<RunResult>;
|
|
8
7
|
private getToolsExecuted;
|
|
9
8
|
private getToolExecutionInfo;
|
|
10
9
|
private getSafeToolArguments;
|
package/lib/cjs/runner.js
CHANGED
|
@@ -8,19 +8,14 @@ class AIAgentRunner {
|
|
|
8
8
|
constructor(agent) {
|
|
9
9
|
this.agent = agent;
|
|
10
10
|
}
|
|
11
|
-
run(messages, context
|
|
12
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
return this.runWithRetry(messages, context, maxRetries, 1);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
runWithRetry(inputMessages, context, maxRetries, attempt) {
|
|
11
|
+
run(messages, context) {
|
|
17
12
|
var _a;
|
|
18
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
14
|
try {
|
|
20
15
|
const runner = new agents_1.Runner({
|
|
21
16
|
modelSettings: { temperature: 0 },
|
|
22
17
|
});
|
|
23
|
-
const result = yield runner.run(this.agent,
|
|
18
|
+
const result = yield runner.run(this.agent, messages, { context });
|
|
24
19
|
const outputMessages = ((_a = result.finalOutput) === null || _a === void 0 ? void 0 : _a.messages) || [];
|
|
25
20
|
const hasExit = outputMessages.length === 0 ||
|
|
26
21
|
outputMessages.some(message => message.type === 'exit');
|
|
@@ -31,7 +26,7 @@ class AIAgentRunner {
|
|
|
31
26
|
: outputMessages.filter(message => message.type !== 'exit'),
|
|
32
27
|
toolsExecuted,
|
|
33
28
|
exit: hasExit,
|
|
34
|
-
memoryLength:
|
|
29
|
+
memoryLength: messages.length,
|
|
35
30
|
error: false,
|
|
36
31
|
inputGuardrailsTriggered: [],
|
|
37
32
|
outputGuardrailsTriggered: [],
|
|
@@ -49,10 +44,7 @@ class AIAgentRunner {
|
|
|
49
44
|
outputGuardrailsTriggered: [],
|
|
50
45
|
};
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
return this.runWithRetry(inputMessages, context, maxRetries, attempt + 1);
|
|
47
|
+
throw error;
|
|
56
48
|
}
|
|
57
49
|
});
|
|
58
50
|
}
|
package/lib/cjs/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";;;;AACA,2CAIuB;AAEvB,mCAA2C;AAS3C,MAAa,aAAa;IAMxB,YAAY,KAAoC;QAC9C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,OAAsC
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";;;;AACA,2CAIuB;AAEvB,mCAA2C;AAS3C,MAAa,aAAa;IAMxB,YAAY,KAAoC;QAC9C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,OAAsC;;;YAEtC,IAAI;gBACF,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;oBACxB,aAAa,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;iBAClC,CAAC,CAAA;gBACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;gBAElE,MAAM,cAAc,GAAG,CAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,QAAQ,KAAI,EAAE,CAAA;gBACzD,MAAM,OAAO,GACX,cAAc,CAAC,MAAM,KAAK,CAAC;oBAC3B,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA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,KAAK,eAAe,EAAE;YACzC,OAAO;gBACL,QAAQ,EAAE,EAAE;gBACZ,aAAa,EAAE,EAAE;aAClB,CAAA;SACF;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAEvE,IAAI,QAAQ,KAAK,yBAAiB,CAAC,IAAI,EAAE;YACvC,OAAO;gBACL,QAAQ;gBACR,aAAa;gBACb,uBAAuB,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS;gBACxD,sBAAsB,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS;aACxD,CAAA;SACF;QAED,OAAO;YACL,QAAQ;YACR,aAAa;SACd,CAAA;IACH,CAAC;IAEO,oBAAoB,CAAC,gBAAwB;QACnD,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;SACpC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,EAAE,CAAA;SACV;IACH,CAAC;CACF;AA1GD,sCA0GC"}
|
|
@@ -4,6 +4,7 @@ export type { CarouselMessage };
|
|
|
4
4
|
export declare const CarouselSchema: z.ZodObject<{
|
|
5
5
|
type: z.ZodEnum<["carousel"]>;
|
|
6
6
|
content: z.ZodObject<{
|
|
7
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
8
|
elements: z.ZodArray<z.ZodObject<{
|
|
8
9
|
title: z.ZodString;
|
|
9
10
|
subtitle: z.ZodString;
|
|
@@ -45,6 +46,7 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
45
46
|
url?: string | null | undefined;
|
|
46
47
|
};
|
|
47
48
|
}[];
|
|
49
|
+
text?: string | null | undefined;
|
|
48
50
|
}, {
|
|
49
51
|
elements: {
|
|
50
52
|
title: string;
|
|
@@ -55,6 +57,7 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
55
57
|
url?: string | null | undefined;
|
|
56
58
|
};
|
|
57
59
|
}[];
|
|
60
|
+
text?: string | null | undefined;
|
|
58
61
|
}>;
|
|
59
62
|
}, "strip", z.ZodTypeAny, {
|
|
60
63
|
type: "carousel";
|
|
@@ -68,6 +71,7 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
68
71
|
url?: string | null | undefined;
|
|
69
72
|
};
|
|
70
73
|
}[];
|
|
74
|
+
text?: string | null | undefined;
|
|
71
75
|
};
|
|
72
76
|
}, {
|
|
73
77
|
type: "carousel";
|
|
@@ -81,5 +85,6 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
81
85
|
url?: string | null | undefined;
|
|
82
86
|
};
|
|
83
87
|
}[];
|
|
88
|
+
text?: string | null | undefined;
|
|
84
89
|
};
|
|
85
90
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":";;;AACA,6BAAuB;AAIV,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,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;aACtC,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":";;;AACA,6BAAuB;AAIV,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,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QACtC,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,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;aACtC,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
|
|
@@ -64,6 +64,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
64
64
|
}>, z.ZodObject<{
|
|
65
65
|
type: z.ZodEnum<["carousel"]>;
|
|
66
66
|
content: z.ZodObject<{
|
|
67
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
68
|
elements: z.ZodArray<z.ZodObject<{
|
|
68
69
|
title: z.ZodString;
|
|
69
70
|
subtitle: z.ZodString;
|
|
@@ -105,6 +106,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
105
106
|
url?: string | null | undefined;
|
|
106
107
|
};
|
|
107
108
|
}[];
|
|
109
|
+
text?: string | null | undefined;
|
|
108
110
|
}, {
|
|
109
111
|
elements: {
|
|
110
112
|
title: string;
|
|
@@ -115,6 +117,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
115
117
|
url?: string | null | undefined;
|
|
116
118
|
};
|
|
117
119
|
}[];
|
|
120
|
+
text?: string | null | undefined;
|
|
118
121
|
}>;
|
|
119
122
|
}, "strip", z.ZodTypeAny, {
|
|
120
123
|
type: "carousel";
|
|
@@ -128,6 +131,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
128
131
|
url?: string | null | undefined;
|
|
129
132
|
};
|
|
130
133
|
}[];
|
|
134
|
+
text?: string | null | undefined;
|
|
131
135
|
};
|
|
132
136
|
}, {
|
|
133
137
|
type: "carousel";
|
|
@@ -141,6 +145,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
141
145
|
url?: string | null | undefined;
|
|
142
146
|
};
|
|
143
147
|
}[];
|
|
148
|
+
text?: string | null | undefined;
|
|
144
149
|
};
|
|
145
150
|
}>, z.ZodObject<{
|
|
146
151
|
type: z.ZodEnum<["exit"]>;
|
|
@@ -162,6 +167,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
162
167
|
url?: string | null | undefined;
|
|
163
168
|
};
|
|
164
169
|
}[];
|
|
170
|
+
text?: string | null | undefined;
|
|
165
171
|
};
|
|
166
172
|
} | {
|
|
167
173
|
type: "exit";
|
|
@@ -192,6 +198,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
192
198
|
url?: string | null | undefined;
|
|
193
199
|
};
|
|
194
200
|
}[];
|
|
201
|
+
text?: string | null | undefined;
|
|
195
202
|
};
|
|
196
203
|
} | {
|
|
197
204
|
type: "exit";
|
package/lib/esm/openai.js
CHANGED
package/lib/esm/openai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;A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,CAAC,MAAM;KACjC,CAAC,CAAA;IACF,sBAAsB,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC"}
|
package/lib/esm/runner.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { AgenticInputMessage, AIAgent, Context, RunResult } from './types';
|
|
|
3
3
|
export declare class AIAgentRunner<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
|
|
4
4
|
private agent;
|
|
5
5
|
constructor(agent: AIAgent<TPlugins, TExtraData>);
|
|
6
|
-
run(messages: AgenticInputMessage[], context: Context<TPlugins, TExtraData
|
|
7
|
-
private runWithRetry;
|
|
6
|
+
run(messages: AgenticInputMessage[], context: Context<TPlugins, TExtraData>): Promise<RunResult>;
|
|
8
7
|
private getToolsExecuted;
|
|
9
8
|
private getToolExecutionInfo;
|
|
10
9
|
private getSafeToolArguments;
|
package/lib/esm/runner.js
CHANGED
|
@@ -5,19 +5,14 @@ export class AIAgentRunner {
|
|
|
5
5
|
constructor(agent) {
|
|
6
6
|
this.agent = agent;
|
|
7
7
|
}
|
|
8
|
-
run(messages, context
|
|
9
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10
|
-
return this.runWithRetry(messages, context, maxRetries, 1);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
runWithRetry(inputMessages, context, maxRetries, attempt) {
|
|
8
|
+
run(messages, context) {
|
|
14
9
|
var _a;
|
|
15
10
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
11
|
try {
|
|
17
12
|
const runner = new Runner({
|
|
18
13
|
modelSettings: { temperature: 0 },
|
|
19
14
|
});
|
|
20
|
-
const result = yield runner.run(this.agent,
|
|
15
|
+
const result = yield runner.run(this.agent, messages, { context });
|
|
21
16
|
const outputMessages = ((_a = result.finalOutput) === null || _a === void 0 ? void 0 : _a.messages) || [];
|
|
22
17
|
const hasExit = outputMessages.length === 0 ||
|
|
23
18
|
outputMessages.some(message => message.type === 'exit');
|
|
@@ -28,7 +23,7 @@ export class AIAgentRunner {
|
|
|
28
23
|
: outputMessages.filter(message => message.type !== 'exit'),
|
|
29
24
|
toolsExecuted,
|
|
30
25
|
exit: hasExit,
|
|
31
|
-
memoryLength:
|
|
26
|
+
memoryLength: messages.length,
|
|
32
27
|
error: false,
|
|
33
28
|
inputGuardrailsTriggered: [],
|
|
34
29
|
outputGuardrailsTriggered: [],
|
|
@@ -46,10 +41,7 @@ export class AIAgentRunner {
|
|
|
46
41
|
outputGuardrailsTriggered: [],
|
|
47
42
|
};
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
return this.runWithRetry(inputMessages, context, maxRetries, attempt + 1);
|
|
44
|
+
throw error;
|
|
53
45
|
}
|
|
54
46
|
});
|
|
55
47
|
}
|
package/lib/esm/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";AACA,OAAO,EACL,+BAA+B,EAC/B,MAAM,EACN,eAAe,GAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAS3C,MAAM,OAAO,aAAa;IAMxB,YAAY,KAAoC;QAC9C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,OAAsC
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";AACA,OAAO,EACL,+BAA+B,EAC/B,MAAM,EACN,eAAe,GAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAS3C,MAAM,OAAO,aAAa;IAMxB,YAAY,KAAoC;QAC9C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,OAAsC;;;YAEtC,IAAI;gBACF,MAAM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5
5
|
type: z.ZodEnum<["carousel"]>;
|
|
6
6
|
content: z.ZodObject<{
|
|
7
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
8
|
elements: z.ZodArray<z.ZodObject<{
|
|
8
9
|
title: z.ZodString;
|
|
9
10
|
subtitle: z.ZodString;
|
|
@@ -45,6 +46,7 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
45
46
|
url?: string | null | undefined;
|
|
46
47
|
};
|
|
47
48
|
}[];
|
|
49
|
+
text?: string | null | undefined;
|
|
48
50
|
}, {
|
|
49
51
|
elements: {
|
|
50
52
|
title: string;
|
|
@@ -55,6 +57,7 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
55
57
|
url?: string | null | undefined;
|
|
56
58
|
};
|
|
57
59
|
}[];
|
|
60
|
+
text?: string | null | undefined;
|
|
58
61
|
}>;
|
|
59
62
|
}, "strip", z.ZodTypeAny, {
|
|
60
63
|
type: "carousel";
|
|
@@ -68,6 +71,7 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
68
71
|
url?: string | null | undefined;
|
|
69
72
|
};
|
|
70
73
|
}[];
|
|
74
|
+
text?: string | null | undefined;
|
|
71
75
|
};
|
|
72
76
|
}, {
|
|
73
77
|
type: "carousel";
|
|
@@ -81,5 +85,6 @@ export declare const CarouselSchema: z.ZodObject<{
|
|
|
81
85
|
url?: string | null | undefined;
|
|
82
86
|
};
|
|
83
87
|
}[];
|
|
88
|
+
text?: string | null | undefined;
|
|
84
89
|
};
|
|
85
90
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;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ACtC,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
|
|
@@ -64,6 +64,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
64
64
|
}>, z.ZodObject<{
|
|
65
65
|
type: z.ZodEnum<["carousel"]>;
|
|
66
66
|
content: z.ZodObject<{
|
|
67
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
68
|
elements: z.ZodArray<z.ZodObject<{
|
|
68
69
|
title: z.ZodString;
|
|
69
70
|
subtitle: z.ZodString;
|
|
@@ -105,6 +106,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
105
106
|
url?: string | null | undefined;
|
|
106
107
|
};
|
|
107
108
|
}[];
|
|
109
|
+
text?: string | null | undefined;
|
|
108
110
|
}, {
|
|
109
111
|
elements: {
|
|
110
112
|
title: string;
|
|
@@ -115,6 +117,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
115
117
|
url?: string | null | undefined;
|
|
116
118
|
};
|
|
117
119
|
}[];
|
|
120
|
+
text?: string | null | undefined;
|
|
118
121
|
}>;
|
|
119
122
|
}, "strip", z.ZodTypeAny, {
|
|
120
123
|
type: "carousel";
|
|
@@ -128,6 +131,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
128
131
|
url?: string | null | undefined;
|
|
129
132
|
};
|
|
130
133
|
}[];
|
|
134
|
+
text?: string | null | undefined;
|
|
131
135
|
};
|
|
132
136
|
}, {
|
|
133
137
|
type: "carousel";
|
|
@@ -141,6 +145,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
141
145
|
url?: string | null | undefined;
|
|
142
146
|
};
|
|
143
147
|
}[];
|
|
148
|
+
text?: string | null | undefined;
|
|
144
149
|
};
|
|
145
150
|
}>, z.ZodObject<{
|
|
146
151
|
type: z.ZodEnum<["exit"]>;
|
|
@@ -162,6 +167,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
162
167
|
url?: string | null | undefined;
|
|
163
168
|
};
|
|
164
169
|
}[];
|
|
170
|
+
text?: string | null | undefined;
|
|
165
171
|
};
|
|
166
172
|
} | {
|
|
167
173
|
type: "exit";
|
|
@@ -192,6 +198,7 @@ export declare const OutputSchema: z.ZodObject<{
|
|
|
192
198
|
url?: string | null | undefined;
|
|
193
199
|
};
|
|
194
200
|
}[];
|
|
201
|
+
text?: string | null | undefined;
|
|
195
202
|
};
|
|
196
203
|
} | {
|
|
197
204
|
type: "exit";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-ai-agents",
|
|
3
|
-
"version": "0.42.0-alpha.
|
|
3
|
+
"version": "0.42.0-alpha.4",
|
|
4
4
|
"main": "./lib/cjs/index.js",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"description": "Use AI Agents to generate your contents",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@botonic/core": "0.42.0-alpha.
|
|
16
|
+
"@botonic/core": "0.42.0-alpha.4",
|
|
17
17
|
"@openai/agents": "^0.1.11",
|
|
18
18
|
"axios": "^1.12.2",
|
|
19
19
|
"openai": "^5.23.2",
|
package/src/openai.ts
CHANGED
|
@@ -25,6 +25,7 @@ function setAzureOpenAIClient() {
|
|
|
25
25
|
apiVersion: AZURE_OPENAI_API_VERSION,
|
|
26
26
|
deployment: AZURE_OPENAI_API_DEPLOYMENT_NAME,
|
|
27
27
|
baseURL: AZURE_OPENAI_API_BASE,
|
|
28
|
+
timeout: 8000, // 8 seconds
|
|
28
29
|
dangerouslyAllowBrowser: !isProd,
|
|
29
30
|
})
|
|
30
31
|
setDefaultOpenAIClient(client)
|
package/src/runner.ts
CHANGED
|
@@ -26,23 +26,13 @@ export class AIAgentRunner<
|
|
|
26
26
|
|
|
27
27
|
async run(
|
|
28
28
|
messages: AgenticInputMessage[],
|
|
29
|
-
context: Context<TPlugins, TExtraData
|
|
30
|
-
maxRetries: number = 1
|
|
31
|
-
): Promise<RunResult> {
|
|
32
|
-
return this.runWithRetry(messages, context, maxRetries, 1)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private async runWithRetry(
|
|
36
|
-
inputMessages: AgenticInputMessage[],
|
|
37
|
-
context: Context<TPlugins, TExtraData>,
|
|
38
|
-
maxRetries: number,
|
|
39
|
-
attempt: number
|
|
29
|
+
context: Context<TPlugins, TExtraData>
|
|
40
30
|
): Promise<RunResult> {
|
|
41
31
|
try {
|
|
42
32
|
const runner = new Runner({
|
|
43
33
|
modelSettings: { temperature: 0 },
|
|
44
34
|
})
|
|
45
|
-
const result = await runner.run(this.agent,
|
|
35
|
+
const result = await runner.run(this.agent, messages, { context })
|
|
46
36
|
|
|
47
37
|
const outputMessages = result.finalOutput?.messages || []
|
|
48
38
|
const hasExit =
|
|
@@ -58,7 +48,7 @@ export class AIAgentRunner<
|
|
|
58
48
|
) as AgenticOutputMessage[]),
|
|
59
49
|
toolsExecuted,
|
|
60
50
|
exit: hasExit,
|
|
61
|
-
memoryLength:
|
|
51
|
+
memoryLength: messages.length,
|
|
62
52
|
error: false,
|
|
63
53
|
inputGuardrailsTriggered: [],
|
|
64
54
|
outputGuardrailsTriggered: [],
|
|
@@ -75,10 +65,7 @@ export class AIAgentRunner<
|
|
|
75
65
|
outputGuardrailsTriggered: [],
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
|
-
|
|
79
|
-
throw error
|
|
80
|
-
}
|
|
81
|
-
return this.runWithRetry(inputMessages, context, maxRetries, attempt + 1)
|
|
68
|
+
throw error
|
|
82
69
|
}
|
|
83
70
|
}
|
|
84
71
|
|