@aigne/core 1.58.0 → 1.58.2
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 +14 -0
- package/lib/cjs/agents/agent.d.ts +1 -1
- package/lib/cjs/agents/chat-model.d.ts +34 -33
- package/lib/cjs/agents/chat-model.js +29 -0
- package/lib/dts/agents/agent.d.ts +1 -1
- package/lib/dts/agents/chat-model.d.ts +34 -33
- package/lib/esm/agents/agent.d.ts +1 -1
- package/lib/esm/agents/chat-model.d.ts +34 -33
- package/lib/esm/agents/chat-model.js +29 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.58.2](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.58.1...core-v1.58.2) (2025-09-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **model:** transform local file to base64 before request llm ([#462](https://github.com/AIGNE-io/aigne-framework/issues/462)) ([58ef5d7](https://github.com/AIGNE-io/aigne-framework/commit/58ef5d77046c49f3c4eed15b7f0cc283cbbcd74a))
|
|
9
|
+
|
|
10
|
+
## [1.58.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.58.0...core-v1.58.1) (2025-09-05)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* should not return local path from aigne hub service ([#460](https://github.com/AIGNE-io/aigne-framework/issues/460)) ([c959717](https://github.com/AIGNE-io/aigne-framework/commit/c95971774f7e84dbeb3313f60b3e6464e2bb22e4))
|
|
16
|
+
|
|
3
17
|
## [1.58.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.57.5...core-v1.58.0) (2025-09-05)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -432,7 +432,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
432
432
|
* @param options Invocation options
|
|
433
433
|
* @returns Final processed output
|
|
434
434
|
*/
|
|
435
|
-
|
|
435
|
+
protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
|
|
436
436
|
/**
|
|
437
437
|
* Process errors that occur during agent execution
|
|
438
438
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type PromiseOrValue } from "../utils/type-utils.js";
|
|
3
|
-
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type Message } from "./agent.js";
|
|
3
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type AgentResponse, type AgentResponseStream, type Message } from "./agent.js";
|
|
4
4
|
export declare class StructuredOutputError extends Error {
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
@@ -104,6 +104,7 @@ export declare abstract class ChatModel extends Agent<ChatModelInput, ChatModelO
|
|
|
104
104
|
* @returns A promise or direct value containing the model's response
|
|
105
105
|
*/
|
|
106
106
|
abstract process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
|
|
107
|
+
protected processAgentOutput(input: ChatModelInput, output: Exclude<AgentResponse<ChatModelOutput>, AgentResponseStream<ChatModelOutput>>, options: AgentInvokeOptions): Promise<ChatModelOutput>;
|
|
107
108
|
transformFileOutput(input: ChatModelInput, data: FileUnionContent, options: AgentInvokeOptions): Promise<FileUnionContent>;
|
|
108
109
|
static getFileExtension(type: string): string | undefined;
|
|
109
110
|
static getMimeType(filename: string): string | undefined;
|
|
@@ -223,11 +224,11 @@ export declare const fileContentBaseSchema: z.ZodObject<{
|
|
|
223
224
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
224
225
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
225
226
|
}, "strip", z.ZodTypeAny, {
|
|
226
|
-
filename?: string | undefined;
|
|
227
227
|
mimeType?: string | undefined;
|
|
228
|
-
}, {
|
|
229
228
|
filename?: string | undefined;
|
|
229
|
+
}, {
|
|
230
230
|
mimeType?: string | undefined;
|
|
231
|
+
filename?: string | undefined;
|
|
231
232
|
}>;
|
|
232
233
|
/**
|
|
233
234
|
* Image URL content type
|
|
@@ -247,13 +248,13 @@ export declare const urlContentSchema: z.ZodObject<{
|
|
|
247
248
|
}, "strip", z.ZodTypeAny, {
|
|
248
249
|
type: "url";
|
|
249
250
|
url: string;
|
|
250
|
-
filename?: string | undefined;
|
|
251
251
|
mimeType?: string | undefined;
|
|
252
|
+
filename?: string | undefined;
|
|
252
253
|
}, {
|
|
253
254
|
type: "url";
|
|
254
255
|
url: string;
|
|
255
|
-
filename?: string | undefined;
|
|
256
256
|
mimeType?: string | undefined;
|
|
257
|
+
filename?: string | undefined;
|
|
257
258
|
}>;
|
|
258
259
|
export interface FileContent extends FileContentBase {
|
|
259
260
|
type: "file";
|
|
@@ -268,13 +269,13 @@ export declare const fileContentSchema: z.ZodObject<{
|
|
|
268
269
|
}, "strip", z.ZodTypeAny, {
|
|
269
270
|
type: "file";
|
|
270
271
|
data: string;
|
|
271
|
-
filename?: string | undefined;
|
|
272
272
|
mimeType?: string | undefined;
|
|
273
|
+
filename?: string | undefined;
|
|
273
274
|
}, {
|
|
274
275
|
type: "file";
|
|
275
276
|
data: string;
|
|
276
|
-
filename?: string | undefined;
|
|
277
277
|
mimeType?: string | undefined;
|
|
278
|
+
filename?: string | undefined;
|
|
278
279
|
}>;
|
|
279
280
|
export interface LocalContent extends FileContentBase {
|
|
280
281
|
type: "local";
|
|
@@ -289,13 +290,13 @@ export declare const localContentSchema: z.ZodObject<{
|
|
|
289
290
|
}, "strip", z.ZodTypeAny, {
|
|
290
291
|
path: string;
|
|
291
292
|
type: "local";
|
|
292
|
-
filename?: string | undefined;
|
|
293
293
|
mimeType?: string | undefined;
|
|
294
|
+
filename?: string | undefined;
|
|
294
295
|
}, {
|
|
295
296
|
path: string;
|
|
296
297
|
type: "local";
|
|
297
|
-
filename?: string | undefined;
|
|
298
298
|
mimeType?: string | undefined;
|
|
299
|
+
filename?: string | undefined;
|
|
299
300
|
}>;
|
|
300
301
|
export type FileUnionContent = LocalContent | UrlContent | FileContent;
|
|
301
302
|
export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -307,13 +308,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
307
308
|
}, "strip", z.ZodTypeAny, {
|
|
308
309
|
path: string;
|
|
309
310
|
type: "local";
|
|
310
|
-
filename?: string | undefined;
|
|
311
311
|
mimeType?: string | undefined;
|
|
312
|
+
filename?: string | undefined;
|
|
312
313
|
}, {
|
|
313
314
|
path: string;
|
|
314
315
|
type: "local";
|
|
315
|
-
filename?: string | undefined;
|
|
316
316
|
mimeType?: string | undefined;
|
|
317
|
+
filename?: string | undefined;
|
|
317
318
|
}>, z.ZodObject<{
|
|
318
319
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
319
320
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -323,13 +324,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
323
324
|
}, "strip", z.ZodTypeAny, {
|
|
324
325
|
type: "url";
|
|
325
326
|
url: string;
|
|
326
|
-
filename?: string | undefined;
|
|
327
327
|
mimeType?: string | undefined;
|
|
328
|
+
filename?: string | undefined;
|
|
328
329
|
}, {
|
|
329
330
|
type: "url";
|
|
330
331
|
url: string;
|
|
331
|
-
filename?: string | undefined;
|
|
332
332
|
mimeType?: string | undefined;
|
|
333
|
+
filename?: string | undefined;
|
|
333
334
|
}>, z.ZodObject<{
|
|
334
335
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
335
336
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -339,13 +340,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
339
340
|
}, "strip", z.ZodTypeAny, {
|
|
340
341
|
type: "file";
|
|
341
342
|
data: string;
|
|
342
|
-
filename?: string | undefined;
|
|
343
343
|
mimeType?: string | undefined;
|
|
344
|
+
filename?: string | undefined;
|
|
344
345
|
}, {
|
|
345
346
|
type: "file";
|
|
346
347
|
data: string;
|
|
347
|
-
filename?: string | undefined;
|
|
348
348
|
mimeType?: string | undefined;
|
|
349
|
+
filename?: string | undefined;
|
|
349
350
|
}>]>;
|
|
350
351
|
export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
351
352
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -356,13 +357,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
356
357
|
}, "strip", z.ZodTypeAny, {
|
|
357
358
|
path: string;
|
|
358
359
|
type: "local";
|
|
359
|
-
filename?: string | undefined;
|
|
360
360
|
mimeType?: string | undefined;
|
|
361
|
+
filename?: string | undefined;
|
|
361
362
|
}, {
|
|
362
363
|
path: string;
|
|
363
364
|
type: "local";
|
|
364
|
-
filename?: string | undefined;
|
|
365
365
|
mimeType?: string | undefined;
|
|
366
|
+
filename?: string | undefined;
|
|
366
367
|
}>, z.ZodObject<{
|
|
367
368
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
368
369
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -372,13 +373,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
372
373
|
}, "strip", z.ZodTypeAny, {
|
|
373
374
|
type: "url";
|
|
374
375
|
url: string;
|
|
375
|
-
filename?: string | undefined;
|
|
376
376
|
mimeType?: string | undefined;
|
|
377
|
+
filename?: string | undefined;
|
|
377
378
|
}, {
|
|
378
379
|
type: "url";
|
|
379
380
|
url: string;
|
|
380
|
-
filename?: string | undefined;
|
|
381
381
|
mimeType?: string | undefined;
|
|
382
|
+
filename?: string | undefined;
|
|
382
383
|
}>, z.ZodObject<{
|
|
383
384
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
384
385
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -388,13 +389,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
388
389
|
}, "strip", z.ZodTypeAny, {
|
|
389
390
|
type: "file";
|
|
390
391
|
data: string;
|
|
391
|
-
filename?: string | undefined;
|
|
392
392
|
mimeType?: string | undefined;
|
|
393
|
+
filename?: string | undefined;
|
|
393
394
|
}, {
|
|
394
395
|
type: "file";
|
|
395
396
|
data: string;
|
|
396
|
-
filename?: string | undefined;
|
|
397
397
|
mimeType?: string | undefined;
|
|
398
|
+
filename?: string | undefined;
|
|
398
399
|
}>]>, z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
399
400
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
400
401
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -404,13 +405,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
404
405
|
}, "strip", z.ZodTypeAny, {
|
|
405
406
|
path: string;
|
|
406
407
|
type: "local";
|
|
407
|
-
filename?: string | undefined;
|
|
408
408
|
mimeType?: string | undefined;
|
|
409
|
+
filename?: string | undefined;
|
|
409
410
|
}, {
|
|
410
411
|
path: string;
|
|
411
412
|
type: "local";
|
|
412
|
-
filename?: string | undefined;
|
|
413
413
|
mimeType?: string | undefined;
|
|
414
|
+
filename?: string | undefined;
|
|
414
415
|
}>, z.ZodObject<{
|
|
415
416
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
416
417
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -420,13 +421,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
420
421
|
}, "strip", z.ZodTypeAny, {
|
|
421
422
|
type: "url";
|
|
422
423
|
url: string;
|
|
423
|
-
filename?: string | undefined;
|
|
424
424
|
mimeType?: string | undefined;
|
|
425
|
+
filename?: string | undefined;
|
|
425
426
|
}, {
|
|
426
427
|
type: "url";
|
|
427
428
|
url: string;
|
|
428
|
-
filename?: string | undefined;
|
|
429
429
|
mimeType?: string | undefined;
|
|
430
|
+
filename?: string | undefined;
|
|
430
431
|
}>, z.ZodObject<{
|
|
431
432
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
432
433
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -436,13 +437,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
436
437
|
}, "strip", z.ZodTypeAny, {
|
|
437
438
|
type: "file";
|
|
438
439
|
data: string;
|
|
439
|
-
filename?: string | undefined;
|
|
440
440
|
mimeType?: string | undefined;
|
|
441
|
+
filename?: string | undefined;
|
|
441
442
|
}, {
|
|
442
443
|
type: "file";
|
|
443
444
|
data: string;
|
|
444
|
-
filename?: string | undefined;
|
|
445
445
|
mimeType?: string | undefined;
|
|
446
|
+
filename?: string | undefined;
|
|
446
447
|
}>]>, "many">]>;
|
|
447
448
|
export type UnionContent = TextContent | FileUnionContent;
|
|
448
449
|
export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -463,13 +464,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
463
464
|
}, "strip", z.ZodTypeAny, {
|
|
464
465
|
path: string;
|
|
465
466
|
type: "local";
|
|
466
|
-
filename?: string | undefined;
|
|
467
467
|
mimeType?: string | undefined;
|
|
468
|
+
filename?: string | undefined;
|
|
468
469
|
}, {
|
|
469
470
|
path: string;
|
|
470
471
|
type: "local";
|
|
471
|
-
filename?: string | undefined;
|
|
472
472
|
mimeType?: string | undefined;
|
|
473
|
+
filename?: string | undefined;
|
|
473
474
|
}>, z.ZodObject<{
|
|
474
475
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
475
476
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -479,13 +480,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
479
480
|
}, "strip", z.ZodTypeAny, {
|
|
480
481
|
type: "url";
|
|
481
482
|
url: string;
|
|
482
|
-
filename?: string | undefined;
|
|
483
483
|
mimeType?: string | undefined;
|
|
484
|
+
filename?: string | undefined;
|
|
484
485
|
}, {
|
|
485
486
|
type: "url";
|
|
486
487
|
url: string;
|
|
487
|
-
filename?: string | undefined;
|
|
488
488
|
mimeType?: string | undefined;
|
|
489
|
+
filename?: string | undefined;
|
|
489
490
|
}>, z.ZodObject<{
|
|
490
491
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
491
492
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -495,13 +496,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
495
496
|
}, "strip", z.ZodTypeAny, {
|
|
496
497
|
type: "file";
|
|
497
498
|
data: string;
|
|
498
|
-
filename?: string | undefined;
|
|
499
499
|
mimeType?: string | undefined;
|
|
500
|
+
filename?: string | undefined;
|
|
500
501
|
}, {
|
|
501
502
|
type: "file";
|
|
502
503
|
data: string;
|
|
503
|
-
filename?: string | undefined;
|
|
504
504
|
mimeType?: string | undefined;
|
|
505
|
+
filename?: string | undefined;
|
|
505
506
|
}>]>;
|
|
506
507
|
/**
|
|
507
508
|
* Model response format settings
|
|
@@ -173,6 +173,25 @@ class ChatModel extends agent_js_1.Agent {
|
|
|
173
173
|
enumerable: false,
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
+
input.messages = await Promise.all(input.messages.map(async (message) => {
|
|
177
|
+
if (!Array.isArray(message.content))
|
|
178
|
+
return message;
|
|
179
|
+
return {
|
|
180
|
+
...message,
|
|
181
|
+
content: await Promise.all(message.content.map(async (item) => {
|
|
182
|
+
if (item.type === "local") {
|
|
183
|
+
return {
|
|
184
|
+
...item,
|
|
185
|
+
type: "file",
|
|
186
|
+
data: await index_js_1.nodejs.fs.readFile(item.path, "base64"),
|
|
187
|
+
path: undefined,
|
|
188
|
+
mimeType: item.mimeType || ChatModel.getMimeType(item.filename || item.path),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return item;
|
|
192
|
+
})),
|
|
193
|
+
};
|
|
194
|
+
}));
|
|
176
195
|
}
|
|
177
196
|
/**
|
|
178
197
|
* Performs postprocessing operations after handling output
|
|
@@ -214,6 +233,16 @@ class ChatModel extends agent_js_1.Agent {
|
|
|
214
233
|
options.context.usage.aigneHubCredits += usage.aigneHubCredits;
|
|
215
234
|
}
|
|
216
235
|
}
|
|
236
|
+
async processAgentOutput(input, output, options) {
|
|
237
|
+
if (output.files) {
|
|
238
|
+
const files = zod_1.z.array(exports.fileUnionContentSchema).parse(output.files);
|
|
239
|
+
output = {
|
|
240
|
+
...output,
|
|
241
|
+
files: await Promise.all(files.map((file) => this.transformFileOutput(input, file, options))),
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return super.processAgentOutput(input, output, options);
|
|
245
|
+
}
|
|
217
246
|
async transformFileOutput(input, data, options) {
|
|
218
247
|
const fileOutputType = input.fileOutputType || FileOutputType.local;
|
|
219
248
|
if (fileOutputType === data.type)
|
|
@@ -432,7 +432,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
432
432
|
* @param options Invocation options
|
|
433
433
|
* @returns Final processed output
|
|
434
434
|
*/
|
|
435
|
-
|
|
435
|
+
protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
|
|
436
436
|
/**
|
|
437
437
|
* Process errors that occur during agent execution
|
|
438
438
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type PromiseOrValue } from "../utils/type-utils.js";
|
|
3
|
-
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type Message } from "./agent.js";
|
|
3
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type AgentResponse, type AgentResponseStream, type Message } from "./agent.js";
|
|
4
4
|
export declare class StructuredOutputError extends Error {
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
@@ -104,6 +104,7 @@ export declare abstract class ChatModel extends Agent<ChatModelInput, ChatModelO
|
|
|
104
104
|
* @returns A promise or direct value containing the model's response
|
|
105
105
|
*/
|
|
106
106
|
abstract process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
|
|
107
|
+
protected processAgentOutput(input: ChatModelInput, output: Exclude<AgentResponse<ChatModelOutput>, AgentResponseStream<ChatModelOutput>>, options: AgentInvokeOptions): Promise<ChatModelOutput>;
|
|
107
108
|
transformFileOutput(input: ChatModelInput, data: FileUnionContent, options: AgentInvokeOptions): Promise<FileUnionContent>;
|
|
108
109
|
static getFileExtension(type: string): string | undefined;
|
|
109
110
|
static getMimeType(filename: string): string | undefined;
|
|
@@ -223,11 +224,11 @@ export declare const fileContentBaseSchema: z.ZodObject<{
|
|
|
223
224
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
224
225
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
225
226
|
}, "strip", z.ZodTypeAny, {
|
|
226
|
-
filename?: string | undefined;
|
|
227
227
|
mimeType?: string | undefined;
|
|
228
|
-
}, {
|
|
229
228
|
filename?: string | undefined;
|
|
229
|
+
}, {
|
|
230
230
|
mimeType?: string | undefined;
|
|
231
|
+
filename?: string | undefined;
|
|
231
232
|
}>;
|
|
232
233
|
/**
|
|
233
234
|
* Image URL content type
|
|
@@ -247,13 +248,13 @@ export declare const urlContentSchema: z.ZodObject<{
|
|
|
247
248
|
}, "strip", z.ZodTypeAny, {
|
|
248
249
|
type: "url";
|
|
249
250
|
url: string;
|
|
250
|
-
filename?: string | undefined;
|
|
251
251
|
mimeType?: string | undefined;
|
|
252
|
+
filename?: string | undefined;
|
|
252
253
|
}, {
|
|
253
254
|
type: "url";
|
|
254
255
|
url: string;
|
|
255
|
-
filename?: string | undefined;
|
|
256
256
|
mimeType?: string | undefined;
|
|
257
|
+
filename?: string | undefined;
|
|
257
258
|
}>;
|
|
258
259
|
export interface FileContent extends FileContentBase {
|
|
259
260
|
type: "file";
|
|
@@ -268,13 +269,13 @@ export declare const fileContentSchema: z.ZodObject<{
|
|
|
268
269
|
}, "strip", z.ZodTypeAny, {
|
|
269
270
|
type: "file";
|
|
270
271
|
data: string;
|
|
271
|
-
filename?: string | undefined;
|
|
272
272
|
mimeType?: string | undefined;
|
|
273
|
+
filename?: string | undefined;
|
|
273
274
|
}, {
|
|
274
275
|
type: "file";
|
|
275
276
|
data: string;
|
|
276
|
-
filename?: string | undefined;
|
|
277
277
|
mimeType?: string | undefined;
|
|
278
|
+
filename?: string | undefined;
|
|
278
279
|
}>;
|
|
279
280
|
export interface LocalContent extends FileContentBase {
|
|
280
281
|
type: "local";
|
|
@@ -289,13 +290,13 @@ export declare const localContentSchema: z.ZodObject<{
|
|
|
289
290
|
}, "strip", z.ZodTypeAny, {
|
|
290
291
|
path: string;
|
|
291
292
|
type: "local";
|
|
292
|
-
filename?: string | undefined;
|
|
293
293
|
mimeType?: string | undefined;
|
|
294
|
+
filename?: string | undefined;
|
|
294
295
|
}, {
|
|
295
296
|
path: string;
|
|
296
297
|
type: "local";
|
|
297
|
-
filename?: string | undefined;
|
|
298
298
|
mimeType?: string | undefined;
|
|
299
|
+
filename?: string | undefined;
|
|
299
300
|
}>;
|
|
300
301
|
export type FileUnionContent = LocalContent | UrlContent | FileContent;
|
|
301
302
|
export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -307,13 +308,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
307
308
|
}, "strip", z.ZodTypeAny, {
|
|
308
309
|
path: string;
|
|
309
310
|
type: "local";
|
|
310
|
-
filename?: string | undefined;
|
|
311
311
|
mimeType?: string | undefined;
|
|
312
|
+
filename?: string | undefined;
|
|
312
313
|
}, {
|
|
313
314
|
path: string;
|
|
314
315
|
type: "local";
|
|
315
|
-
filename?: string | undefined;
|
|
316
316
|
mimeType?: string | undefined;
|
|
317
|
+
filename?: string | undefined;
|
|
317
318
|
}>, z.ZodObject<{
|
|
318
319
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
319
320
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -323,13 +324,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
323
324
|
}, "strip", z.ZodTypeAny, {
|
|
324
325
|
type: "url";
|
|
325
326
|
url: string;
|
|
326
|
-
filename?: string | undefined;
|
|
327
327
|
mimeType?: string | undefined;
|
|
328
|
+
filename?: string | undefined;
|
|
328
329
|
}, {
|
|
329
330
|
type: "url";
|
|
330
331
|
url: string;
|
|
331
|
-
filename?: string | undefined;
|
|
332
332
|
mimeType?: string | undefined;
|
|
333
|
+
filename?: string | undefined;
|
|
333
334
|
}>, z.ZodObject<{
|
|
334
335
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
335
336
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -339,13 +340,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
339
340
|
}, "strip", z.ZodTypeAny, {
|
|
340
341
|
type: "file";
|
|
341
342
|
data: string;
|
|
342
|
-
filename?: string | undefined;
|
|
343
343
|
mimeType?: string | undefined;
|
|
344
|
+
filename?: string | undefined;
|
|
344
345
|
}, {
|
|
345
346
|
type: "file";
|
|
346
347
|
data: string;
|
|
347
|
-
filename?: string | undefined;
|
|
348
348
|
mimeType?: string | undefined;
|
|
349
|
+
filename?: string | undefined;
|
|
349
350
|
}>]>;
|
|
350
351
|
export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
351
352
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -356,13 +357,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
356
357
|
}, "strip", z.ZodTypeAny, {
|
|
357
358
|
path: string;
|
|
358
359
|
type: "local";
|
|
359
|
-
filename?: string | undefined;
|
|
360
360
|
mimeType?: string | undefined;
|
|
361
|
+
filename?: string | undefined;
|
|
361
362
|
}, {
|
|
362
363
|
path: string;
|
|
363
364
|
type: "local";
|
|
364
|
-
filename?: string | undefined;
|
|
365
365
|
mimeType?: string | undefined;
|
|
366
|
+
filename?: string | undefined;
|
|
366
367
|
}>, z.ZodObject<{
|
|
367
368
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
368
369
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -372,13 +373,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
372
373
|
}, "strip", z.ZodTypeAny, {
|
|
373
374
|
type: "url";
|
|
374
375
|
url: string;
|
|
375
|
-
filename?: string | undefined;
|
|
376
376
|
mimeType?: string | undefined;
|
|
377
|
+
filename?: string | undefined;
|
|
377
378
|
}, {
|
|
378
379
|
type: "url";
|
|
379
380
|
url: string;
|
|
380
|
-
filename?: string | undefined;
|
|
381
381
|
mimeType?: string | undefined;
|
|
382
|
+
filename?: string | undefined;
|
|
382
383
|
}>, z.ZodObject<{
|
|
383
384
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
384
385
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -388,13 +389,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
388
389
|
}, "strip", z.ZodTypeAny, {
|
|
389
390
|
type: "file";
|
|
390
391
|
data: string;
|
|
391
|
-
filename?: string | undefined;
|
|
392
392
|
mimeType?: string | undefined;
|
|
393
|
+
filename?: string | undefined;
|
|
393
394
|
}, {
|
|
394
395
|
type: "file";
|
|
395
396
|
data: string;
|
|
396
|
-
filename?: string | undefined;
|
|
397
397
|
mimeType?: string | undefined;
|
|
398
|
+
filename?: string | undefined;
|
|
398
399
|
}>]>, z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
399
400
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
400
401
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -404,13 +405,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
404
405
|
}, "strip", z.ZodTypeAny, {
|
|
405
406
|
path: string;
|
|
406
407
|
type: "local";
|
|
407
|
-
filename?: string | undefined;
|
|
408
408
|
mimeType?: string | undefined;
|
|
409
|
+
filename?: string | undefined;
|
|
409
410
|
}, {
|
|
410
411
|
path: string;
|
|
411
412
|
type: "local";
|
|
412
|
-
filename?: string | undefined;
|
|
413
413
|
mimeType?: string | undefined;
|
|
414
|
+
filename?: string | undefined;
|
|
414
415
|
}>, z.ZodObject<{
|
|
415
416
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
416
417
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -420,13 +421,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
420
421
|
}, "strip", z.ZodTypeAny, {
|
|
421
422
|
type: "url";
|
|
422
423
|
url: string;
|
|
423
|
-
filename?: string | undefined;
|
|
424
424
|
mimeType?: string | undefined;
|
|
425
|
+
filename?: string | undefined;
|
|
425
426
|
}, {
|
|
426
427
|
type: "url";
|
|
427
428
|
url: string;
|
|
428
|
-
filename?: string | undefined;
|
|
429
429
|
mimeType?: string | undefined;
|
|
430
|
+
filename?: string | undefined;
|
|
430
431
|
}>, z.ZodObject<{
|
|
431
432
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
432
433
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -436,13 +437,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
436
437
|
}, "strip", z.ZodTypeAny, {
|
|
437
438
|
type: "file";
|
|
438
439
|
data: string;
|
|
439
|
-
filename?: string | undefined;
|
|
440
440
|
mimeType?: string | undefined;
|
|
441
|
+
filename?: string | undefined;
|
|
441
442
|
}, {
|
|
442
443
|
type: "file";
|
|
443
444
|
data: string;
|
|
444
|
-
filename?: string | undefined;
|
|
445
445
|
mimeType?: string | undefined;
|
|
446
|
+
filename?: string | undefined;
|
|
446
447
|
}>]>, "many">]>;
|
|
447
448
|
export type UnionContent = TextContent | FileUnionContent;
|
|
448
449
|
export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -463,13 +464,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
463
464
|
}, "strip", z.ZodTypeAny, {
|
|
464
465
|
path: string;
|
|
465
466
|
type: "local";
|
|
466
|
-
filename?: string | undefined;
|
|
467
467
|
mimeType?: string | undefined;
|
|
468
|
+
filename?: string | undefined;
|
|
468
469
|
}, {
|
|
469
470
|
path: string;
|
|
470
471
|
type: "local";
|
|
471
|
-
filename?: string | undefined;
|
|
472
472
|
mimeType?: string | undefined;
|
|
473
|
+
filename?: string | undefined;
|
|
473
474
|
}>, z.ZodObject<{
|
|
474
475
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
475
476
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -479,13 +480,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
479
480
|
}, "strip", z.ZodTypeAny, {
|
|
480
481
|
type: "url";
|
|
481
482
|
url: string;
|
|
482
|
-
filename?: string | undefined;
|
|
483
483
|
mimeType?: string | undefined;
|
|
484
|
+
filename?: string | undefined;
|
|
484
485
|
}, {
|
|
485
486
|
type: "url";
|
|
486
487
|
url: string;
|
|
487
|
-
filename?: string | undefined;
|
|
488
488
|
mimeType?: string | undefined;
|
|
489
|
+
filename?: string | undefined;
|
|
489
490
|
}>, z.ZodObject<{
|
|
490
491
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
491
492
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -495,13 +496,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
495
496
|
}, "strip", z.ZodTypeAny, {
|
|
496
497
|
type: "file";
|
|
497
498
|
data: string;
|
|
498
|
-
filename?: string | undefined;
|
|
499
499
|
mimeType?: string | undefined;
|
|
500
|
+
filename?: string | undefined;
|
|
500
501
|
}, {
|
|
501
502
|
type: "file";
|
|
502
503
|
data: string;
|
|
503
|
-
filename?: string | undefined;
|
|
504
504
|
mimeType?: string | undefined;
|
|
505
|
+
filename?: string | undefined;
|
|
505
506
|
}>]>;
|
|
506
507
|
/**
|
|
507
508
|
* Model response format settings
|
|
@@ -432,7 +432,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
432
432
|
* @param options Invocation options
|
|
433
433
|
* @returns Final processed output
|
|
434
434
|
*/
|
|
435
|
-
|
|
435
|
+
protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
|
|
436
436
|
/**
|
|
437
437
|
* Process errors that occur during agent execution
|
|
438
438
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type PromiseOrValue } from "../utils/type-utils.js";
|
|
3
|
-
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type Message } from "./agent.js";
|
|
3
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type AgentResponse, type AgentResponseStream, type Message } from "./agent.js";
|
|
4
4
|
export declare class StructuredOutputError extends Error {
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
@@ -104,6 +104,7 @@ export declare abstract class ChatModel extends Agent<ChatModelInput, ChatModelO
|
|
|
104
104
|
* @returns A promise or direct value containing the model's response
|
|
105
105
|
*/
|
|
106
106
|
abstract process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
|
|
107
|
+
protected processAgentOutput(input: ChatModelInput, output: Exclude<AgentResponse<ChatModelOutput>, AgentResponseStream<ChatModelOutput>>, options: AgentInvokeOptions): Promise<ChatModelOutput>;
|
|
107
108
|
transformFileOutput(input: ChatModelInput, data: FileUnionContent, options: AgentInvokeOptions): Promise<FileUnionContent>;
|
|
108
109
|
static getFileExtension(type: string): string | undefined;
|
|
109
110
|
static getMimeType(filename: string): string | undefined;
|
|
@@ -223,11 +224,11 @@ export declare const fileContentBaseSchema: z.ZodObject<{
|
|
|
223
224
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
224
225
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
225
226
|
}, "strip", z.ZodTypeAny, {
|
|
226
|
-
filename?: string | undefined;
|
|
227
227
|
mimeType?: string | undefined;
|
|
228
|
-
}, {
|
|
229
228
|
filename?: string | undefined;
|
|
229
|
+
}, {
|
|
230
230
|
mimeType?: string | undefined;
|
|
231
|
+
filename?: string | undefined;
|
|
231
232
|
}>;
|
|
232
233
|
/**
|
|
233
234
|
* Image URL content type
|
|
@@ -247,13 +248,13 @@ export declare const urlContentSchema: z.ZodObject<{
|
|
|
247
248
|
}, "strip", z.ZodTypeAny, {
|
|
248
249
|
type: "url";
|
|
249
250
|
url: string;
|
|
250
|
-
filename?: string | undefined;
|
|
251
251
|
mimeType?: string | undefined;
|
|
252
|
+
filename?: string | undefined;
|
|
252
253
|
}, {
|
|
253
254
|
type: "url";
|
|
254
255
|
url: string;
|
|
255
|
-
filename?: string | undefined;
|
|
256
256
|
mimeType?: string | undefined;
|
|
257
|
+
filename?: string | undefined;
|
|
257
258
|
}>;
|
|
258
259
|
export interface FileContent extends FileContentBase {
|
|
259
260
|
type: "file";
|
|
@@ -268,13 +269,13 @@ export declare const fileContentSchema: z.ZodObject<{
|
|
|
268
269
|
}, "strip", z.ZodTypeAny, {
|
|
269
270
|
type: "file";
|
|
270
271
|
data: string;
|
|
271
|
-
filename?: string | undefined;
|
|
272
272
|
mimeType?: string | undefined;
|
|
273
|
+
filename?: string | undefined;
|
|
273
274
|
}, {
|
|
274
275
|
type: "file";
|
|
275
276
|
data: string;
|
|
276
|
-
filename?: string | undefined;
|
|
277
277
|
mimeType?: string | undefined;
|
|
278
|
+
filename?: string | undefined;
|
|
278
279
|
}>;
|
|
279
280
|
export interface LocalContent extends FileContentBase {
|
|
280
281
|
type: "local";
|
|
@@ -289,13 +290,13 @@ export declare const localContentSchema: z.ZodObject<{
|
|
|
289
290
|
}, "strip", z.ZodTypeAny, {
|
|
290
291
|
path: string;
|
|
291
292
|
type: "local";
|
|
292
|
-
filename?: string | undefined;
|
|
293
293
|
mimeType?: string | undefined;
|
|
294
|
+
filename?: string | undefined;
|
|
294
295
|
}, {
|
|
295
296
|
path: string;
|
|
296
297
|
type: "local";
|
|
297
|
-
filename?: string | undefined;
|
|
298
298
|
mimeType?: string | undefined;
|
|
299
|
+
filename?: string | undefined;
|
|
299
300
|
}>;
|
|
300
301
|
export type FileUnionContent = LocalContent | UrlContent | FileContent;
|
|
301
302
|
export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -307,13 +308,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
307
308
|
}, "strip", z.ZodTypeAny, {
|
|
308
309
|
path: string;
|
|
309
310
|
type: "local";
|
|
310
|
-
filename?: string | undefined;
|
|
311
311
|
mimeType?: string | undefined;
|
|
312
|
+
filename?: string | undefined;
|
|
312
313
|
}, {
|
|
313
314
|
path: string;
|
|
314
315
|
type: "local";
|
|
315
|
-
filename?: string | undefined;
|
|
316
316
|
mimeType?: string | undefined;
|
|
317
|
+
filename?: string | undefined;
|
|
317
318
|
}>, z.ZodObject<{
|
|
318
319
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
319
320
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -323,13 +324,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
323
324
|
}, "strip", z.ZodTypeAny, {
|
|
324
325
|
type: "url";
|
|
325
326
|
url: string;
|
|
326
|
-
filename?: string | undefined;
|
|
327
327
|
mimeType?: string | undefined;
|
|
328
|
+
filename?: string | undefined;
|
|
328
329
|
}, {
|
|
329
330
|
type: "url";
|
|
330
331
|
url: string;
|
|
331
|
-
filename?: string | undefined;
|
|
332
332
|
mimeType?: string | undefined;
|
|
333
|
+
filename?: string | undefined;
|
|
333
334
|
}>, z.ZodObject<{
|
|
334
335
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
335
336
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -339,13 +340,13 @@ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
339
340
|
}, "strip", z.ZodTypeAny, {
|
|
340
341
|
type: "file";
|
|
341
342
|
data: string;
|
|
342
|
-
filename?: string | undefined;
|
|
343
343
|
mimeType?: string | undefined;
|
|
344
|
+
filename?: string | undefined;
|
|
344
345
|
}, {
|
|
345
346
|
type: "file";
|
|
346
347
|
data: string;
|
|
347
|
-
filename?: string | undefined;
|
|
348
348
|
mimeType?: string | undefined;
|
|
349
|
+
filename?: string | undefined;
|
|
349
350
|
}>]>;
|
|
350
351
|
export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
351
352
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -356,13 +357,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
356
357
|
}, "strip", z.ZodTypeAny, {
|
|
357
358
|
path: string;
|
|
358
359
|
type: "local";
|
|
359
|
-
filename?: string | undefined;
|
|
360
360
|
mimeType?: string | undefined;
|
|
361
|
+
filename?: string | undefined;
|
|
361
362
|
}, {
|
|
362
363
|
path: string;
|
|
363
364
|
type: "local";
|
|
364
|
-
filename?: string | undefined;
|
|
365
365
|
mimeType?: string | undefined;
|
|
366
|
+
filename?: string | undefined;
|
|
366
367
|
}>, z.ZodObject<{
|
|
367
368
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
368
369
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -372,13 +373,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
372
373
|
}, "strip", z.ZodTypeAny, {
|
|
373
374
|
type: "url";
|
|
374
375
|
url: string;
|
|
375
|
-
filename?: string | undefined;
|
|
376
376
|
mimeType?: string | undefined;
|
|
377
|
+
filename?: string | undefined;
|
|
377
378
|
}, {
|
|
378
379
|
type: "url";
|
|
379
380
|
url: string;
|
|
380
|
-
filename?: string | undefined;
|
|
381
381
|
mimeType?: string | undefined;
|
|
382
|
+
filename?: string | undefined;
|
|
382
383
|
}>, z.ZodObject<{
|
|
383
384
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
384
385
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -388,13 +389,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
388
389
|
}, "strip", z.ZodTypeAny, {
|
|
389
390
|
type: "file";
|
|
390
391
|
data: string;
|
|
391
|
-
filename?: string | undefined;
|
|
392
392
|
mimeType?: string | undefined;
|
|
393
|
+
filename?: string | undefined;
|
|
393
394
|
}, {
|
|
394
395
|
type: "file";
|
|
395
396
|
data: string;
|
|
396
|
-
filename?: string | undefined;
|
|
397
397
|
mimeType?: string | undefined;
|
|
398
|
+
filename?: string | undefined;
|
|
398
399
|
}>]>, z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
399
400
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
400
401
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -404,13 +405,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
404
405
|
}, "strip", z.ZodTypeAny, {
|
|
405
406
|
path: string;
|
|
406
407
|
type: "local";
|
|
407
|
-
filename?: string | undefined;
|
|
408
408
|
mimeType?: string | undefined;
|
|
409
|
+
filename?: string | undefined;
|
|
409
410
|
}, {
|
|
410
411
|
path: string;
|
|
411
412
|
type: "local";
|
|
412
|
-
filename?: string | undefined;
|
|
413
413
|
mimeType?: string | undefined;
|
|
414
|
+
filename?: string | undefined;
|
|
414
415
|
}>, z.ZodObject<{
|
|
415
416
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
416
417
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -420,13 +421,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
420
421
|
}, "strip", z.ZodTypeAny, {
|
|
421
422
|
type: "url";
|
|
422
423
|
url: string;
|
|
423
|
-
filename?: string | undefined;
|
|
424
424
|
mimeType?: string | undefined;
|
|
425
|
+
filename?: string | undefined;
|
|
425
426
|
}, {
|
|
426
427
|
type: "url";
|
|
427
428
|
url: string;
|
|
428
|
-
filename?: string | undefined;
|
|
429
429
|
mimeType?: string | undefined;
|
|
430
|
+
filename?: string | undefined;
|
|
430
431
|
}>, z.ZodObject<{
|
|
431
432
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
432
433
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -436,13 +437,13 @@ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnio
|
|
|
436
437
|
}, "strip", z.ZodTypeAny, {
|
|
437
438
|
type: "file";
|
|
438
439
|
data: string;
|
|
439
|
-
filename?: string | undefined;
|
|
440
440
|
mimeType?: string | undefined;
|
|
441
|
+
filename?: string | undefined;
|
|
441
442
|
}, {
|
|
442
443
|
type: "file";
|
|
443
444
|
data: string;
|
|
444
|
-
filename?: string | undefined;
|
|
445
445
|
mimeType?: string | undefined;
|
|
446
|
+
filename?: string | undefined;
|
|
446
447
|
}>]>, "many">]>;
|
|
447
448
|
export type UnionContent = TextContent | FileUnionContent;
|
|
448
449
|
export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -463,13 +464,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
463
464
|
}, "strip", z.ZodTypeAny, {
|
|
464
465
|
path: string;
|
|
465
466
|
type: "local";
|
|
466
|
-
filename?: string | undefined;
|
|
467
467
|
mimeType?: string | undefined;
|
|
468
|
+
filename?: string | undefined;
|
|
468
469
|
}, {
|
|
469
470
|
path: string;
|
|
470
471
|
type: "local";
|
|
471
|
-
filename?: string | undefined;
|
|
472
472
|
mimeType?: string | undefined;
|
|
473
|
+
filename?: string | undefined;
|
|
473
474
|
}>, z.ZodObject<{
|
|
474
475
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
475
476
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -479,13 +480,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
479
480
|
}, "strip", z.ZodTypeAny, {
|
|
480
481
|
type: "url";
|
|
481
482
|
url: string;
|
|
482
|
-
filename?: string | undefined;
|
|
483
483
|
mimeType?: string | undefined;
|
|
484
|
+
filename?: string | undefined;
|
|
484
485
|
}, {
|
|
485
486
|
type: "url";
|
|
486
487
|
url: string;
|
|
487
|
-
filename?: string | undefined;
|
|
488
488
|
mimeType?: string | undefined;
|
|
489
|
+
filename?: string | undefined;
|
|
489
490
|
}>, z.ZodObject<{
|
|
490
491
|
filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
491
492
|
mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
@@ -495,13 +496,13 @@ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
495
496
|
}, "strip", z.ZodTypeAny, {
|
|
496
497
|
type: "file";
|
|
497
498
|
data: string;
|
|
498
|
-
filename?: string | undefined;
|
|
499
499
|
mimeType?: string | undefined;
|
|
500
|
+
filename?: string | undefined;
|
|
500
501
|
}, {
|
|
501
502
|
type: "file";
|
|
502
503
|
data: string;
|
|
503
|
-
filename?: string | undefined;
|
|
504
504
|
mimeType?: string | undefined;
|
|
505
|
+
filename?: string | undefined;
|
|
505
506
|
}>]>;
|
|
506
507
|
/**
|
|
507
508
|
* Model response format settings
|
|
@@ -133,6 +133,25 @@ export class ChatModel extends Agent {
|
|
|
133
133
|
enumerable: false,
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
+
input.messages = await Promise.all(input.messages.map(async (message) => {
|
|
137
|
+
if (!Array.isArray(message.content))
|
|
138
|
+
return message;
|
|
139
|
+
return {
|
|
140
|
+
...message,
|
|
141
|
+
content: await Promise.all(message.content.map(async (item) => {
|
|
142
|
+
if (item.type === "local") {
|
|
143
|
+
return {
|
|
144
|
+
...item,
|
|
145
|
+
type: "file",
|
|
146
|
+
data: await nodejs.fs.readFile(item.path, "base64"),
|
|
147
|
+
path: undefined,
|
|
148
|
+
mimeType: item.mimeType || ChatModel.getMimeType(item.filename || item.path),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return item;
|
|
152
|
+
})),
|
|
153
|
+
};
|
|
154
|
+
}));
|
|
136
155
|
}
|
|
137
156
|
/**
|
|
138
157
|
* Performs postprocessing operations after handling output
|
|
@@ -174,6 +193,16 @@ export class ChatModel extends Agent {
|
|
|
174
193
|
options.context.usage.aigneHubCredits += usage.aigneHubCredits;
|
|
175
194
|
}
|
|
176
195
|
}
|
|
196
|
+
async processAgentOutput(input, output, options) {
|
|
197
|
+
if (output.files) {
|
|
198
|
+
const files = z.array(fileUnionContentSchema).parse(output.files);
|
|
199
|
+
output = {
|
|
200
|
+
...output,
|
|
201
|
+
files: await Promise.all(files.map((file) => this.transformFileOutput(input, file, options))),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return super.processAgentOutput(input, output, options);
|
|
205
|
+
}
|
|
177
206
|
async transformFileOutput(input, data, options) {
|
|
178
207
|
const fileOutputType = input.fileOutputType || FileOutputType.local;
|
|
179
208
|
if (fileOutputType === data.type)
|