-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathquick-start.ts
More file actions
48 lines (43 loc) · 1.16 KB
/
quick-start.ts
File metadata and controls
48 lines (43 loc) · 1.16 KB
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
45
46
47
48
/**
* Quick Start Example
*
* This is the simplest example to get started with Torque.
* Demonstrates AI-generated user messages with static/generated assistant responses.
*/
import {
generateDataset,
generatedUser,
assistant,
generatedAssistant,
oneOf,
} from "@qforge/torque";
import { createOpenAI } from "@ai-sdk/openai";
const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) {
console.error("❌ ERROR: OPENAI_API_KEY not found!");
console.log("\n📝 To add your API key:");
console.log(
"1. Add: OPENAI_API_KEY=your-key-here or change the apiKey variable above."
);
console.log("2. Run this script again\n");
process.exit(1);
}
const openai = createOpenAI({
apiKey,
});
await generateDataset(
() => [
generatedUser({ prompt: "Friendly greeting or introduction" }), // AI generated
oneOf([
// pick one randomly
assistant({ content: "Hello!" }), // static
generatedAssistant({ prompt: "Respond to greeting" }), // AI generated
]),
],
{
count: 2, // number of examples
model: openai("gpt-5-mini"), // any ai-sdk model
seed: 42, // replayable RNG
output: "data/quick-start.jsonl",
}
);