-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (40 loc) · 1.03 KB
/
index.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const HyperDX = require("@hyperdx/node-opentelemetry");
HyperDX.init({
service: "ai-sdk",
});
const { openai } = require("@ai-sdk/openai");
const { generateObject } = require("ai");
const { z } = require("zod");
const main = async () => {
const result = await generateObject({
model: openai("gpt-4o-mini", {
structuredOutputs: true,
}),
schemaName: "recipe",
schemaDescription: "A recipe for lasagna.",
schema: z.object({
name: z.string(),
ingredients: z.array(
z.object({
name: z.string(),
amount: z.string(),
}),
),
steps: z.array(z.string()),
}),
prompt: "Generate a lasagna recipe.",
experimental_telemetry: {
isEnabled: true,
functionId: "my-awesome-function",
metadata: {
something: "custom",
someOtherThing: "other-value",
},
},
});
console.log(JSON.stringify(result, null, 2));
await HyperDX.shutdown();
};
main()
.then(() => console.log("Done!"))
.catch((err) => console.error(err));