-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-usage.ts
More file actions
29 lines (23 loc) · 1012 Bytes
/
basic-usage.ts
File metadata and controls
29 lines (23 loc) · 1012 Bytes
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
import { prompt } from "@marrakesh/core";
// Basic prompt building with new minimal API
const p = prompt("You are a helpful customer service agent")
.system("Always be polite and professional")
.system("If you don't know something, say so");
// Compile for different providers
console.log("=== Generic Format ===");
console.log(p.systemPrompt);
console.log("\n=== OpenAI Format ===");
const openaiResult = p.toOpenAI();
console.log("Messages:", openaiResult.messages);
console.log("Tools:", openaiResult.tools);
console.log("\n=== Anthropic Format ===");
const anthropicResult = p.toAnthropic();
console.log("System:", anthropicResult.system);
console.log("Tools:", anthropicResult.tools);
// Prepare messages for API calls
const conversationMessages = [
{ role: "user" as const, content: "I have a problem with my recent order" },
];
const messagesWithSystem = p.toVercelAI(conversationMessages);
console.log("\n=== Prepared Messages ===");
console.log(JSON.stringify(messagesWithSystem, null, 2));