@voltagent/core 0.1.9 → 0.1.10
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/dist/index.js +98 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -790,11 +790,17 @@ var AgentResponseSchema = import_zod.z.object({
|
|
|
790
790
|
}).passthrough();
|
|
791
791
|
var GenerateOptionsSchema = import_zod.z.object({
|
|
792
792
|
userId: import_zod.z.string().optional().openapi({ description: "Optional user ID for context tracking" }),
|
|
793
|
-
conversationId: import_zod.z.string().optional().openapi({
|
|
794
|
-
|
|
793
|
+
conversationId: import_zod.z.string().optional().openapi({
|
|
794
|
+
description: "Optional conversation ID for context tracking"
|
|
795
|
+
}),
|
|
796
|
+
contextLimit: import_zod.z.number().int().positive().optional().default(10).openapi({
|
|
797
|
+
description: "Optional limit for conversation history context"
|
|
798
|
+
}),
|
|
795
799
|
temperature: import_zod.z.number().min(0).max(1).optional().default(0.7).openapi({ description: "Controls randomness (0-1)" }),
|
|
796
|
-
maxTokens: import_zod.z.number().int().positive().optional().default(
|
|
797
|
-
topP: import_zod.z.number().min(0).max(1).optional().default(1).openapi({
|
|
800
|
+
maxTokens: import_zod.z.number().int().positive().optional().default(4e3).openapi({ description: "Maximum tokens to generate" }),
|
|
801
|
+
topP: import_zod.z.number().min(0).max(1).optional().default(1).openapi({
|
|
802
|
+
description: "Controls diversity via nucleus sampling (0-1)"
|
|
803
|
+
}),
|
|
798
804
|
frequencyPenalty: import_zod.z.number().min(0).max(2).optional().default(0).openapi({ description: "Penalizes repeated tokens (0-2)" }),
|
|
799
805
|
presencePenalty: import_zod.z.number().min(0).max(2).optional().default(0).openapi({ description: "Penalizes tokens based on presence (0-2)" }),
|
|
800
806
|
seed: import_zod.z.number().int().optional().openapi({ description: "Optional seed for reproducible results" }),
|
|
@@ -802,13 +808,72 @@ var GenerateOptionsSchema = import_zod.z.object({
|
|
|
802
808
|
extraOptions: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().openapi({ description: "Provider-specific options" })
|
|
803
809
|
// Add other relevant options from PublicGenerateOptions if known/needed for API exposure
|
|
804
810
|
}).passthrough();
|
|
811
|
+
var ContentPartSchema = import_zod.z.union([
|
|
812
|
+
import_zod.z.object({
|
|
813
|
+
// Text part
|
|
814
|
+
type: import_zod.z.literal("text"),
|
|
815
|
+
text: import_zod.z.string()
|
|
816
|
+
}).openapi({ example: { type: "text", text: "Hello there!" } }),
|
|
817
|
+
import_zod.z.object({
|
|
818
|
+
// Image part
|
|
819
|
+
type: import_zod.z.literal("image"),
|
|
820
|
+
image: import_zod.z.string().openapi({ description: "Base64 encoded image data or a URL" }),
|
|
821
|
+
mimeType: import_zod.z.string().optional().openapi({ example: "image/jpeg" }),
|
|
822
|
+
alt: import_zod.z.string().optional().openapi({ description: "Alternative text for the image" })
|
|
823
|
+
}).openapi({
|
|
824
|
+
example: {
|
|
825
|
+
type: "image",
|
|
826
|
+
image: "data:image/png;base64,...",
|
|
827
|
+
mimeType: "image/png"
|
|
828
|
+
}
|
|
829
|
+
}),
|
|
830
|
+
import_zod.z.object({
|
|
831
|
+
// File part
|
|
832
|
+
type: import_zod.z.literal("file"),
|
|
833
|
+
data: import_zod.z.string().openapi({ description: "Base64 encoded file data" }),
|
|
834
|
+
filename: import_zod.z.string().openapi({ example: "document.pdf" }),
|
|
835
|
+
mimeType: import_zod.z.string().openapi({ example: "application/pdf" }),
|
|
836
|
+
size: import_zod.z.number().optional().openapi({ description: "File size in bytes" })
|
|
837
|
+
}).openapi({
|
|
838
|
+
example: {
|
|
839
|
+
type: "file",
|
|
840
|
+
data: "...",
|
|
841
|
+
filename: "report.docx",
|
|
842
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
843
|
+
}
|
|
844
|
+
})
|
|
845
|
+
]);
|
|
846
|
+
var MessageContentSchema = import_zod.z.union([
|
|
847
|
+
import_zod.z.string().openapi({ description: "Plain text content" }),
|
|
848
|
+
import_zod.z.array(ContentPartSchema).openapi({ description: "An array of content parts (text, image, file)." })
|
|
849
|
+
]);
|
|
850
|
+
var MessageObjectSchema = import_zod.z.object({
|
|
851
|
+
role: import_zod.z.string().openapi({
|
|
852
|
+
description: "Role of the sender (e.g., 'user', 'assistant')"
|
|
853
|
+
}),
|
|
854
|
+
content: MessageContentSchema
|
|
855
|
+
// Use the reusable content schema
|
|
856
|
+
}).openapi({ description: "A message object with role and content" });
|
|
805
857
|
var TextRequestSchema = import_zod.z.object({
|
|
806
|
-
input: import_zod.z.
|
|
858
|
+
input: import_zod.z.union([
|
|
859
|
+
import_zod.z.string().openapi({
|
|
860
|
+
description: "Input text for the agent",
|
|
861
|
+
example: "Tell me a joke!"
|
|
862
|
+
}),
|
|
863
|
+
import_zod.z.array(MessageObjectSchema).openapi({
|
|
864
|
+
description: "An array of message objects, representing the conversation history",
|
|
865
|
+
example: [
|
|
866
|
+
{ role: "user", content: "What is the weather?" },
|
|
867
|
+
{ role: "assistant", content: "The weather is sunny." },
|
|
868
|
+
{ role: "user", content: [{ type: "text", text: "Thanks!" }] }
|
|
869
|
+
]
|
|
870
|
+
})
|
|
871
|
+
]),
|
|
807
872
|
options: GenerateOptionsSchema.optional().openapi({
|
|
808
|
-
description: "Optional generation parameters"
|
|
873
|
+
description: "Optional generation parameters",
|
|
874
|
+
example: { temperature: 0.7, maxTokens: 100 }
|
|
809
875
|
})
|
|
810
|
-
|
|
811
|
-
});
|
|
876
|
+
}).openapi("TextGenerationRequest");
|
|
812
877
|
var TextResponseSchema = import_zod.z.object({
|
|
813
878
|
success: import_zod.z.literal(true),
|
|
814
879
|
data: import_zod.z.string().openapi({ description: "Generated text response" })
|
|
@@ -822,34 +887,18 @@ var StreamTextEventSchema = import_zod.z.object({
|
|
|
822
887
|
error: import_zod.z.string().optional()
|
|
823
888
|
});
|
|
824
889
|
var ObjectRequestSchema = import_zod.z.object({
|
|
825
|
-
input: import_zod.z.
|
|
826
|
-
|
|
827
|
-
description: "
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
joke_setup: {
|
|
832
|
-
type: "string",
|
|
833
|
-
description: "The setup part of the joke"
|
|
834
|
-
},
|
|
835
|
-
punchline: {
|
|
836
|
-
type: "string",
|
|
837
|
-
description: "The punchline of the joke"
|
|
838
|
-
},
|
|
839
|
-
rating: {
|
|
840
|
-
type: "number",
|
|
841
|
-
description: "A rating of how funny the joke is from 1 to 5"
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
required: ["joke_setup", "punchline"]
|
|
845
|
-
}
|
|
890
|
+
input: import_zod.z.union([
|
|
891
|
+
import_zod.z.string().openapi({ description: "Input text prompt" }),
|
|
892
|
+
import_zod.z.array(MessageObjectSchema).openapi({ description: "Conversation history" })
|
|
893
|
+
]),
|
|
894
|
+
schema: import_zod.z.any().openapi({
|
|
895
|
+
description: "The Zod schema for the desired object output (passed as JSON)"
|
|
846
896
|
}),
|
|
847
|
-
// Expect a JSON Schema object
|
|
848
897
|
options: GenerateOptionsSchema.optional().openapi({
|
|
849
|
-
description: "Optional generation parameters"
|
|
898
|
+
description: "Optional object generation parameters",
|
|
899
|
+
example: { temperature: 0.2 }
|
|
850
900
|
})
|
|
851
|
-
|
|
852
|
-
});
|
|
901
|
+
}).openapi("ObjectGenerationRequest");
|
|
853
902
|
var ObjectResponseSchema = import_zod.z.object({
|
|
854
903
|
success: import_zod.z.literal(true),
|
|
855
904
|
data: import_zod.z.object({}).passthrough().openapi({ description: "Generated object response" })
|
|
@@ -1290,12 +1339,23 @@ app.openapi(streamRoute, (c) => __async(void 0, null, function* () {
|
|
|
1290
1339
|
}
|
|
1291
1340
|
try {
|
|
1292
1341
|
let _a;
|
|
1293
|
-
const {
|
|
1342
|
+
const {
|
|
1343
|
+
input,
|
|
1344
|
+
options = {
|
|
1345
|
+
maxTokens: 4e3,
|
|
1346
|
+
temperature: 0.7
|
|
1347
|
+
}
|
|
1348
|
+
} = c.req.valid("json");
|
|
1294
1349
|
const stream = new ReadableStream({
|
|
1295
1350
|
start(controller) {
|
|
1296
1351
|
return __async(this, null, function* () {
|
|
1297
1352
|
try {
|
|
1298
|
-
const response = yield agent.streamText(input, __spreadValues({}, options)
|
|
1353
|
+
const response = yield agent.streamText(input, __spreadProps(__spreadValues({}, options), {
|
|
1354
|
+
provider: {
|
|
1355
|
+
maxTokens: options.maxTokens,
|
|
1356
|
+
temperature: options.temperature
|
|
1357
|
+
}
|
|
1358
|
+
}));
|
|
1299
1359
|
try {
|
|
1300
1360
|
for (var iter = __forAwait(response.textStream), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
|
|
1301
1361
|
const chunk = temp.value;
|
|
@@ -5180,6 +5240,7 @@ ${context}`;
|
|
|
5180
5240
|
maxSteps,
|
|
5181
5241
|
tools,
|
|
5182
5242
|
signal,
|
|
5243
|
+
provider,
|
|
5183
5244
|
toolExecutionContext: {
|
|
5184
5245
|
operationContext,
|
|
5185
5246
|
agentId: this.id,
|
|
@@ -5383,6 +5444,7 @@ ${context}`;
|
|
|
5383
5444
|
model: this.model,
|
|
5384
5445
|
schema,
|
|
5385
5446
|
signal,
|
|
5447
|
+
provider,
|
|
5386
5448
|
toolExecutionContext: {
|
|
5387
5449
|
operationContext,
|
|
5388
5450
|
agentId: this.id,
|
|
@@ -5494,6 +5556,7 @@ ${context}`;
|
|
|
5494
5556
|
messages,
|
|
5495
5557
|
model: this.model,
|
|
5496
5558
|
schema,
|
|
5559
|
+
provider,
|
|
5497
5560
|
signal,
|
|
5498
5561
|
toolExecutionContext: {
|
|
5499
5562
|
operationContext,
|