forked from i-am-bee/bee-agent-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructured.ts
30 lines (29 loc) · 822 Bytes
/
structured.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import "dotenv/config.js";
import { z } from "zod";
import { BaseMessage, Role } from "bee-agent-framework/llms/primitives/message";
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat";
import { JsonDriver } from "bee-agent-framework/llms/drivers/json";
const llm = new OllamaChatLLM();
const driver = new JsonDriver(llm);
const response = await driver.generate(
z.union([
z.object({
firstName: z.string().min(1),
lastName: z.string().min(1),
address: z.string(),
age: z.number().int().min(1),
hobby: z.string(),
}),
z.object({
error: z.string(),
}),
]),
[
BaseMessage.of({
role: Role.USER,
text: "Generate a profile of a citizen of Europe.", // feel free to update it
}),
],
);
console.info(response);
process.exit(0);