@ariaflowagents/core 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -2
- package/dist/hooks/helpers.d.ts +62 -0
- package/dist/hooks/helpers.d.ts.map +1 -0
- package/dist/hooks/helpers.js +250 -0
- package/dist/hooks/helpers.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/prompts/PromptBuilder.d.ts +9 -0
- package/dist/prompts/PromptBuilder.d.ts.map +1 -0
- package/dist/prompts/PromptBuilder.js +34 -0
- package/dist/prompts/PromptBuilder.js.map +1 -0
- package/dist/prompts/index.d.ts +7 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/registry.d.ts +6 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +16 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/prompts/templates.d.ts +8 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +256 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/prompts/types.d.ts +93 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +286 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/tools/errorHandling.d.ts +37 -0
- package/dist/tools/errorHandling.d.ts.map +1 -0
- package/dist/tools/errorHandling.js +139 -0
- package/dist/tools/errorHandling.js.map +1 -0
- package/dist/tools/errorMessages.d.ts +13 -0
- package/dist/tools/errorMessages.d.ts.map +1 -0
- package/dist/tools/errorMessages.js +81 -0
- package/dist/tools/errorMessages.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/utils/chrono.d.ts +72 -0
- package/dist/utils/chrono.d.ts.map +1 -0
- package/dist/utils/chrono.js +106 -0
- package/dist/utils/chrono.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PromptTemplate } from './types.js';
|
|
2
|
+
import type { ToolSet } from '../tools/Tool.js';
|
|
3
|
+
export declare const SUPPORT_AGENT_TEMPLATE: PromptTemplate;
|
|
4
|
+
export declare const SALES_AGENT_TEMPLATE: PromptTemplate;
|
|
5
|
+
export declare const TRIAGE_AGENT_TEMPLATE: PromptTemplate;
|
|
6
|
+
export declare function createSupportAgentTemplate(tools?: ToolSet): PromptTemplate;
|
|
7
|
+
export declare const BUILTIN_TEMPLATES: Record<string, PromptTemplate>;
|
|
8
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,eAAO,MAAM,sBAAsB,EAAE,cAiEpC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,cAuElC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAsDnC,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,cAAc,CAyD1E;AAGD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAI5D,CAAC"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
export const SUPPORT_AGENT_TEMPLATE = {
|
|
2
|
+
id: 'support-agent',
|
|
3
|
+
name: 'Support Agent',
|
|
4
|
+
description: 'General purpose customer support agent template',
|
|
5
|
+
sections: [
|
|
6
|
+
{
|
|
7
|
+
type: 'personality',
|
|
8
|
+
content: `You are a professional customer support agent. You are empathetic, patient, and committed to helping customers resolve their issues. You adapt your communication style to match the customer's tone and level of expertise.`,
|
|
9
|
+
priority: 10,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: 'goal',
|
|
13
|
+
content: `Your goal is to: 1) Understand the customer's issue thoroughly, 2) Provide accurate and helpful solutions, 3) Ensure the customer feels heard and supported, 4) Follow up to confirm resolution when appropriate.`,
|
|
14
|
+
priority: 20,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'guardrails',
|
|
18
|
+
content: `1. Never make up information - if unsure, acknowledge and offer to verify
|
|
19
|
+
2. Never share customer PII without proper verification
|
|
20
|
+
3. Escalate to a human agent for: legal issues, threats, complex refunds, or situations you're uncomfortable handling
|
|
21
|
+
4. Do not offer refunds or compensation without authorization
|
|
22
|
+
5. If you need to escalate, explain why and what will happen next`,
|
|
23
|
+
priority: 30,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'tone',
|
|
27
|
+
content: `Be friendly but professional. Use the customer's name when known. Avoid technical jargon unless they demonstrate familiarity. For voice interactions, keep responses concise and natural for speech.`,
|
|
28
|
+
priority: 40,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'error_handling',
|
|
32
|
+
content: `When you encounter an issue you cannot resolve: 1) Acknowledge the limitation clearly, 2) Explain why you need to escalate, 3) Provide a clear timeline for follow-up, 4) Thank them for their patience.`,
|
|
33
|
+
priority: 50,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'character_normalization',
|
|
37
|
+
content: `For voice-optimized responses: 1) Spell out email addresses (user at example dot com), 2) Read order numbers as individual digits with pauses, 3) Format dates speakably (January 15th, 2026), 4) Read phone numbers digit by digit.`,
|
|
38
|
+
priority: 60,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'voice_rules',
|
|
42
|
+
content: `Your responses will be converted to speech. Follow these rules for natural TTS output:
|
|
43
|
+
|
|
44
|
+
## Formatting
|
|
45
|
+
1. **Punctuation**: Use proper punctuation at the end of every sentence.
|
|
46
|
+
2. **No special characters**: Avoid emojis, markdown formatting, or special unicode characters.
|
|
47
|
+
3. **No quotation marks**: Avoid unless explicitly quoting someone.
|
|
48
|
+
|
|
49
|
+
## Identifiers
|
|
50
|
+
- Spell out identifiers digit by digit: "A one B two C three"
|
|
51
|
+
- Phone numbers: "five five five, one two three, four five six seven"
|
|
52
|
+
- Email addresses: "user at example dot com"
|
|
53
|
+
|
|
54
|
+
## URLs & Emails
|
|
55
|
+
- Say "dot" instead of ".": "example dot com"
|
|
56
|
+
- Say "at" instead of "@": "user at example dot com"
|
|
57
|
+
|
|
58
|
+
## Speaking Style
|
|
59
|
+
- Be concise and conversational.
|
|
60
|
+
- Use contractions (I'm, you're, we'll).
|
|
61
|
+
- Avoid abbreviations: say "versus" not "vs.", "for example" not "e.g."`,
|
|
62
|
+
priority: 65,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
requiredSections: ['personality', 'goal', 'guardrails'],
|
|
66
|
+
};
|
|
67
|
+
export const SALES_AGENT_TEMPLATE = {
|
|
68
|
+
id: 'sales-agent',
|
|
69
|
+
name: 'Sales Agent',
|
|
70
|
+
description: 'Sales and conversion agent template',
|
|
71
|
+
sections: [
|
|
72
|
+
{
|
|
73
|
+
type: 'personality',
|
|
74
|
+
content: `You are a knowledgeable sales representative. You're enthusiastic about products you believe in, but never pushy. You focus on understanding customer needs and presenting relevant solutions.`,
|
|
75
|
+
priority: 10,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'goal',
|
|
79
|
+
content: `Your goals are: 1) Understand the customer's needs and use case, 2) Present relevant products/solutions, 3) Address concerns and objections, 4) Guide toward the best purchase decision for their needs.`,
|
|
80
|
+
priority: 20,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'guardrails',
|
|
84
|
+
content: `1. Never misrepresent product capabilities or pricing
|
|
85
|
+
2. Don't pressure customers - provide information and let them decide
|
|
86
|
+
3. If a competitor is better suited, acknowledge it
|
|
87
|
+
4. Never create false urgency or scarcity
|
|
88
|
+
5. Escalate to a human for: enterprise deals, custom pricing, contract negotiations`,
|
|
89
|
+
priority: 30,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'tone',
|
|
93
|
+
content: `Be confident but not aggressive. Focus on value and benefits relevant to the customer's stated needs. Use social proof and success stories when appropriate.`,
|
|
94
|
+
priority: 40,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'tools',
|
|
98
|
+
content: `Use product recommendation tools to suggest the best options based on customer requirements.`,
|
|
99
|
+
priority: 50,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'error_handling',
|
|
103
|
+
content: `If a product doesn't meet their needs, acknowledge it honestly. Suggest alternatives or recommend they speak with a specialist who can help with custom requirements.`,
|
|
104
|
+
priority: 60,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'voice_rules',
|
|
108
|
+
content: `Your responses will be converted to speech. Follow these rules for natural TTS output:
|
|
109
|
+
|
|
110
|
+
## Formatting
|
|
111
|
+
1. **Punctuation**: Use proper punctuation at the end of every sentence.
|
|
112
|
+
2. **No special characters**: Avoid emojis, markdown formatting, or special unicode characters.
|
|
113
|
+
3. **No quotation marks**: Avoid unless explicitly quoting someone.
|
|
114
|
+
|
|
115
|
+
## Identifiers
|
|
116
|
+
- Spell out identifiers digit by digit: "A one B two C three"
|
|
117
|
+
- Product codes and SKUs: "B dash one two three four"
|
|
118
|
+
- Email addresses: "user at example dot com"
|
|
119
|
+
|
|
120
|
+
## URLs & Emails
|
|
121
|
+
- Say "dot" instead of ".": "example dot com"
|
|
122
|
+
- Say "at" instead of "@": "user at example dot com"
|
|
123
|
+
|
|
124
|
+
## Currency & Prices
|
|
125
|
+
- Say "five dollars" not "$5"
|
|
126
|
+
- Say "five ninety-nine" not "$5.99"
|
|
127
|
+
- Say "ninety nine dollars and ninety nine cents" not "$99.99"
|
|
128
|
+
|
|
129
|
+
## Speaking Style
|
|
130
|
+
- Be confident but not aggressive.
|
|
131
|
+
- Use natural enthusiasm but avoid exaggeration.
|
|
132
|
+
- Use contractions (I'm, you're, we'll).
|
|
133
|
+
- Avoid abbreviations: say "versus" not "vs.", "for example" not "e.g."`,
|
|
134
|
+
priority: 65,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
requiredSections: ['personality', 'goal', 'guardrails'],
|
|
138
|
+
};
|
|
139
|
+
export const TRIAGE_AGENT_TEMPLATE = {
|
|
140
|
+
id: 'triage-agent',
|
|
141
|
+
name: 'Triage Agent',
|
|
142
|
+
description: 'Initial contact agent that routes to specialized agents',
|
|
143
|
+
sections: [
|
|
144
|
+
{
|
|
145
|
+
type: 'personality',
|
|
146
|
+
content: `You are a friendly and efficient first point of contact. You're great at quickly understanding what people need and directing them to the right resource.`,
|
|
147
|
+
priority: 10,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: 'goal',
|
|
151
|
+
content: `Your goal is to: 1) Quickly understand the customer's primary need, 2) Determine the appropriate specialist or department, 3) Provide a smooth handoff with context, 4) Set expectations for what happens next.`,
|
|
152
|
+
priority: 20,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: 'guardrails',
|
|
156
|
+
content: `1. When unsure which agent to route to, ask clarifying questions
|
|
157
|
+
2. Never attempt to handle issues outside your scope - route to appropriate specialist
|
|
158
|
+
3. Always provide warm handoff with full context
|
|
159
|
+
4. For emergencies, immediately route to human support`,
|
|
160
|
+
priority: 30,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: 'tone',
|
|
164
|
+
content: `Be quick and helpful. Set clear expectations: "I'm connecting you with a specialist who can help with..."`,
|
|
165
|
+
priority: 40,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
type: 'voice_rules',
|
|
169
|
+
content: `Your responses will be converted to speech. Follow these rules for natural TTS output:
|
|
170
|
+
|
|
171
|
+
## Formatting
|
|
172
|
+
1. **Punctuation**: Use proper punctuation at the end of every sentence.
|
|
173
|
+
2. **No special characters**: Avoid emojis, markdown formatting, or special unicode characters.
|
|
174
|
+
3. **No quotation marks**: Avoid unless explicitly quoting someone.
|
|
175
|
+
|
|
176
|
+
## Identifiers
|
|
177
|
+
- Spell out identifiers digit by digit: "A one B two C three"
|
|
178
|
+
- Phone numbers: "five five five, one two three, four five six seven"
|
|
179
|
+
|
|
180
|
+
## URLs & Emails
|
|
181
|
+
- Say "dot" instead of ".": "example dot com"
|
|
182
|
+
- Say "at" instead of "@": "user at example dot com"
|
|
183
|
+
|
|
184
|
+
## Speaking Style
|
|
185
|
+
- Be concise and efficient.
|
|
186
|
+
- Set clear expectations with spoken transitions.
|
|
187
|
+
- Use contractions (I'm, you're, we'll).
|
|
188
|
+
- Avoid abbreviations: say "versus" not "vs.", "for example" not "e.g."`,
|
|
189
|
+
priority: 65,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
requiredSections: ['personality', 'goal', 'guardrails'],
|
|
193
|
+
};
|
|
194
|
+
export function createSupportAgentTemplate(tools) {
|
|
195
|
+
const template = {
|
|
196
|
+
id: 'support-agent',
|
|
197
|
+
name: 'Support Agent',
|
|
198
|
+
description: 'General purpose customer support agent template',
|
|
199
|
+
sections: [
|
|
200
|
+
{
|
|
201
|
+
type: 'personality',
|
|
202
|
+
content: `You are a professional customer support agent. You are empathetic, patient, and committed to helping customers resolve their issues. You adapt your communication style to match the customer's tone and level of expertise.`,
|
|
203
|
+
priority: 10,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
type: 'goal',
|
|
207
|
+
content: `Your goal is to: 1) Understand the customer's issue thoroughly, 2) Provide accurate and helpful solutions, 3) Ensure the customer feels heard and supported, 4) Follow up to confirm resolution when appropriate.`,
|
|
208
|
+
priority: 20,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
type: 'guardrails',
|
|
212
|
+
content: `1. Never make up information - if unsure, acknowledge and offer to verify
|
|
213
|
+
2. Never share customer PII without proper verification
|
|
214
|
+
3. Escalate to a human agent for: legal issues, threats, complex refunds, or situations you're uncomfortable handling
|
|
215
|
+
4. Do not offer refunds or compensation without authorization
|
|
216
|
+
5. If you need to escalate, explain why and what will happen next`,
|
|
217
|
+
priority: 30,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
type: 'tone',
|
|
221
|
+
content: `Be friendly but professional. Use the customer's name when known. Avoid technical jargon unless they demonstrate familiarity. For voice interactions, keep responses concise and natural for speech.`,
|
|
222
|
+
priority: 40,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: 'error_handling',
|
|
226
|
+
content: `When you encounter an issue you cannot resolve: 1) Acknowledge the limitation clearly, 2) Explain why you need to escalate, 3) Provide a clear timeline for follow-up, 4) Thank them for their patience.`,
|
|
227
|
+
priority: 50,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
type: 'character_normalization',
|
|
231
|
+
content: `For voice-optimized responses: 1) Spell out email addresses (user at example dot com), 2) Read order numbers as individual digits with pauses, 3) Format dates speakably (January 15th, 2026), 4) Read phone numbers digit by digit.`,
|
|
232
|
+
priority: 60,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
requiredSections: ['personality', 'goal', 'guardrails'],
|
|
236
|
+
};
|
|
237
|
+
if (tools) {
|
|
238
|
+
const toolDescriptions = Object.entries(tools).map(([name, tool]) => {
|
|
239
|
+
const desc = 'description' in tool ? String(tool.description) : '';
|
|
240
|
+
return `### ${name}\n${desc}`;
|
|
241
|
+
}).join('\n\n');
|
|
242
|
+
template.sections.push({
|
|
243
|
+
type: 'tools',
|
|
244
|
+
content: toolDescriptions,
|
|
245
|
+
priority: 70,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return template;
|
|
249
|
+
}
|
|
250
|
+
// Export built-in templates for config loader
|
|
251
|
+
export const BUILTIN_TEMPLATES = {
|
|
252
|
+
'support-agent': SUPPORT_AGENT_TEMPLATE,
|
|
253
|
+
'sales-agent': SALES_AGENT_TEMPLATE,
|
|
254
|
+
'triage-agent': TRIAGE_AGENT_TEMPLATE,
|
|
255
|
+
};
|
|
256
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,sBAAsB,GAAmB;IACpD,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,iDAAiD;IAC9D,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,8NAA8N;YACvO,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,mNAAmN;YAC5N,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE;;;;kEAImD;YAC5D,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,sMAAsM;YAC/M,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,0MAA0M;YACnN,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,sOAAsO;YAC/O,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;wEAmByD;YAClE,QAAQ,EAAE,EAAE;SACb;KACF;IACD,gBAAgB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EAAE,IAAI,CAAC,EAAE,EAAE;YAClE,MAAM,IAAI,GAAG,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,OAAO,OAAO,IAAI,KAAK,IAAI,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChB,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;YACrB,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,gBAAgB;YACzB,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,eAAe,EAAE,sBAAsB;IACvC,aAAa,EAAE,oBAAoB;IACnC,cAAc,EAAE,qBAAqB;CACtC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ToolSet } from '../tools/Tool.js';
|
|
2
|
+
export type PromptSectionType = 'personality' | 'goal' | 'guardrails' | 'tools' | 'tone' | 'character_normalization' | 'voice_rules' | 'glossary' | 'system_reminder' | 'error_handling' | 'custom';
|
|
3
|
+
export interface PromptSection {
|
|
4
|
+
type: PromptSectionType;
|
|
5
|
+
content: string;
|
|
6
|
+
priority?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ToolGuideline {
|
|
9
|
+
name: string;
|
|
10
|
+
whenToUse: string;
|
|
11
|
+
howToUse: string;
|
|
12
|
+
errorHandling: string;
|
|
13
|
+
}
|
|
14
|
+
export interface VoiceRulesConfig {
|
|
15
|
+
/** Cartesia-specific <spell> tags. Defaults to false for cross-TTS compatibility. */
|
|
16
|
+
useSpellTags?: boolean;
|
|
17
|
+
/** Cartesia-specific <break> tags. Defaults to false. */
|
|
18
|
+
useBreakTags?: boolean;
|
|
19
|
+
/** Cartesia-specific <speed> tags. Defaults to false. */
|
|
20
|
+
useSpeedTags?: boolean;
|
|
21
|
+
/** Cartesia-specific <emotion> tags. Defaults to false. */
|
|
22
|
+
useEmotionTags?: boolean;
|
|
23
|
+
/** Cartesia-specific [laughter] tags. Defaults to false. */
|
|
24
|
+
useLaughterTags?: boolean;
|
|
25
|
+
customPronunciations?: Record<string, string>;
|
|
26
|
+
formatDates?: 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD' | 'speakable';
|
|
27
|
+
formatTimes?: '12h' | '24h';
|
|
28
|
+
urlFormat?: 'dot' | 'spell';
|
|
29
|
+
numberFormat?: 'words' | 'digits' | 'mixed';
|
|
30
|
+
verbalizeCurrency?: boolean;
|
|
31
|
+
verbalizeSymbols?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface VoiceRules {
|
|
34
|
+
config: VoiceRulesConfig;
|
|
35
|
+
rules: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface GlossaryTerm {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
synonyms?: string[];
|
|
41
|
+
category?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface GlossaryConfig {
|
|
44
|
+
terms: GlossaryTerm[];
|
|
45
|
+
format?: 'list' | 'table' | 'detailed';
|
|
46
|
+
}
|
|
47
|
+
export interface PromptTemplate {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
sections: PromptSection[];
|
|
52
|
+
requiredSections: PromptSectionType[];
|
|
53
|
+
}
|
|
54
|
+
export interface PromptTemplateBuilderOptions {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
}
|
|
59
|
+
export declare class PromptTemplateBuilder {
|
|
60
|
+
private readonly id;
|
|
61
|
+
private readonly name;
|
|
62
|
+
private readonly description?;
|
|
63
|
+
private sections;
|
|
64
|
+
private toolGuidelines;
|
|
65
|
+
private toolsProvided;
|
|
66
|
+
private voiceRulesConfig;
|
|
67
|
+
private glossaryTerms;
|
|
68
|
+
private injectTodayDateFlag;
|
|
69
|
+
constructor(options: PromptTemplateBuilderOptions);
|
|
70
|
+
personality(content: string): this;
|
|
71
|
+
goal(content: string): this;
|
|
72
|
+
guardrails(content: string): this;
|
|
73
|
+
tools(content: string): this;
|
|
74
|
+
tone(content: string): this;
|
|
75
|
+
characterNormalization(content: string): this;
|
|
76
|
+
voiceRules(config?: VoiceRulesConfig): this;
|
|
77
|
+
enableVoiceRules(config?: VoiceRulesConfig): this;
|
|
78
|
+
glossary(terms: GlossaryTerm[]): this;
|
|
79
|
+
addTerm(name: string, description: string, synonyms?: string[]): this;
|
|
80
|
+
injectTodayDate(enabled?: boolean): this;
|
|
81
|
+
errorHandling(content: string): this;
|
|
82
|
+
custom(name: string, content: string, priority?: number): this;
|
|
83
|
+
toolGuideline(guideline: ToolGuideline): this;
|
|
84
|
+
toolsSet(tools: ToolSet): this;
|
|
85
|
+
default(tools?: ToolSet): this;
|
|
86
|
+
build(): PromptTemplate;
|
|
87
|
+
private addSection;
|
|
88
|
+
private formatToolGuidelines;
|
|
89
|
+
private formatVoiceRules;
|
|
90
|
+
private formatGlossary;
|
|
91
|
+
}
|
|
92
|
+
export declare function createPromptTemplate(id: string, name: string, configure: (builder: PromptTemplateBuilder) => void): PromptTemplate;
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,MAAM,GACN,YAAY,GACZ,OAAO,GACP,MAAM,GACN,yBAAyB,GACzB,aAAa,GACb,UAAU,GACV,iBAAiB,GACjB,gBAAgB,GAChB,QAAQ,CAAC;AAEb,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB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EAAE,GAAG,IAAI;IAKrC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI;IAKrE,eAAe,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAK9C,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAO9D,aAAa,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAK7C,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAU9B,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAgD9B,KAAK,IAAI,cAAc;IAiDvB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,gBAAgB;IAoGxB,OAAO,CAAC,cAAc;CAuBvB;AAED,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,GAClD,cAAc,CAIhB"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
export class PromptTemplateBuilder {
|
|
2
|
+
id;
|
|
3
|
+
name;
|
|
4
|
+
description;
|
|
5
|
+
sections = [];
|
|
6
|
+
toolGuidelines = [];
|
|
7
|
+
toolsProvided = false;
|
|
8
|
+
voiceRulesConfig = {};
|
|
9
|
+
glossaryTerms = [];
|
|
10
|
+
injectTodayDateFlag = true; // Default to true for .default() to include date
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.id = options.id;
|
|
13
|
+
this.name = options.name;
|
|
14
|
+
this.description = options.description;
|
|
15
|
+
}
|
|
16
|
+
personality(content) {
|
|
17
|
+
this.addSection('personality', content);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
goal(content) {
|
|
21
|
+
this.addSection('goal', content);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
guardrails(content) {
|
|
25
|
+
this.addSection('guardrails', content);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
tools(content) {
|
|
29
|
+
this.addSection('tools', content);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
tone(content) {
|
|
33
|
+
this.addSection('tone', content);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
characterNormalization(content) {
|
|
37
|
+
this.addSection('character_normalization', content);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
voiceRules(config) {
|
|
41
|
+
this.voiceRulesConfig = { ...this.voiceRulesConfig, ...config };
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
enableVoiceRules(config) {
|
|
45
|
+
return this.voiceRules(config);
|
|
46
|
+
}
|
|
47
|
+
glossary(terms) {
|
|
48
|
+
this.glossaryTerms = [...this.glossaryTerms, ...terms];
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
addTerm(name, description, synonyms) {
|
|
52
|
+
this.glossaryTerms.push({ name, description, synonyms });
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
injectTodayDate(enabled = true) {
|
|
56
|
+
this.injectTodayDateFlag = enabled;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
errorHandling(content) {
|
|
60
|
+
this.addSection('error_handling', content);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
custom(name, content, priority) {
|
|
64
|
+
// Special case: if creating a "System Reminder" section, use system_reminder type
|
|
65
|
+
const sectionType = name.toLowerCase() === 'system reminder' ? 'system_reminder' : 'custom';
|
|
66
|
+
this.addSection(sectionType, sectionType === 'custom' ? `# ${name}\n\n${content}` : content, priority);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
toolGuideline(guideline) {
|
|
70
|
+
this.toolGuidelines.push(guideline);
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
toolsSet(tools) {
|
|
74
|
+
const toolDescriptions = Object.entries(tools).map(([name, tool]) => {
|
|
75
|
+
const desc = 'description' in tool ? String(tool.description) : '';
|
|
76
|
+
return `### ${name}\n${desc}`;
|
|
77
|
+
}).join('\n\n');
|
|
78
|
+
this.addSection('tools', toolDescriptions);
|
|
79
|
+
this.toolsProvided = true;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
default(tools) {
|
|
83
|
+
const hasCustomPersonality = this.sections.some(s => s.type === 'personality');
|
|
84
|
+
const hasCustomGoal = this.sections.some(s => s.type === 'goal');
|
|
85
|
+
const hasCustomGuardrails = this.sections.some(s => s.type === 'guardrails');
|
|
86
|
+
const hasCustomTone = this.sections.some(s => s.type === 'tone');
|
|
87
|
+
const hasCustomErrorHandling = this.sections.some(s => s.type === 'error_handling');
|
|
88
|
+
const hasCustomCharNorm = this.sections.some(s => s.type === 'character_normalization');
|
|
89
|
+
const hasCustomVoiceRules = this.sections.some(s => s.type === 'voice_rules');
|
|
90
|
+
const hasCustomTools = this.sections.some(s => s.type === 'tools');
|
|
91
|
+
if (!hasCustomPersonality) {
|
|
92
|
+
this.addSection('personality', `You are a ${this.name}. You are professional, helpful, and adapt your communication style to match the user's needs.`);
|
|
93
|
+
}
|
|
94
|
+
if (!hasCustomGoal) {
|
|
95
|
+
this.addSection('goal', `Your goal is to understand the user's request, provide accurate and helpful information, and complete tasks efficiently while maintaining a high quality of service.`);
|
|
96
|
+
}
|
|
97
|
+
if (!hasCustomGuardrails) {
|
|
98
|
+
this.addSection('guardrails', `Never make up information. If you don't know something, admit it clearly and offer to find out. Never share sensitive information unless properly verified. Escalate to a human when appropriate.`);
|
|
99
|
+
}
|
|
100
|
+
if (!hasCustomTone) {
|
|
101
|
+
this.addSection('tone', `Use clear, concise language. Be friendly but professional. Avoid jargon unless the user demonstrates familiarity with it.`);
|
|
102
|
+
}
|
|
103
|
+
if (!hasCustomErrorHandling) {
|
|
104
|
+
this.addSection('error_handling', `When you encounter an error or cannot complete a request: 1) Acknowledge the issue clearly, 2) Don't guess or make up solutions, 3) Offer alternatives or suggest next steps.`);
|
|
105
|
+
}
|
|
106
|
+
if (!hasCustomCharNorm) {
|
|
107
|
+
this.addSection('character_normalization', `Normalize user input for speech recognition systems: 1) Convert email addresses to speakable format (at-sign as "at", dot as "dot"), 2) Spell out phone numbers digit by digit, 3) Format codes and IDs with spaces or pauses.`);
|
|
108
|
+
}
|
|
109
|
+
if (tools && !hasCustomTools) {
|
|
110
|
+
this.toolsSet(tools);
|
|
111
|
+
}
|
|
112
|
+
// Set injectTodayDateFlag to true by default in .default()
|
|
113
|
+
if (this.injectTodayDateFlag === true) {
|
|
114
|
+
// Flag is already true, do nothing
|
|
115
|
+
}
|
|
116
|
+
else if (this.injectTodayDateFlag === undefined) {
|
|
117
|
+
this.injectTodayDateFlag = true; // Enable by default in .default()
|
|
118
|
+
}
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
build() {
|
|
122
|
+
const guidelineSection = this.toolGuidelines.length > 0
|
|
123
|
+
? {
|
|
124
|
+
type: 'custom',
|
|
125
|
+
content: this.formatToolGuidelines(),
|
|
126
|
+
priority: 80,
|
|
127
|
+
}
|
|
128
|
+
: null;
|
|
129
|
+
if (guidelineSection) {
|
|
130
|
+
this.sections.push(guidelineSection);
|
|
131
|
+
}
|
|
132
|
+
if (Object.keys(this.voiceRulesConfig).length > 0) {
|
|
133
|
+
const voiceRulesContent = this.formatVoiceRules();
|
|
134
|
+
this.addSection('voice_rules', voiceRulesContent, 65);
|
|
135
|
+
}
|
|
136
|
+
if (this.glossaryTerms.length > 0) {
|
|
137
|
+
const glossaryContent = this.formatGlossary();
|
|
138
|
+
this.addSection('glossary', glossaryContent, 55);
|
|
139
|
+
}
|
|
140
|
+
if (this.injectTodayDateFlag) {
|
|
141
|
+
const hasCustomSystemReminder = this.sections.some(s => s.type === 'system_reminder');
|
|
142
|
+
if (!hasCustomSystemReminder) {
|
|
143
|
+
const today = new Date().toLocaleDateString('en-US', {
|
|
144
|
+
weekday: 'long',
|
|
145
|
+
year: 'numeric',
|
|
146
|
+
month: 'long',
|
|
147
|
+
day: 'numeric',
|
|
148
|
+
});
|
|
149
|
+
this.addSection('system_reminder', `Today is ${today}.`, 25);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const requiredSections = ['personality', 'goal', 'guardrails'];
|
|
153
|
+
this.sections.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
|
|
154
|
+
return {
|
|
155
|
+
id: this.id,
|
|
156
|
+
name: this.name,
|
|
157
|
+
description: this.description,
|
|
158
|
+
sections: this.sections,
|
|
159
|
+
requiredSections,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
addSection(type, content, priority) {
|
|
163
|
+
const existingIndex = this.sections.findIndex(s => s.type === type);
|
|
164
|
+
if (existingIndex !== -1) {
|
|
165
|
+
this.sections[existingIndex] = { type, content, priority };
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this.sections.push({ type, content, priority });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
formatToolGuidelines() {
|
|
172
|
+
return `## Tool Usage Guidelines\n\n${this.toolGuidelines.map(g => `### ${g.name}\n**When to use:** ${g.whenToUse}\n\n**How to use:** ${g.howToUse}\n\n**Error handling:** ${g.errorHandling}`).join('\n\n---\n\n')}`;
|
|
173
|
+
}
|
|
174
|
+
formatVoiceRules() {
|
|
175
|
+
const rules = [];
|
|
176
|
+
const cfg = this.voiceRulesConfig;
|
|
177
|
+
rules.push('Your responses will be converted to speech. Follow these rules for natural TTS output:');
|
|
178
|
+
rules.push('## Formatting');
|
|
179
|
+
rules.push('1. **Punctuation**: Use proper punctuation at the end of every sentence.');
|
|
180
|
+
rules.push('2. **No special characters**: Avoid emojis, markdown formatting, or special unicode characters.');
|
|
181
|
+
rules.push('3. **No quotation marks**: Avoid unless explicitly quoting someone.\n');
|
|
182
|
+
rules.push('## Numbers & Dates');
|
|
183
|
+
if (cfg.formatDates === 'MM/DD/YYYY') {
|
|
184
|
+
rules.push('- **Dates**: Write as MM/DD/YYYY (e.g., "04/20/2023" not "April 20th").');
|
|
185
|
+
}
|
|
186
|
+
else if (cfg.formatDates === 'speakable') {
|
|
187
|
+
rules.push('- **Dates**: Speak in natural form (e.g., "April twentieth, twenty twenty-three").');
|
|
188
|
+
}
|
|
189
|
+
if (cfg.formatTimes === '12h') {
|
|
190
|
+
rules.push('- **Times**: Use 12-hour format with space before AM/PM (e.g., "7:00 PM" not "7:00PM").');
|
|
191
|
+
}
|
|
192
|
+
// useSpellTags defaults to false for cross-TTS compatibility (Cartesia-specific feature)
|
|
193
|
+
if (cfg.useSpellTags) {
|
|
194
|
+
rules.push('\n## Identifiers (Spelling)');
|
|
195
|
+
rules.push('- Wrap identifiers in <spell> tags:');
|
|
196
|
+
rules.push(' - Order numbers: "<spell>A1B2C3</spell>"');
|
|
197
|
+
rules.push(' - Phone numbers: "<spell>555-123-4567</spell>"');
|
|
198
|
+
rules.push(' - Confirmation codes: "<spell>XYZ789</spell>"');
|
|
199
|
+
rules.push(' - Email addresses: "<spell>user@example.com</spell>"');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
rules.push('\n## Identifiers');
|
|
203
|
+
rules.push('- Spell out identifiers digit by digit: "A one B two C three"');
|
|
204
|
+
rules.push('- Phone numbers: "five five five, one two three, four five six seven"');
|
|
205
|
+
rules.push('- Email addresses: "user at example dot com"');
|
|
206
|
+
}
|
|
207
|
+
if (cfg.urlFormat === 'dot') {
|
|
208
|
+
rules.push('\n## URLs & Emails');
|
|
209
|
+
rules.push('- Say "dot" instead of ".": "example dot com"');
|
|
210
|
+
rules.push('- Say "at" instead of "@": "user at example dot com"');
|
|
211
|
+
}
|
|
212
|
+
rules.push('\n## Pauses & Breaks');
|
|
213
|
+
if (cfg.useBreakTags) {
|
|
214
|
+
rules.push('- Use <break time="Xs"/> for pauses: "Let me check.<break time="1s"/>Okay..."');
|
|
215
|
+
rules.push('- Shorter breaks (200-500ms) between list items.');
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
rules.push('- Use natural pauses with punctuation and dashes.');
|
|
219
|
+
rules.push('- Use "—" (em dash) for longer pauses in speech.');
|
|
220
|
+
}
|
|
221
|
+
if (cfg.useSpeedTags) {
|
|
222
|
+
rules.push('\n## Speaking Pace');
|
|
223
|
+
rules.push('- Use <speed ratio="0.8"/> for slow, clear explanations.');
|
|
224
|
+
rules.push('- Use <speed ratio="1.2"/> for quick summaries.');
|
|
225
|
+
rules.push('- Normal speed is ratio 1.0.');
|
|
226
|
+
}
|
|
227
|
+
if (cfg.useEmotionTags) {
|
|
228
|
+
rules.push('\n## Emotional Expression');
|
|
229
|
+
rules.push('- Use <emotion value="..."/> for tone: neutral, excited, sympathetic, curious, etc.');
|
|
230
|
+
rules.push('- Emotions: happy, excited, content, sad, scared, curious, sympathetic, calm.');
|
|
231
|
+
rules.push('- Match emotion to content - do not use conflicting tones.');
|
|
232
|
+
}
|
|
233
|
+
if (cfg.useLaughterTags) {
|
|
234
|
+
rules.push('\n## Nonverbal Sounds');
|
|
235
|
+
rules.push('- Use [laughter] to indicate laughing: "That is funny! [laughter]"');
|
|
236
|
+
rules.push('- Use sparingly for natural effect.');
|
|
237
|
+
}
|
|
238
|
+
if (cfg.verbalizeCurrency) {
|
|
239
|
+
rules.push('\n## Currency');
|
|
240
|
+
rules.push('- Say "five dollars" not "$5"');
|
|
241
|
+
rules.push('- Say "five ninety-nine" not "$5.99"');
|
|
242
|
+
}
|
|
243
|
+
if (cfg.verbalizeSymbols) {
|
|
244
|
+
rules.push('\n## Symbols');
|
|
245
|
+
rules.push('- Say "percent" not "%"');
|
|
246
|
+
rules.push('- Say "dollar" not "$"');
|
|
247
|
+
rules.push('- Say "equals" not "="');
|
|
248
|
+
}
|
|
249
|
+
if (cfg.customPronunciations) {
|
|
250
|
+
rules.push('\n## Custom Pronunciations');
|
|
251
|
+
for (const [word, pronunciation] of Object.entries(cfg.customPronunciations)) {
|
|
252
|
+
rules.push(`- "${word}" should be pronounced: "${pronunciation}"`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
rules.push('\n## Speaking Style');
|
|
256
|
+
rules.push('- Be concise and conversational.');
|
|
257
|
+
rules.push('- Use contractions (I\'m, you\'re, we\'ll).');
|
|
258
|
+
rules.push('- Avoid abbreviations: say "versus" not "vs.", "for example" not "e.g."');
|
|
259
|
+
rules.push('- For lists, use natural connectors: "first, second, third" not bullet points.');
|
|
260
|
+
return rules.filter(r => r.trim()).join('\n');
|
|
261
|
+
}
|
|
262
|
+
formatGlossary() {
|
|
263
|
+
if (this.glossaryTerms.length === 0) {
|
|
264
|
+
return '';
|
|
265
|
+
}
|
|
266
|
+
const lines = ['## Domain Glossary'];
|
|
267
|
+
lines.push('');
|
|
268
|
+
lines.push('The following terms have specific meanings in this context:');
|
|
269
|
+
lines.push('');
|
|
270
|
+
for (const term of this.glossaryTerms) {
|
|
271
|
+
lines.push(`### ${term.name}`);
|
|
272
|
+
lines.push(`**Description:** ${term.description}`);
|
|
273
|
+
if (term.synonyms && term.synonyms.length > 0) {
|
|
274
|
+
lines.push(`**Synonyms:** ${term.synonyms.join(', ')}`);
|
|
275
|
+
}
|
|
276
|
+
lines.push(''); // Blank line between terms
|
|
277
|
+
}
|
|
278
|
+
return lines.join('\n');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export function createPromptTemplate(id, name, configure) {
|
|
282
|
+
const builder = new PromptTemplateBuilder({ id, name });
|
|
283
|
+
configure(builder);
|
|
284
|
+
return builder.build();
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=types.js.map
|