-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01-basic-usage.ts
More file actions
32 lines (28 loc) · 825 Bytes
/
01-basic-usage.ts
File metadata and controls
32 lines (28 loc) · 825 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
30
31
/**
* Example 1: Basic Usage
*
* This example demonstrates the simplest way to use promptfmt
* to build a prompt with basic components, including array-based components.
*/
import { PromptBuilder } from '../dist';
const prompt = new PromptBuilder()
.role('You are a helpful assistant')
.goal('Answer user questions clearly and concisely')
.input('User question: ${question}')
.steps([
'Understand the question',
'Provide a clear answer',
'Include relevant examples if needed'
])
.constraints([
'Keep response concise (2-3 sentences)',
'Use simple language',
'Be accurate and helpful'
])
.output('Provide a clear answer in 2-3 sentences')
.build({
question: 'What is TypeScript?'
});
console.log('=== Basic Usage Example ===');
console.log(prompt);
console.log('\n');