@promptbook/core 0.100.0-21 → 0.100.0-22
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/esm/index.es.js +272 -1
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +4 -0
- package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +5 -0
- package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +6 -0
- package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +272 -1
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-22';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -207,6 +207,26 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
207
207
|
constructor() {
|
|
208
208
|
super('ACTION');
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Markdown documentation for ACTION commitment.
|
|
212
|
+
*/
|
|
213
|
+
get description() {
|
|
214
|
+
return [
|
|
215
|
+
'# ACTION',
|
|
216
|
+
'',
|
|
217
|
+
'Defines specific actions or capabilities that the agent can perform.',
|
|
218
|
+
'',
|
|
219
|
+
'Effects on system message:',
|
|
220
|
+
'- Appends a "Capability: ..." line to the system message.',
|
|
221
|
+
'',
|
|
222
|
+
'Examples:',
|
|
223
|
+
'```book',
|
|
224
|
+
'ACTION Can generate code snippets and explain programming concepts',
|
|
225
|
+
'ACTION Able to analyze data and provide insights',
|
|
226
|
+
'```',
|
|
227
|
+
'',
|
|
228
|
+
].join('\n');
|
|
229
|
+
}
|
|
210
230
|
applyToAgentModelRequirements(requirements, content) {
|
|
211
231
|
const trimmedContent = content.trim();
|
|
212
232
|
if (!trimmedContent) {
|
|
@@ -247,6 +267,26 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
247
267
|
constructor() {
|
|
248
268
|
super('FORMAT');
|
|
249
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Markdown documentation for FORMAT commitment.
|
|
272
|
+
*/
|
|
273
|
+
get description() {
|
|
274
|
+
return [
|
|
275
|
+
'# FORMAT',
|
|
276
|
+
'',
|
|
277
|
+
'Defines the specific output structure and formatting for responses (data formats, templates, structure).',
|
|
278
|
+
'',
|
|
279
|
+
'Effects on system message:',
|
|
280
|
+
'- Appends an "Output Format: ..." line to the system message.',
|
|
281
|
+
'',
|
|
282
|
+
'Examples:',
|
|
283
|
+
'```book',
|
|
284
|
+
"FORMAT Always respond in JSON format with 'status' and 'data' fields",
|
|
285
|
+
'FORMAT Use markdown formatting for all code blocks',
|
|
286
|
+
'```',
|
|
287
|
+
'',
|
|
288
|
+
].join('\n');
|
|
289
|
+
}
|
|
250
290
|
applyToAgentModelRequirements(requirements, content) {
|
|
251
291
|
const trimmedContent = content.trim();
|
|
252
292
|
if (!trimmedContent) {
|
|
@@ -999,6 +1039,32 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
999
1039
|
super('KNOWLEDGE');
|
|
1000
1040
|
this.ragService = new FrontendRAGService();
|
|
1001
1041
|
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Markdown documentation for KNOWLEDGE commitment.
|
|
1044
|
+
*/
|
|
1045
|
+
get description() {
|
|
1046
|
+
return [
|
|
1047
|
+
'# KNOWLEDGE',
|
|
1048
|
+
'',
|
|
1049
|
+
'Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.',
|
|
1050
|
+
'',
|
|
1051
|
+
'Two modes:',
|
|
1052
|
+
'- Direct text knowledge: Appends a "Knowledge: ..." line to the system message.',
|
|
1053
|
+
'- URL knowledge source: Stores the URL in metadata.knowledgeSources and a ragService for retrieval at chat time, and appends an informational line to the system message.',
|
|
1054
|
+
'',
|
|
1055
|
+
'Metadata effects when URL is used:',
|
|
1056
|
+
'- metadata.ragService = FrontendRAGService instance',
|
|
1057
|
+
'- metadata.knowledgeSources += [url]',
|
|
1058
|
+
'',
|
|
1059
|
+
'Examples:',
|
|
1060
|
+
'```book',
|
|
1061
|
+
'KNOWLEDGE The company was founded in 2020 and specializes in AI-powered solutions',
|
|
1062
|
+
'KNOWLEDGE https://example.com/company-handbook.pdf',
|
|
1063
|
+
'KNOWLEDGE https://example.com/product-documentation.pdf',
|
|
1064
|
+
'```',
|
|
1065
|
+
'',
|
|
1066
|
+
].join('\n');
|
|
1067
|
+
}
|
|
1002
1068
|
applyToAgentModelRequirements(requirements, content) {
|
|
1003
1069
|
var _a;
|
|
1004
1070
|
const trimmedContent = content.trim();
|
|
@@ -1078,6 +1144,27 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1078
1144
|
constructor() {
|
|
1079
1145
|
super('META IMAGE');
|
|
1080
1146
|
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Markdown documentation for META IMAGE commitment.
|
|
1149
|
+
*/
|
|
1150
|
+
get description() {
|
|
1151
|
+
return [
|
|
1152
|
+
'# META IMAGE',
|
|
1153
|
+
'',
|
|
1154
|
+
"Sets the agent's avatar/profile image URL.",
|
|
1155
|
+
'',
|
|
1156
|
+
'Behavior:',
|
|
1157
|
+
'- Does not modify the system message.',
|
|
1158
|
+
'- Handled separately by parsing logic to extract and store a profile image URL.',
|
|
1159
|
+
'',
|
|
1160
|
+
'Examples:',
|
|
1161
|
+
'```book',
|
|
1162
|
+
'META IMAGE https://example.com/avatar.jpg',
|
|
1163
|
+
'META IMAGE /assets/agent-avatar.png',
|
|
1164
|
+
'```',
|
|
1165
|
+
'',
|
|
1166
|
+
].join('\\n').replace(/\\\\n/g, '\\n');
|
|
1167
|
+
}
|
|
1081
1168
|
applyToAgentModelRequirements(requirements, content) {
|
|
1082
1169
|
// META IMAGE doesn't modify the system message or model requirements
|
|
1083
1170
|
// It's handled separately in the parsing logic for profile image extraction
|
|
@@ -1131,6 +1218,29 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1131
1218
|
constructor() {
|
|
1132
1219
|
super('META LINK');
|
|
1133
1220
|
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Markdown documentation for META LINK commitment.
|
|
1223
|
+
*/
|
|
1224
|
+
get description() {
|
|
1225
|
+
return [
|
|
1226
|
+
'# META LINK',
|
|
1227
|
+
'',
|
|
1228
|
+
'Represents a profile or source link for the person the agent is modeled after.',
|
|
1229
|
+
'',
|
|
1230
|
+
'Behavior:',
|
|
1231
|
+
'- Does not modify the system message.',
|
|
1232
|
+
'- Parsing logic extracts and stores the link for profile display.',
|
|
1233
|
+
'- Multiple META LINK lines are allowed when there are multiple sources.',
|
|
1234
|
+
'',
|
|
1235
|
+
'Examples:',
|
|
1236
|
+
'```book',
|
|
1237
|
+
'META LINK https://twitter.com/username',
|
|
1238
|
+
'META LINK https://linkedin.com/in/profile',
|
|
1239
|
+
'META LINK https://github.com/username',
|
|
1240
|
+
'```',
|
|
1241
|
+
'',
|
|
1242
|
+
].join('\\n').replace(/\\\\n/g, '\\n');
|
|
1243
|
+
}
|
|
1134
1244
|
applyToAgentModelRequirements(requirements, content) {
|
|
1135
1245
|
// META LINK doesn't modify the system message or model requirements
|
|
1136
1246
|
// It's handled separately in the parsing logic for profile link extraction
|
|
@@ -1188,6 +1298,33 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1188
1298
|
constructor() {
|
|
1189
1299
|
super('MODEL');
|
|
1190
1300
|
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Markdown documentation for MODEL commitment.
|
|
1303
|
+
*/
|
|
1304
|
+
get description() {
|
|
1305
|
+
return [
|
|
1306
|
+
'# MODEL',
|
|
1307
|
+
'',
|
|
1308
|
+
'Specifies which AI model to use and optional decoding parameters.',
|
|
1309
|
+
'',
|
|
1310
|
+
'Supported parameters:',
|
|
1311
|
+
'- temperature: number',
|
|
1312
|
+
'- topP (aka top_p): number',
|
|
1313
|
+
'- topK (aka top_k): integer',
|
|
1314
|
+
'',
|
|
1315
|
+
'Effects on requirements:',
|
|
1316
|
+
'- Sets modelName from the first token.',
|
|
1317
|
+
'- Parses optional parameters and assigns them to requirements (temperature, topP, topK).',
|
|
1318
|
+
'',
|
|
1319
|
+
'Examples:',
|
|
1320
|
+
'```book',
|
|
1321
|
+
'MODEL gpt-4',
|
|
1322
|
+
'MODEL claude-3-opus temperature=0.3',
|
|
1323
|
+
'MODEL gpt-3.5-turbo temperature=0.8 topP=0.9',
|
|
1324
|
+
'```',
|
|
1325
|
+
'',
|
|
1326
|
+
].join('\n');
|
|
1327
|
+
}
|
|
1191
1328
|
applyToAgentModelRequirements(requirements, content) {
|
|
1192
1329
|
const trimmedContent = content.trim();
|
|
1193
1330
|
if (!trimmedContent) {
|
|
@@ -1273,6 +1410,29 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1273
1410
|
constructor() {
|
|
1274
1411
|
super('NOTE');
|
|
1275
1412
|
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Markdown documentation for NOTE commitment.
|
|
1415
|
+
*/
|
|
1416
|
+
get description() {
|
|
1417
|
+
return [
|
|
1418
|
+
'# NOTE',
|
|
1419
|
+
'',
|
|
1420
|
+
'Adds comments for documentation without changing system message or model requirements.',
|
|
1421
|
+
'',
|
|
1422
|
+
'Key behaviors:',
|
|
1423
|
+
'- Makes no changes to the system message.',
|
|
1424
|
+
'- Makes no changes to requirements.',
|
|
1425
|
+
'- Aggregates multiple NOTE lines into metadata.NOTE.',
|
|
1426
|
+
'',
|
|
1427
|
+
'Examples:',
|
|
1428
|
+
'```book',
|
|
1429
|
+
'NOTE This agent was designed for customer support scenarios',
|
|
1430
|
+
'NOTE Remember to update the knowledge base monthly',
|
|
1431
|
+
'NOTE Performance optimized for quick response times',
|
|
1432
|
+
'```',
|
|
1433
|
+
'',
|
|
1434
|
+
].join('\n');
|
|
1435
|
+
}
|
|
1276
1436
|
applyToAgentModelRequirements(requirements, content) {
|
|
1277
1437
|
var _a;
|
|
1278
1438
|
// The NOTE commitment makes no changes to the system message or model requirements
|
|
@@ -1335,6 +1495,37 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1335
1495
|
constructor() {
|
|
1336
1496
|
super('PERSONA');
|
|
1337
1497
|
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Markdown documentation for PERSONA commitment.
|
|
1500
|
+
*/
|
|
1501
|
+
get description() {
|
|
1502
|
+
return [
|
|
1503
|
+
'# PERSONA',
|
|
1504
|
+
'',
|
|
1505
|
+
'Defines who the agent is, their background, expertise, and personality traits.',
|
|
1506
|
+
'',
|
|
1507
|
+
'Key behaviors:',
|
|
1508
|
+
'- Multiple PERSONA commitments are merged together.',
|
|
1509
|
+
'- The merged content is placed at the beginning of the system message.',
|
|
1510
|
+
'- Original PERSONA lines are preserved in metadata.PERSONA.',
|
|
1511
|
+
'- Comment lines (# PERSONA) are removed from the final system message.',
|
|
1512
|
+
'',
|
|
1513
|
+
'Effects on system message:',
|
|
1514
|
+
'- Creates a section:',
|
|
1515
|
+
' ```',
|
|
1516
|
+
' # PERSONA',
|
|
1517
|
+
' You are {agentName}',
|
|
1518
|
+
' {merged persona content}',
|
|
1519
|
+
' ```',
|
|
1520
|
+
'',
|
|
1521
|
+
'Examples:',
|
|
1522
|
+
'```book',
|
|
1523
|
+
'PERSONA You are a helpful programming assistant with expertise in TypeScript and React',
|
|
1524
|
+
'PERSONA You have deep knowledge of modern web development practices',
|
|
1525
|
+
'```',
|
|
1526
|
+
'',
|
|
1527
|
+
].join('\n');
|
|
1528
|
+
}
|
|
1338
1529
|
applyToAgentModelRequirements(requirements, content) {
|
|
1339
1530
|
var _a, _b;
|
|
1340
1531
|
// The PERSONA commitment aggregates all persona content and places it at the beginning
|
|
@@ -1435,6 +1626,26 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1435
1626
|
constructor(type = 'RULE') {
|
|
1436
1627
|
super(type);
|
|
1437
1628
|
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Markdown documentation for RULE/RULES commitment.
|
|
1631
|
+
*/
|
|
1632
|
+
get description() {
|
|
1633
|
+
return [
|
|
1634
|
+
`# ${this.type}`,
|
|
1635
|
+
'',
|
|
1636
|
+
'Adds behavioral constraints and guidelines that the agent must follow.',
|
|
1637
|
+
'',
|
|
1638
|
+
'Effects on system message:',
|
|
1639
|
+
'- Appends a "Rule: ..." line to the system message.',
|
|
1640
|
+
'',
|
|
1641
|
+
'Examples:',
|
|
1642
|
+
'```book',
|
|
1643
|
+
'RULE Always ask for clarification if the user\'s request is ambiguous',
|
|
1644
|
+
'RULES Never provide medical advice, always refer to healthcare professionals',
|
|
1645
|
+
'```',
|
|
1646
|
+
'',
|
|
1647
|
+
].join('\n');
|
|
1648
|
+
}
|
|
1438
1649
|
applyToAgentModelRequirements(requirements, content) {
|
|
1439
1650
|
const trimmedContent = content.trim();
|
|
1440
1651
|
if (!trimmedContent) {
|
|
@@ -1480,6 +1691,26 @@ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1480
1691
|
constructor(type = 'SAMPLE') {
|
|
1481
1692
|
super(type);
|
|
1482
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Markdown documentation for SAMPLE/EXAMPLE commitment.
|
|
1696
|
+
*/
|
|
1697
|
+
get description() {
|
|
1698
|
+
return [
|
|
1699
|
+
`# ${this.type}`,
|
|
1700
|
+
'',
|
|
1701
|
+
'Provides examples of how the agent should respond or behave in certain situations.',
|
|
1702
|
+
'',
|
|
1703
|
+
'Effects on system message:',
|
|
1704
|
+
'- Appends an "Example: ..." line to the system message.',
|
|
1705
|
+
'',
|
|
1706
|
+
'Examples:',
|
|
1707
|
+
'```book',
|
|
1708
|
+
'SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."',
|
|
1709
|
+
'EXAMPLE For code questions, always include working code snippets',
|
|
1710
|
+
'```',
|
|
1711
|
+
'',
|
|
1712
|
+
].join('\\n').replace(/\\\\n/g, '\\n');
|
|
1713
|
+
}
|
|
1483
1714
|
applyToAgentModelRequirements(requirements, content) {
|
|
1484
1715
|
const trimmedContent = content.trim();
|
|
1485
1716
|
if (!trimmedContent) {
|
|
@@ -1525,6 +1756,26 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1525
1756
|
constructor() {
|
|
1526
1757
|
super('STYLE');
|
|
1527
1758
|
}
|
|
1759
|
+
/**
|
|
1760
|
+
* Markdown documentation for STYLE commitment.
|
|
1761
|
+
*/
|
|
1762
|
+
get description() {
|
|
1763
|
+
return [
|
|
1764
|
+
'# STYLE',
|
|
1765
|
+
'',
|
|
1766
|
+
'Defines how the agent should format and present its responses (tone, writing style, formatting).',
|
|
1767
|
+
'',
|
|
1768
|
+
'Effects on system message:',
|
|
1769
|
+
'- Appends a "Style: ..." line to the system message.',
|
|
1770
|
+
'',
|
|
1771
|
+
'Examples:',
|
|
1772
|
+
'```book',
|
|
1773
|
+
'STYLE Write in a professional but friendly tone, use bullet points for lists',
|
|
1774
|
+
'STYLE Always provide code examples when explaining programming concepts',
|
|
1775
|
+
'```',
|
|
1776
|
+
'',
|
|
1777
|
+
].join('\n');
|
|
1778
|
+
}
|
|
1528
1779
|
applyToAgentModelRequirements(requirements, content) {
|
|
1529
1780
|
const trimmedContent = content.trim();
|
|
1530
1781
|
if (!trimmedContent) {
|
|
@@ -1557,6 +1808,26 @@ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1557
1808
|
constructor(type) {
|
|
1558
1809
|
super(type);
|
|
1559
1810
|
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Markdown documentation available at runtime.
|
|
1813
|
+
*/
|
|
1814
|
+
get description() {
|
|
1815
|
+
return [
|
|
1816
|
+
`# ${this.type}`,
|
|
1817
|
+
``,
|
|
1818
|
+
`This commitment is not yet fully implemented.`,
|
|
1819
|
+
`Until it is, its content is appended 1:1 to the system message, preserving current behavior.`,
|
|
1820
|
+
``,
|
|
1821
|
+
`- Status: Placeholder`,
|
|
1822
|
+
`- Effect: Appends a line to the system message prefixed by the commitment type`,
|
|
1823
|
+
``,
|
|
1824
|
+
`Example:`,
|
|
1825
|
+
`\`\`\`book`,
|
|
1826
|
+
`${this.type} Your content here`,
|
|
1827
|
+
`\`\`\``,
|
|
1828
|
+
``,
|
|
1829
|
+
].join('\n');
|
|
1830
|
+
}
|
|
1560
1831
|
applyToAgentModelRequirements(requirements, content) {
|
|
1561
1832
|
const trimmedContent = content.trim();
|
|
1562
1833
|
if (!trimmedContent) {
|