@promptbook/core 0.100.0-23 → 0.100.0-25
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 +542 -380
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +28 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +380 -218
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim, { spaceTrim
|
|
1
|
+
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
2
2
|
import { format } from 'prettier';
|
|
3
3
|
import parserHtml from 'prettier/parser-html';
|
|
4
4
|
import { randomBytes } from 'crypto';
|
|
@@ -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-25';
|
|
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
|
|
@@ -217,21 +217,38 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
217
217
|
* Markdown documentation for ACTION commitment.
|
|
218
218
|
*/
|
|
219
219
|
get documentation() {
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
'
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
220
|
+
return spaceTrim(`
|
|
221
|
+
# ACTION
|
|
222
|
+
|
|
223
|
+
Defines specific actions or capabilities that the agent can perform.
|
|
224
|
+
|
|
225
|
+
## Key behaviors
|
|
226
|
+
|
|
227
|
+
- Multiple \`ACTION\` commitments are applied sequentially.
|
|
228
|
+
- Each action adds to the agent's capability list.
|
|
229
|
+
- Actions help users understand what the agent can do.
|
|
230
|
+
|
|
231
|
+
## Examples
|
|
232
|
+
|
|
233
|
+
\`\`\`book
|
|
234
|
+
Code Assistant
|
|
235
|
+
|
|
236
|
+
PERSONA You are a programming assistant
|
|
237
|
+
ACTION Can generate code snippets and explain programming concepts
|
|
238
|
+
ACTION Able to debug existing code and suggest improvements
|
|
239
|
+
ACTION Can create unit tests for functions
|
|
240
|
+
\`\`\`
|
|
241
|
+
|
|
242
|
+
\`\`\`book
|
|
243
|
+
Data Scientist
|
|
244
|
+
|
|
245
|
+
PERSONA You are a data analysis expert
|
|
246
|
+
ACTION Able to analyze data and provide insights
|
|
247
|
+
ACTION Can create visualizations and charts
|
|
248
|
+
ACTION Capable of statistical analysis and modeling
|
|
249
|
+
KNOWLEDGE Data analysis best practices and statistical methods
|
|
250
|
+
\`\`\`
|
|
251
|
+
`);
|
|
235
252
|
}
|
|
236
253
|
applyToAgentModelRequirements(requirements, content) {
|
|
237
254
|
const trimmedContent = content.trim();
|
|
@@ -283,21 +300,36 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
283
300
|
* Markdown documentation for FORMAT commitment.
|
|
284
301
|
*/
|
|
285
302
|
get documentation() {
|
|
286
|
-
return
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
303
|
+
return spaceTrim(`
|
|
304
|
+
# FORMAT
|
|
305
|
+
|
|
306
|
+
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
307
|
+
|
|
308
|
+
## Key behaviors
|
|
309
|
+
|
|
310
|
+
- Multiple \`FORMAT\` commitments are applied sequentially.
|
|
311
|
+
- If they are in conflict, the last one takes precedence.
|
|
312
|
+
- You can specify both data formats and presentation styles.
|
|
313
|
+
|
|
314
|
+
## Examples
|
|
315
|
+
|
|
316
|
+
\`\`\`book
|
|
317
|
+
Customer Support Bot
|
|
318
|
+
|
|
319
|
+
PERSONA You are a helpful customer support agent
|
|
320
|
+
FORMAT Always respond in JSON format with 'status' and 'data' fields
|
|
321
|
+
FORMAT Use markdown formatting for all code blocks
|
|
322
|
+
\`\`\`
|
|
323
|
+
|
|
324
|
+
\`\`\`book
|
|
325
|
+
Data Analyst
|
|
326
|
+
|
|
327
|
+
PERSONA You are a data analysis expert
|
|
328
|
+
FORMAT Present results in structured tables
|
|
329
|
+
FORMAT Include confidence scores for all predictions
|
|
330
|
+
STYLE Be concise and precise in explanations
|
|
331
|
+
\`\`\`
|
|
332
|
+
`);
|
|
301
333
|
}
|
|
302
334
|
applyToAgentModelRequirements(requirements, content) {
|
|
303
335
|
const trimmedContent = content.trim();
|
|
@@ -690,7 +722,7 @@ true);
|
|
|
690
722
|
function getErrorReportUrl(error) {
|
|
691
723
|
const report = {
|
|
692
724
|
title: `🐜 Error report from ${NAME}`,
|
|
693
|
-
body: spaceTrim((block) => `
|
|
725
|
+
body: spaceTrim$1((block) => `
|
|
694
726
|
|
|
695
727
|
|
|
696
728
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -733,7 +765,7 @@ function getErrorReportUrl(error) {
|
|
|
733
765
|
*/
|
|
734
766
|
class UnexpectedError extends Error {
|
|
735
767
|
constructor(message) {
|
|
736
|
-
super(spaceTrim
|
|
768
|
+
super(spaceTrim((block) => `
|
|
737
769
|
${block(message)}
|
|
738
770
|
|
|
739
771
|
Note: This error should not happen.
|
|
@@ -759,7 +791,7 @@ class WrappedError extends Error {
|
|
|
759
791
|
constructor(whatWasThrown) {
|
|
760
792
|
const tag = `[🤮]`;
|
|
761
793
|
console.error(tag, whatWasThrown);
|
|
762
|
-
super(spaceTrim
|
|
794
|
+
super(spaceTrim(`
|
|
763
795
|
Non-Error object was thrown
|
|
764
796
|
|
|
765
797
|
Note: Look for ${tag} in the console for more details
|
|
@@ -816,7 +848,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
816
848
|
else if (urlOrRequest instanceof Request) {
|
|
817
849
|
url = urlOrRequest.url;
|
|
818
850
|
}
|
|
819
|
-
throw new PromptbookFetchError(spaceTrim((block) => `
|
|
851
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
820
852
|
Can not fetch "${url}"
|
|
821
853
|
|
|
822
854
|
Fetch error:
|
|
@@ -1061,27 +1093,45 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1061
1093
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
1062
1094
|
*/
|
|
1063
1095
|
get documentation() {
|
|
1064
|
-
return
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1096
|
+
return spaceTrim(`
|
|
1097
|
+
# KNOWLEDGE
|
|
1098
|
+
|
|
1099
|
+
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
1100
|
+
|
|
1101
|
+
## Key behaviors
|
|
1102
|
+
|
|
1103
|
+
- Multiple \`KNOWLEDGE\` commitments are applied sequentially.
|
|
1104
|
+
- Supports both direct text knowledge and external URLs.
|
|
1105
|
+
- External sources (PDFs, websites) are processed via RAG for context retrieval.
|
|
1106
|
+
|
|
1107
|
+
## Supported formats
|
|
1108
|
+
|
|
1109
|
+
- Direct text: Immediate knowledge incorporated into agent
|
|
1110
|
+
- URLs: External documents processed for contextual retrieval
|
|
1111
|
+
- Supported file types: PDF, text, markdown, HTML
|
|
1112
|
+
|
|
1113
|
+
## Examples
|
|
1114
|
+
|
|
1115
|
+
\`\`\`book
|
|
1116
|
+
Customer Support Bot
|
|
1117
|
+
|
|
1118
|
+
PERSONA You are a helpful customer support agent for TechCorp
|
|
1119
|
+
KNOWLEDGE TechCorp was founded in 2020 and specializes in AI-powered solutions
|
|
1120
|
+
KNOWLEDGE https://example.com/company-handbook.pdf
|
|
1121
|
+
KNOWLEDGE https://example.com/product-documentation.pdf
|
|
1122
|
+
RULE Always be polite and professional
|
|
1123
|
+
\`\`\`
|
|
1124
|
+
|
|
1125
|
+
\`\`\`book
|
|
1126
|
+
Research Assistant
|
|
1127
|
+
|
|
1128
|
+
PERSONA You are a knowledgeable research assistant
|
|
1129
|
+
KNOWLEDGE Academic research requires careful citation and verification
|
|
1130
|
+
KNOWLEDGE https://example.com/research-guidelines.pdf
|
|
1131
|
+
ACTION Can help with literature reviews and data analysis
|
|
1132
|
+
STYLE Present information in clear, academic format
|
|
1133
|
+
\`\`\`
|
|
1134
|
+
`);
|
|
1085
1135
|
}
|
|
1086
1136
|
applyToAgentModelRequirements(requirements, content) {
|
|
1087
1137
|
var _a;
|
|
@@ -1172,24 +1222,37 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1172
1222
|
* Markdown documentation for META IMAGE commitment.
|
|
1173
1223
|
*/
|
|
1174
1224
|
get documentation() {
|
|
1175
|
-
return
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
.
|
|
1225
|
+
return spaceTrim(`
|
|
1226
|
+
# META IMAGE
|
|
1227
|
+
|
|
1228
|
+
Sets the agent's avatar/profile image URL.
|
|
1229
|
+
|
|
1230
|
+
## Key behaviors
|
|
1231
|
+
|
|
1232
|
+
- Does not modify the agent's behavior or responses.
|
|
1233
|
+
- Only one \`META IMAGE\` should be used per agent.
|
|
1234
|
+
- If multiple are specified, the last one takes precedence.
|
|
1235
|
+
- Used for visual representation in user interfaces.
|
|
1236
|
+
|
|
1237
|
+
## Examples
|
|
1238
|
+
|
|
1239
|
+
\`\`\`book
|
|
1240
|
+
Professional Assistant
|
|
1241
|
+
|
|
1242
|
+
META IMAGE https://example.com/professional-avatar.jpg
|
|
1243
|
+
PERSONA You are a professional business assistant
|
|
1244
|
+
STYLE Maintain a formal and courteous tone
|
|
1245
|
+
\`\`\`
|
|
1246
|
+
|
|
1247
|
+
\`\`\`book
|
|
1248
|
+
Creative Helper
|
|
1249
|
+
|
|
1250
|
+
META IMAGE /assets/creative-bot-avatar.png
|
|
1251
|
+
PERSONA You are a creative and inspiring assistant
|
|
1252
|
+
STYLE Be enthusiastic and encouraging
|
|
1253
|
+
ACTION Can help with brainstorming and ideation
|
|
1254
|
+
\`\`\`
|
|
1255
|
+
`);
|
|
1193
1256
|
}
|
|
1194
1257
|
applyToAgentModelRequirements(requirements, content) {
|
|
1195
1258
|
// META IMAGE doesn't modify the system message or model requirements
|
|
@@ -1254,26 +1317,39 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1254
1317
|
* Markdown documentation for META LINK commitment.
|
|
1255
1318
|
*/
|
|
1256
1319
|
get documentation() {
|
|
1257
|
-
return
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
.
|
|
1276
|
-
.
|
|
1320
|
+
return spaceTrim(`
|
|
1321
|
+
# META LINK
|
|
1322
|
+
|
|
1323
|
+
Represents a profile or source link for the person the agent is modeled after.
|
|
1324
|
+
|
|
1325
|
+
## Key behaviors
|
|
1326
|
+
|
|
1327
|
+
- Does not modify the agent's behavior or responses.
|
|
1328
|
+
- Multiple \`META LINK\` commitments can be used for different social profiles.
|
|
1329
|
+
- Used for attribution and crediting the original person.
|
|
1330
|
+
- Displayed in user interfaces for transparency.
|
|
1331
|
+
|
|
1332
|
+
## Examples
|
|
1333
|
+
|
|
1334
|
+
\`\`\`book
|
|
1335
|
+
Expert Consultant
|
|
1336
|
+
|
|
1337
|
+
META LINK https://twitter.com/expertname
|
|
1338
|
+
META LINK https://linkedin.com/in/expertprofile
|
|
1339
|
+
PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
|
|
1340
|
+
KNOWLEDGE Extensive background in machine learning and neural networks
|
|
1341
|
+
\`\`\`
|
|
1342
|
+
|
|
1343
|
+
\`\`\`book
|
|
1344
|
+
Open Source Developer
|
|
1345
|
+
|
|
1346
|
+
META LINK https://github.com/developer
|
|
1347
|
+
META LINK https://twitter.com/devhandle
|
|
1348
|
+
PERSONA You are an experienced open source developer
|
|
1349
|
+
ACTION Can help with code reviews and architecture decisions
|
|
1350
|
+
STYLE Be direct and technical in explanations
|
|
1351
|
+
\`\`\`
|
|
1352
|
+
`);
|
|
1277
1353
|
}
|
|
1278
1354
|
applyToAgentModelRequirements(requirements, content) {
|
|
1279
1355
|
// META LINK doesn't modify the system message or model requirements
|
|
@@ -1342,28 +1418,42 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1342
1418
|
* Markdown documentation for MODEL commitment.
|
|
1343
1419
|
*/
|
|
1344
1420
|
get documentation() {
|
|
1345
|
-
return
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1421
|
+
return spaceTrim(`
|
|
1422
|
+
# MODEL
|
|
1423
|
+
|
|
1424
|
+
Specifies which AI model to use and optional decoding parameters.
|
|
1425
|
+
|
|
1426
|
+
## Key behaviors
|
|
1427
|
+
|
|
1428
|
+
- Only one \`MODEL\` commitment should be used per agent.
|
|
1429
|
+
- If multiple are specified, the last one takes precedence.
|
|
1430
|
+
- Parameters control the randomness and creativity of responses.
|
|
1431
|
+
|
|
1432
|
+
## Supported parameters
|
|
1433
|
+
|
|
1434
|
+
- \`temperature\`: Controls randomness (0.0 = deterministic, 1.0+ = creative)
|
|
1435
|
+
- \`topP\` (aka \`top_p\`): Nucleus sampling parameter
|
|
1436
|
+
- \`topK\` (aka \`top_k\`): Top-k sampling parameter
|
|
1437
|
+
|
|
1438
|
+
## Examples
|
|
1439
|
+
|
|
1440
|
+
\`\`\`book
|
|
1441
|
+
Precise Assistant
|
|
1442
|
+
|
|
1443
|
+
PERSONA You are a precise and accurate assistant
|
|
1444
|
+
MODEL gpt-4 temperature=0.1
|
|
1445
|
+
RULE Always provide factual information
|
|
1446
|
+
\`\`\`
|
|
1447
|
+
|
|
1448
|
+
\`\`\`book
|
|
1449
|
+
Creative Writer
|
|
1450
|
+
|
|
1451
|
+
PERSONA You are a creative writing assistant
|
|
1452
|
+
MODEL claude-3-opus temperature=0.8 topP=0.9
|
|
1453
|
+
STYLE Be imaginative and expressive
|
|
1454
|
+
ACTION Can help with storytelling and character development
|
|
1455
|
+
\`\`\`
|
|
1456
|
+
`);
|
|
1367
1457
|
}
|
|
1368
1458
|
applyToAgentModelRequirements(requirements, content) {
|
|
1369
1459
|
const trimmedContent = content.trim();
|
|
@@ -1460,24 +1550,40 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1460
1550
|
* Markdown documentation for NOTE commitment.
|
|
1461
1551
|
*/
|
|
1462
1552
|
get documentation() {
|
|
1463
|
-
return
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1553
|
+
return spaceTrim(`
|
|
1554
|
+
# NOTE
|
|
1555
|
+
|
|
1556
|
+
Adds comments for documentation without changing agent behavior.
|
|
1557
|
+
|
|
1558
|
+
## Key behaviors
|
|
1559
|
+
|
|
1560
|
+
- Does not modify the agent's behavior or responses.
|
|
1561
|
+
- Multiple \`NOTE\` commitments are aggregated for debugging.
|
|
1562
|
+
- Useful for documenting design decisions and reminders.
|
|
1563
|
+
- Content is preserved in metadata for inspection.
|
|
1564
|
+
|
|
1565
|
+
## Examples
|
|
1566
|
+
|
|
1567
|
+
\`\`\`book
|
|
1568
|
+
Customer Support Bot
|
|
1569
|
+
|
|
1570
|
+
NOTE This agent was designed for customer support scenarios
|
|
1571
|
+
NOTE Remember to update the knowledge base monthly
|
|
1572
|
+
PERSONA You are a helpful customer support representative
|
|
1573
|
+
KNOWLEDGE Company policies and procedures
|
|
1574
|
+
RULE Always be polite and professional
|
|
1575
|
+
\`\`\`
|
|
1576
|
+
|
|
1577
|
+
\`\`\`book
|
|
1578
|
+
Research Assistant
|
|
1579
|
+
|
|
1580
|
+
NOTE Performance optimized for quick response times
|
|
1581
|
+
NOTE Uses RAG for accessing latest research papers
|
|
1582
|
+
PERSONA You are a knowledgeable research assistant
|
|
1583
|
+
ACTION Can help with literature reviews and citations
|
|
1584
|
+
STYLE Present information in academic format
|
|
1585
|
+
\`\`\`
|
|
1586
|
+
`);
|
|
1481
1587
|
}
|
|
1482
1588
|
applyToAgentModelRequirements(requirements, content) {
|
|
1483
1589
|
var _a;
|
|
@@ -1551,32 +1657,26 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1551
1657
|
* Markdown documentation for PERSONA commitment.
|
|
1552
1658
|
*/
|
|
1553
1659
|
get documentation() {
|
|
1554
|
-
return
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
'```book',
|
|
1575
|
-
'PERSONA You are a helpful programming assistant with expertise in TypeScript and React',
|
|
1576
|
-
'PERSONA You have deep knowledge of modern web development practices',
|
|
1577
|
-
'```',
|
|
1578
|
-
'',
|
|
1579
|
-
].join('\n');
|
|
1660
|
+
return spaceTrim(`
|
|
1661
|
+
# PERSONA
|
|
1662
|
+
|
|
1663
|
+
Defines who the agent is, their background, expertise, and personality traits.
|
|
1664
|
+
|
|
1665
|
+
## Key behaviors
|
|
1666
|
+
|
|
1667
|
+
- Multiple \`PERSONA\` commitments are merged together.
|
|
1668
|
+
- If they are in conflict, the last one takes precedence.
|
|
1669
|
+
- You can write persona content in multiple lines.
|
|
1670
|
+
|
|
1671
|
+
## Examples
|
|
1672
|
+
|
|
1673
|
+
\`\`\`book
|
|
1674
|
+
Programming Assistant
|
|
1675
|
+
|
|
1676
|
+
PERSONA You are a helpful programming assistant with expertise in TypeScript and React
|
|
1677
|
+
PERSONA You have deep knowledge of modern web development practices
|
|
1678
|
+
\`\`\`
|
|
1679
|
+
`);
|
|
1580
1680
|
}
|
|
1581
1681
|
applyToAgentModelRequirements(requirements, content) {
|
|
1582
1682
|
var _a, _b;
|
|
@@ -1688,21 +1788,39 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1688
1788
|
* Markdown documentation for RULE/RULES commitment.
|
|
1689
1789
|
*/
|
|
1690
1790
|
get documentation() {
|
|
1691
|
-
return
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1791
|
+
return spaceTrim(`
|
|
1792
|
+
# ${this.type}
|
|
1793
|
+
|
|
1794
|
+
Adds behavioral constraints and guidelines that the agent must follow.
|
|
1795
|
+
|
|
1796
|
+
## Key behaviors
|
|
1797
|
+
|
|
1798
|
+
- Multiple \`RULE\` and \`RULES\` commitments are applied sequentially.
|
|
1799
|
+
- All rules are treated equally regardless of singular/plural form.
|
|
1800
|
+
- Rules define what the agent must or must not do.
|
|
1801
|
+
|
|
1802
|
+
## Examples
|
|
1803
|
+
|
|
1804
|
+
\`\`\`book
|
|
1805
|
+
Customer Support Agent
|
|
1806
|
+
|
|
1807
|
+
PERSONA You are a helpful customer support representative
|
|
1808
|
+
RULE Always ask for clarification if the user's request is ambiguous
|
|
1809
|
+
RULE Be polite and professional in all interactions
|
|
1810
|
+
RULES Never provide medical or legal advice
|
|
1811
|
+
STYLE Maintain a friendly and helpful tone
|
|
1812
|
+
\`\`\`
|
|
1813
|
+
|
|
1814
|
+
\`\`\`book
|
|
1815
|
+
Educational Tutor
|
|
1816
|
+
|
|
1817
|
+
PERSONA You are a patient and knowledgeable tutor
|
|
1818
|
+
RULE Break down complex concepts into simple steps
|
|
1819
|
+
RULE Always encourage students and celebrate their progress
|
|
1820
|
+
RULE If you don't know something, admit it and suggest resources
|
|
1821
|
+
SAMPLE When explaining math: "Let's work through this step by step..."
|
|
1822
|
+
\`\`\`
|
|
1823
|
+
`);
|
|
1706
1824
|
}
|
|
1707
1825
|
applyToAgentModelRequirements(requirements, content) {
|
|
1708
1826
|
const trimmedContent = content.trim();
|
|
@@ -1759,23 +1877,38 @@ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1759
1877
|
* Markdown documentation for SAMPLE/EXAMPLE commitment.
|
|
1760
1878
|
*/
|
|
1761
1879
|
get documentation() {
|
|
1762
|
-
return
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
'
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1880
|
+
return spaceTrim(`
|
|
1881
|
+
# ${this.type}
|
|
1882
|
+
|
|
1883
|
+
Provides examples of how the agent should respond or behave in certain situations.
|
|
1884
|
+
|
|
1885
|
+
## Key behaviors
|
|
1886
|
+
|
|
1887
|
+
- Multiple \`SAMPLE\` and \`EXAMPLE\` commitments are applied sequentially.
|
|
1888
|
+
- Both terms work identically and can be used interchangeably.
|
|
1889
|
+
- Examples help guide the agent's response patterns and style.
|
|
1890
|
+
|
|
1891
|
+
## Examples
|
|
1892
|
+
|
|
1893
|
+
\`\`\`book
|
|
1894
|
+
Sales Assistant
|
|
1895
|
+
|
|
1896
|
+
PERSONA You are a knowledgeable sales representative
|
|
1897
|
+
SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
|
|
1898
|
+
SAMPLE For feature comparisons, create a clear comparison table
|
|
1899
|
+
RULE Always be honest about limitations
|
|
1900
|
+
\`\`\`
|
|
1901
|
+
|
|
1902
|
+
\`\`\`book
|
|
1903
|
+
Code Reviewer
|
|
1904
|
+
|
|
1905
|
+
PERSONA You are an experienced software engineer
|
|
1906
|
+
EXAMPLE For code questions, always include working code snippets
|
|
1907
|
+
EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
|
|
1908
|
+
RULE Explain the reasoning behind your suggestions
|
|
1909
|
+
STYLE Be constructive and encouraging in feedback
|
|
1910
|
+
\`\`\`
|
|
1911
|
+
`);
|
|
1779
1912
|
}
|
|
1780
1913
|
applyToAgentModelRequirements(requirements, content) {
|
|
1781
1914
|
const trimmedContent = content.trim();
|
|
@@ -1832,21 +1965,38 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1832
1965
|
* Markdown documentation for STYLE commitment.
|
|
1833
1966
|
*/
|
|
1834
1967
|
get documentation() {
|
|
1835
|
-
return
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1968
|
+
return spaceTrim(`
|
|
1969
|
+
# STYLE
|
|
1970
|
+
|
|
1971
|
+
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
1972
|
+
|
|
1973
|
+
## Key behaviors
|
|
1974
|
+
|
|
1975
|
+
- Multiple \`STYLE\` commitments are applied sequentially.
|
|
1976
|
+
- Later style instructions can override earlier ones.
|
|
1977
|
+
- Style affects both tone and presentation format.
|
|
1978
|
+
|
|
1979
|
+
## Examples
|
|
1980
|
+
|
|
1981
|
+
\`\`\`book
|
|
1982
|
+
Technical Writer
|
|
1983
|
+
|
|
1984
|
+
PERSONA You are a technical documentation expert
|
|
1985
|
+
STYLE Write in a professional but friendly tone, use bullet points for lists
|
|
1986
|
+
STYLE Always provide code examples when explaining programming concepts
|
|
1987
|
+
FORMAT Use markdown formatting with clear headings
|
|
1988
|
+
\`\`\`
|
|
1989
|
+
|
|
1990
|
+
\`\`\`book
|
|
1991
|
+
Creative Assistant
|
|
1992
|
+
|
|
1993
|
+
PERSONA You are a creative writing helper
|
|
1994
|
+
STYLE Be enthusiastic and encouraging in your responses
|
|
1995
|
+
STYLE Use vivid metaphors and analogies to explain concepts
|
|
1996
|
+
STYLE Keep responses conversational and engaging
|
|
1997
|
+
RULE Always maintain a positive and supportive tone
|
|
1998
|
+
\`\`\`
|
|
1999
|
+
`);
|
|
1850
2000
|
}
|
|
1851
2001
|
applyToAgentModelRequirements(requirements, content) {
|
|
1852
2002
|
const trimmedContent = content.trim();
|
|
@@ -1890,21 +2040,33 @@ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
1890
2040
|
* Markdown documentation available at runtime.
|
|
1891
2041
|
*/
|
|
1892
2042
|
get documentation() {
|
|
1893
|
-
return
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2043
|
+
return spaceTrim(`
|
|
2044
|
+
# ${this.type}
|
|
2045
|
+
|
|
2046
|
+
This commitment is not yet fully implemented.
|
|
2047
|
+
|
|
2048
|
+
## Key behaviors
|
|
2049
|
+
|
|
2050
|
+
- Content is appended directly to the system message.
|
|
2051
|
+
- No special processing or validation is performed.
|
|
2052
|
+
- Behavior preserved until proper implementation is added.
|
|
2053
|
+
|
|
2054
|
+
## Status
|
|
2055
|
+
|
|
2056
|
+
- **Status:** Placeholder implementation
|
|
2057
|
+
- **Effect:** Appends content prefixed by commitment type
|
|
2058
|
+
- **Future:** Will be replaced with specialized logic
|
|
2059
|
+
|
|
2060
|
+
## Examples
|
|
2061
|
+
|
|
2062
|
+
\`\`\`book
|
|
2063
|
+
Example Agent
|
|
2064
|
+
|
|
2065
|
+
PERSONA You are a helpful assistant
|
|
2066
|
+
${this.type} Your content here
|
|
2067
|
+
RULE Always be helpful
|
|
2068
|
+
\`\`\`
|
|
2069
|
+
`);
|
|
1908
2070
|
}
|
|
1909
2071
|
applyToAgentModelRequirements(requirements, content) {
|
|
1910
2072
|
const trimmedContent = content.trim();
|
|
@@ -2037,7 +2199,7 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
2037
2199
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
2038
2200
|
commitments.push({
|
|
2039
2201
|
type: currentCommitment.type,
|
|
2040
|
-
content: spaceTrim
|
|
2202
|
+
content: spaceTrim(fullContent),
|
|
2041
2203
|
originalLine: currentCommitment.originalStartLine,
|
|
2042
2204
|
lineNumber: currentCommitment.startLineNumber,
|
|
2043
2205
|
});
|
|
@@ -2073,7 +2235,7 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
2073
2235
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
2074
2236
|
commitments.push({
|
|
2075
2237
|
type: currentCommitment.type,
|
|
2076
|
-
content: spaceTrim
|
|
2238
|
+
content: spaceTrim(fullContent),
|
|
2077
2239
|
originalLine: currentCommitment.originalStartLine,
|
|
2078
2240
|
lineNumber: currentCommitment.startLineNumber,
|
|
2079
2241
|
});
|
|
@@ -2167,7 +2329,7 @@ function validateBook(source) {
|
|
|
2167
2329
|
*
|
|
2168
2330
|
* @public exported from `@promptbook/core`
|
|
2169
2331
|
*/
|
|
2170
|
-
const DEFAULT_BOOK = validateBook(spaceTrim(`
|
|
2332
|
+
const DEFAULT_BOOK = validateBook(spaceTrim$1(`
|
|
2171
2333
|
AI Avatar
|
|
2172
2334
|
|
|
2173
2335
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -2704,7 +2866,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2704
2866
|
pipelineString += '\n\n';
|
|
2705
2867
|
pipelineString += '```' + contentLanguage;
|
|
2706
2868
|
pipelineString += '\n';
|
|
2707
|
-
pipelineString += spaceTrim(content);
|
|
2869
|
+
pipelineString += spaceTrim$1(content);
|
|
2708
2870
|
// <- TODO: [main] !!3 Escape
|
|
2709
2871
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2710
2872
|
pipelineString += '\n';
|
|
@@ -2798,7 +2960,7 @@ function checkSerializableAsJson(options) {
|
|
|
2798
2960
|
}
|
|
2799
2961
|
else if (typeof value === 'object') {
|
|
2800
2962
|
if (value instanceof Date) {
|
|
2801
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2963
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2802
2964
|
\`${name}\` is Date
|
|
2803
2965
|
|
|
2804
2966
|
Use \`string_date_iso8601\` instead
|
|
@@ -2817,7 +2979,7 @@ function checkSerializableAsJson(options) {
|
|
|
2817
2979
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2818
2980
|
}
|
|
2819
2981
|
else if (value instanceof Error) {
|
|
2820
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2982
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2821
2983
|
\`${name}\` is unserialized Error
|
|
2822
2984
|
|
|
2823
2985
|
Use function \`serializeError\`
|
|
@@ -2840,7 +3002,7 @@ function checkSerializableAsJson(options) {
|
|
|
2840
3002
|
}
|
|
2841
3003
|
catch (error) {
|
|
2842
3004
|
assertsError(error);
|
|
2843
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
3005
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2844
3006
|
\`${name}\` is not serializable
|
|
2845
3007
|
|
|
2846
3008
|
${block(error.stack || error.message)}
|
|
@@ -2872,7 +3034,7 @@ function checkSerializableAsJson(options) {
|
|
|
2872
3034
|
}
|
|
2873
3035
|
}
|
|
2874
3036
|
else {
|
|
2875
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
3037
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2876
3038
|
\`${name}\` is unknown type
|
|
2877
3039
|
|
|
2878
3040
|
Additional message for \`${name}\`:
|
|
@@ -3159,7 +3321,7 @@ function validatePipeline(pipeline) {
|
|
|
3159
3321
|
if (!(error instanceof PipelineLogicError)) {
|
|
3160
3322
|
throw error;
|
|
3161
3323
|
}
|
|
3162
|
-
console.error(spaceTrim
|
|
3324
|
+
console.error(spaceTrim((block) => `
|
|
3163
3325
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
3164
3326
|
|
|
3165
3327
|
${block(error.message)}
|
|
@@ -3186,7 +3348,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3186
3348
|
})();
|
|
3187
3349
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
3188
3350
|
// <- Note: [🚲]
|
|
3189
|
-
throw new PipelineLogicError(spaceTrim
|
|
3351
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3190
3352
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
3191
3353
|
|
|
3192
3354
|
${block(pipelineIdentification)}
|
|
@@ -3194,7 +3356,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3194
3356
|
}
|
|
3195
3357
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
3196
3358
|
// <- Note: [🚲]
|
|
3197
|
-
throw new PipelineLogicError(spaceTrim
|
|
3359
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3198
3360
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
3199
3361
|
|
|
3200
3362
|
${block(pipelineIdentification)}
|
|
@@ -3203,7 +3365,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3203
3365
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
3204
3366
|
if (!Array.isArray(pipeline.parameters)) {
|
|
3205
3367
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
3206
|
-
throw new ParseError(spaceTrim
|
|
3368
|
+
throw new ParseError(spaceTrim((block) => `
|
|
3207
3369
|
Pipeline is valid JSON but with wrong structure
|
|
3208
3370
|
|
|
3209
3371
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -3214,7 +3376,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3214
3376
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
3215
3377
|
if (!Array.isArray(pipeline.tasks)) {
|
|
3216
3378
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
3217
|
-
throw new ParseError(spaceTrim
|
|
3379
|
+
throw new ParseError(spaceTrim((block) => `
|
|
3218
3380
|
Pipeline is valid JSON but with wrong structure
|
|
3219
3381
|
|
|
3220
3382
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -3240,7 +3402,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3240
3402
|
// Note: Check each parameter individually
|
|
3241
3403
|
for (const parameter of pipeline.parameters) {
|
|
3242
3404
|
if (parameter.isInput && parameter.isOutput) {
|
|
3243
|
-
throw new PipelineLogicError(spaceTrim
|
|
3405
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3244
3406
|
|
|
3245
3407
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
3246
3408
|
|
|
@@ -3251,7 +3413,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3251
3413
|
if (!parameter.isInput &&
|
|
3252
3414
|
!parameter.isOutput &&
|
|
3253
3415
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
3254
|
-
throw new PipelineLogicError(spaceTrim
|
|
3416
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3255
3417
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
3256
3418
|
|
|
3257
3419
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -3263,7 +3425,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3263
3425
|
}
|
|
3264
3426
|
// Note: Testing that parameter is either input or result of some task
|
|
3265
3427
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
3266
|
-
throw new PipelineLogicError(spaceTrim
|
|
3428
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3267
3429
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
3268
3430
|
|
|
3269
3431
|
You can do one of these:
|
|
@@ -3279,14 +3441,14 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3279
3441
|
// Note: Checking each task individually
|
|
3280
3442
|
for (const task of pipeline.tasks) {
|
|
3281
3443
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
3282
|
-
throw new PipelineLogicError(spaceTrim
|
|
3444
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3283
3445
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
3284
3446
|
|
|
3285
3447
|
${block(pipelineIdentification)}
|
|
3286
3448
|
`));
|
|
3287
3449
|
}
|
|
3288
3450
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
3289
|
-
throw new PipelineLogicError(spaceTrim
|
|
3451
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3290
3452
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
3291
3453
|
|
|
3292
3454
|
${block(pipelineIdentification)}
|
|
@@ -3296,7 +3458,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3296
3458
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
3297
3459
|
if (!task.format &&
|
|
3298
3460
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
3299
|
-
throw new PipelineLogicError(spaceTrim
|
|
3461
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3300
3462
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
3301
3463
|
|
|
3302
3464
|
${block(pipelineIdentification)}
|
|
@@ -3304,7 +3466,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3304
3466
|
}
|
|
3305
3467
|
for (const joker of task.jokerParameterNames) {
|
|
3306
3468
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
3307
|
-
throw new PipelineLogicError(spaceTrim
|
|
3469
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3308
3470
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
3309
3471
|
|
|
3310
3472
|
${block(pipelineIdentification)}
|
|
@@ -3315,21 +3477,21 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3315
3477
|
if (task.expectations) {
|
|
3316
3478
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
3317
3479
|
if (min !== undefined && max !== undefined && min > max) {
|
|
3318
|
-
throw new PipelineLogicError(spaceTrim
|
|
3480
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3319
3481
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
3320
3482
|
|
|
3321
3483
|
${block(pipelineIdentification)}
|
|
3322
3484
|
`));
|
|
3323
3485
|
}
|
|
3324
3486
|
if (min !== undefined && min < 0) {
|
|
3325
|
-
throw new PipelineLogicError(spaceTrim
|
|
3487
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3326
3488
|
Min expectation of ${unit} must be zero or positive
|
|
3327
3489
|
|
|
3328
3490
|
${block(pipelineIdentification)}
|
|
3329
3491
|
`));
|
|
3330
3492
|
}
|
|
3331
3493
|
if (max !== undefined && max <= 0) {
|
|
3332
|
-
throw new PipelineLogicError(spaceTrim
|
|
3494
|
+
throw new PipelineLogicError(spaceTrim((block) => `
|
|
3333
3495
|
Max expectation of ${unit} must be positive
|
|
3334
3496
|
|
|
3335
3497
|
${block(pipelineIdentification)}
|
|
@@ -3351,7 +3513,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3351
3513
|
while (unresovedTasks.length > 0) {
|
|
3352
3514
|
if (loopLimit-- < 0) {
|
|
3353
3515
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
3354
|
-
throw new UnexpectedError(spaceTrim
|
|
3516
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
3355
3517
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
3356
3518
|
|
|
3357
3519
|
${block(pipelineIdentification)}
|
|
@@ -3361,7 +3523,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
3361
3523
|
if (currentlyResovedTasks.length === 0) {
|
|
3362
3524
|
throw new PipelineLogicError(
|
|
3363
3525
|
// TODO: [🐎] DRY
|
|
3364
|
-
spaceTrim
|
|
3526
|
+
spaceTrim((block) => `
|
|
3365
3527
|
|
|
3366
3528
|
Can not resolve some parameters:
|
|
3367
3529
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -3525,7 +3687,7 @@ class SimplePipelineCollection {
|
|
|
3525
3687
|
for (const pipeline of pipelines) {
|
|
3526
3688
|
// TODO: [👠] DRY
|
|
3527
3689
|
if (pipeline.pipelineUrl === undefined) {
|
|
3528
|
-
throw new PipelineUrlError(spaceTrim
|
|
3690
|
+
throw new PipelineUrlError(spaceTrim(`
|
|
3529
3691
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
3530
3692
|
|
|
3531
3693
|
File:
|
|
@@ -3547,7 +3709,7 @@ class SimplePipelineCollection {
|
|
|
3547
3709
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
3548
3710
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
3549
3711
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
3550
|
-
throw new PipelineUrlError(spaceTrim
|
|
3712
|
+
throw new PipelineUrlError(spaceTrim(`
|
|
3551
3713
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
3552
3714
|
|
|
3553
3715
|
Conflicting files:
|
|
@@ -3579,13 +3741,13 @@ class SimplePipelineCollection {
|
|
|
3579
3741
|
const pipeline = this.collection.get(url);
|
|
3580
3742
|
if (!pipeline) {
|
|
3581
3743
|
if (this.listPipelines().length === 0) {
|
|
3582
|
-
throw new NotFoundError(spaceTrim
|
|
3744
|
+
throw new NotFoundError(spaceTrim(`
|
|
3583
3745
|
Pipeline with url "${url}" not found
|
|
3584
3746
|
|
|
3585
3747
|
No pipelines available
|
|
3586
3748
|
`));
|
|
3587
3749
|
}
|
|
3588
|
-
throw new NotFoundError(spaceTrim
|
|
3750
|
+
throw new NotFoundError(spaceTrim((block) => `
|
|
3589
3751
|
Pipeline with url "${url}" not found
|
|
3590
3752
|
|
|
3591
3753
|
Available pipelines:
|
|
@@ -3715,7 +3877,7 @@ function createSubcollection(collection, predicate) {
|
|
|
3715
3877
|
}
|
|
3716
3878
|
async function getPipelineByUrl(url) {
|
|
3717
3879
|
if (!predicate(url)) {
|
|
3718
|
-
throw new NotFoundError(await spaceTrim
|
|
3880
|
+
throw new NotFoundError(await spaceTrim(async (block) => `
|
|
3719
3881
|
Promptbook with url "${url}" not found or not accessible
|
|
3720
3882
|
|
|
3721
3883
|
Available promptbooks:
|
|
@@ -3750,7 +3912,7 @@ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"
|
|
|
3750
3912
|
*/
|
|
3751
3913
|
class MissingToolsError extends Error {
|
|
3752
3914
|
constructor(message) {
|
|
3753
|
-
super(spaceTrim
|
|
3915
|
+
super(spaceTrim((block) => `
|
|
3754
3916
|
${block(message)}
|
|
3755
3917
|
|
|
3756
3918
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -3919,7 +4081,7 @@ class LimitReachedError extends Error {
|
|
|
3919
4081
|
*/
|
|
3920
4082
|
class NotYetImplementedError extends Error {
|
|
3921
4083
|
constructor(message) {
|
|
3922
|
-
super(spaceTrim
|
|
4084
|
+
super(spaceTrim((block) => `
|
|
3923
4085
|
${block(message)}
|
|
3924
4086
|
|
|
3925
4087
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -4040,7 +4202,7 @@ function serializeError(error) {
|
|
|
4040
4202
|
const { name, message, stack } = error;
|
|
4041
4203
|
const { id } = error;
|
|
4042
4204
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
4043
|
-
console.error(spaceTrim((block) => `
|
|
4205
|
+
console.error(spaceTrim$1((block) => `
|
|
4044
4206
|
|
|
4045
4207
|
Cannot serialize error with name "${name}"
|
|
4046
4208
|
|
|
@@ -4073,7 +4235,7 @@ function jsonParse(value) {
|
|
|
4073
4235
|
}
|
|
4074
4236
|
else if (typeof value !== 'string') {
|
|
4075
4237
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
4076
|
-
throw new Error(spaceTrim(`
|
|
4238
|
+
throw new Error(spaceTrim$1(`
|
|
4077
4239
|
Can not parse JSON from non-string value.
|
|
4078
4240
|
|
|
4079
4241
|
The value type: ${typeof value}
|
|
@@ -4087,7 +4249,7 @@ function jsonParse(value) {
|
|
|
4087
4249
|
if (!(error instanceof Error)) {
|
|
4088
4250
|
throw error;
|
|
4089
4251
|
}
|
|
4090
|
-
throw new Error(spaceTrim((block) => `
|
|
4252
|
+
throw new Error(spaceTrim$1((block) => `
|
|
4091
4253
|
${block(error.message)}
|
|
4092
4254
|
|
|
4093
4255
|
The expected JSON text:
|
|
@@ -4140,7 +4302,7 @@ function deserializeError(error) {
|
|
|
4140
4302
|
message = `${name}: ${message}`;
|
|
4141
4303
|
}
|
|
4142
4304
|
if (stack !== undefined && stack !== '') {
|
|
4143
|
-
message = spaceTrim((block) => `
|
|
4305
|
+
message = spaceTrim$1((block) => `
|
|
4144
4306
|
${block(message)}
|
|
4145
4307
|
|
|
4146
4308
|
Original stack trace:
|
|
@@ -4177,11 +4339,11 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
4177
4339
|
throw deserializeError(errors[0]);
|
|
4178
4340
|
}
|
|
4179
4341
|
else {
|
|
4180
|
-
throw new PipelineExecutionError(spaceTrim
|
|
4342
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
4181
4343
|
Multiple errors occurred during Promptbook execution
|
|
4182
4344
|
|
|
4183
4345
|
${block(errors
|
|
4184
|
-
.map(({ name, stack, message }, index) => spaceTrim
|
|
4346
|
+
.map(({ name, stack, message }, index) => spaceTrim((block) => `
|
|
4185
4347
|
${name} ${index + 1}:
|
|
4186
4348
|
${block(stack || message)}
|
|
4187
4349
|
`))
|
|
@@ -4551,7 +4713,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
4551
4713
|
}
|
|
4552
4714
|
catch (error) {
|
|
4553
4715
|
assertsError(error);
|
|
4554
|
-
throw new ParseError(spaceTrim
|
|
4716
|
+
throw new ParseError(spaceTrim((block) => `
|
|
4555
4717
|
Can not extract variables from the script
|
|
4556
4718
|
${block(error.stack || error.message)}
|
|
4557
4719
|
|
|
@@ -4734,7 +4896,7 @@ const CsvFormatParser = {
|
|
|
4734
4896
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4735
4897
|
const csv = csvParse(value, settings);
|
|
4736
4898
|
if (csv.errors.length !== 0) {
|
|
4737
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
4899
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
4738
4900
|
CSV parsing error
|
|
4739
4901
|
|
|
4740
4902
|
Error(s) from CSV parsing:
|
|
@@ -4779,7 +4941,7 @@ const CsvFormatParser = {
|
|
|
4779
4941
|
const { value, settings, mapCallback, onProgress } = options;
|
|
4780
4942
|
const csv = csvParse(value, settings);
|
|
4781
4943
|
if (csv.errors.length !== 0) {
|
|
4782
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
4944
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
4783
4945
|
CSV parsing error
|
|
4784
4946
|
|
|
4785
4947
|
Error(s) from CSV parsing:
|
|
@@ -4989,7 +5151,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4989
5151
|
}
|
|
4990
5152
|
// Phase 2️⃣: Non-matching mapping
|
|
4991
5153
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
4992
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5154
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
4993
5155
|
Can not map available parameters to expected parameters
|
|
4994
5156
|
|
|
4995
5157
|
Mapped parameters:
|
|
@@ -5042,14 +5204,14 @@ class MultipleLlmExecutionTools {
|
|
|
5042
5204
|
if (description === undefined) {
|
|
5043
5205
|
return headLine;
|
|
5044
5206
|
}
|
|
5045
|
-
return spaceTrim((block) => `
|
|
5207
|
+
return spaceTrim$1((block) => `
|
|
5046
5208
|
${headLine}
|
|
5047
5209
|
|
|
5048
5210
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
5049
5211
|
`);
|
|
5050
5212
|
})
|
|
5051
5213
|
.join('\n\n');
|
|
5052
|
-
return spaceTrim((block) => `
|
|
5214
|
+
return spaceTrim$1((block) => `
|
|
5053
5215
|
Multiple LLM Providers:
|
|
5054
5216
|
|
|
5055
5217
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -5140,7 +5302,7 @@ class MultipleLlmExecutionTools {
|
|
|
5140
5302
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
5141
5303
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
5142
5304
|
// 3) ...
|
|
5143
|
-
spaceTrim((block) => `
|
|
5305
|
+
spaceTrim$1((block) => `
|
|
5144
5306
|
All execution tools failed:
|
|
5145
5307
|
|
|
5146
5308
|
${block(errors
|
|
@@ -5153,7 +5315,7 @@ class MultipleLlmExecutionTools {
|
|
|
5153
5315
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\``);
|
|
5154
5316
|
}
|
|
5155
5317
|
else {
|
|
5156
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5318
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5157
5319
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
|
|
5158
5320
|
|
|
5159
5321
|
Available \`LlmExecutionTools\`:
|
|
@@ -5186,7 +5348,7 @@ class MultipleLlmExecutionTools {
|
|
|
5186
5348
|
*/
|
|
5187
5349
|
function joinLlmExecutionTools(...llmExecutionTools) {
|
|
5188
5350
|
if (llmExecutionTools.length === 0) {
|
|
5189
|
-
const warningMessage = spaceTrim(`
|
|
5351
|
+
const warningMessage = spaceTrim$1(`
|
|
5190
5352
|
You have not provided any \`LlmExecutionTools\`
|
|
5191
5353
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
5192
5354
|
|
|
@@ -5898,7 +6060,7 @@ function validatePromptResult(options) {
|
|
|
5898
6060
|
}
|
|
5899
6061
|
catch (error) {
|
|
5900
6062
|
keepUnused(error);
|
|
5901
|
-
throw new ExpectError(spaceTrim
|
|
6063
|
+
throw new ExpectError(spaceTrim((block) => `
|
|
5902
6064
|
Expected valid JSON string
|
|
5903
6065
|
|
|
5904
6066
|
The expected JSON text:
|
|
@@ -5963,7 +6125,7 @@ async function executeAttempts(options) {
|
|
|
5963
6125
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
5964
6126
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
5965
6127
|
if (isJokerAttempt && !jokerParameterName) {
|
|
5966
|
-
throw new UnexpectedError(spaceTrim
|
|
6128
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
5967
6129
|
Joker not found in attempt ${attemptIndex}
|
|
5968
6130
|
|
|
5969
6131
|
${block(pipelineIdentification)}
|
|
@@ -5974,7 +6136,7 @@ async function executeAttempts(options) {
|
|
|
5974
6136
|
$ongoingTaskResult.$expectError = null;
|
|
5975
6137
|
if (isJokerAttempt) {
|
|
5976
6138
|
if (parameters[jokerParameterName] === undefined) {
|
|
5977
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6139
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5978
6140
|
Joker parameter {${jokerParameterName}} not defined
|
|
5979
6141
|
|
|
5980
6142
|
${block(pipelineIdentification)}
|
|
@@ -6032,7 +6194,7 @@ async function executeAttempts(options) {
|
|
|
6032
6194
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6033
6195
|
break variant;
|
|
6034
6196
|
case 'EMBEDDING':
|
|
6035
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6197
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6036
6198
|
Embedding model can not be used in pipeline
|
|
6037
6199
|
|
|
6038
6200
|
This should be catched during parsing
|
|
@@ -6043,7 +6205,7 @@ async function executeAttempts(options) {
|
|
|
6043
6205
|
break variant;
|
|
6044
6206
|
// <- case [🤖]:
|
|
6045
6207
|
default:
|
|
6046
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6208
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6047
6209
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6048
6210
|
|
|
6049
6211
|
${block(pipelineIdentification)}
|
|
@@ -6054,14 +6216,14 @@ async function executeAttempts(options) {
|
|
|
6054
6216
|
break;
|
|
6055
6217
|
case 'SCRIPT_TASK':
|
|
6056
6218
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6057
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6219
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6058
6220
|
No script execution tools are available
|
|
6059
6221
|
|
|
6060
6222
|
${block(pipelineIdentification)}
|
|
6061
6223
|
`));
|
|
6062
6224
|
}
|
|
6063
6225
|
if (!task.contentLanguage) {
|
|
6064
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6226
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6065
6227
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6066
6228
|
|
|
6067
6229
|
${block(pipelineIdentification)}
|
|
@@ -6092,7 +6254,7 @@ async function executeAttempts(options) {
|
|
|
6092
6254
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6093
6255
|
}
|
|
6094
6256
|
else {
|
|
6095
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6257
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6096
6258
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6097
6259
|
|
|
6098
6260
|
${block(pipelineIdentification)}
|
|
@@ -6106,7 +6268,7 @@ async function executeAttempts(options) {
|
|
|
6106
6268
|
break taskType;
|
|
6107
6269
|
case 'DIALOG_TASK':
|
|
6108
6270
|
if (tools.userInterface === undefined) {
|
|
6109
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6271
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6110
6272
|
User interface tools are not available
|
|
6111
6273
|
|
|
6112
6274
|
${block(pipelineIdentification)}
|
|
@@ -6124,7 +6286,7 @@ async function executeAttempts(options) {
|
|
|
6124
6286
|
break taskType;
|
|
6125
6287
|
// <- case: [🅱]
|
|
6126
6288
|
default:
|
|
6127
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6289
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6128
6290
|
Unknown execution type "${task.taskType}"
|
|
6129
6291
|
|
|
6130
6292
|
${block(pipelineIdentification)}
|
|
@@ -6215,7 +6377,7 @@ async function executeAttempts(options) {
|
|
|
6215
6377
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6216
6378
|
// Note: Create a summary of all failures
|
|
6217
6379
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6218
|
-
.map((failure) => spaceTrim
|
|
6380
|
+
.map((failure) => spaceTrim((block) => {
|
|
6219
6381
|
var _a, _b;
|
|
6220
6382
|
return `
|
|
6221
6383
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6225,14 +6387,14 @@ async function executeAttempts(options) {
|
|
|
6225
6387
|
Result:
|
|
6226
6388
|
${block(failure.result === null
|
|
6227
6389
|
? 'null'
|
|
6228
|
-
: spaceTrim
|
|
6390
|
+
: spaceTrim(failure.result)
|
|
6229
6391
|
.split('\n')
|
|
6230
6392
|
.map((line) => `> ${line}`)
|
|
6231
6393
|
.join('\n'))}
|
|
6232
6394
|
`;
|
|
6233
6395
|
}))
|
|
6234
6396
|
.join('\n\n---\n\n');
|
|
6235
|
-
throw new PipelineExecutionError(spaceTrim
|
|
6397
|
+
throw new PipelineExecutionError(spaceTrim((block) => {
|
|
6236
6398
|
var _a;
|
|
6237
6399
|
return `
|
|
6238
6400
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6252,7 +6414,7 @@ async function executeAttempts(options) {
|
|
|
6252
6414
|
}
|
|
6253
6415
|
}
|
|
6254
6416
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6255
|
-
throw new UnexpectedError(spaceTrim
|
|
6417
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
6256
6418
|
Something went wrong and prompt result is null
|
|
6257
6419
|
|
|
6258
6420
|
${block(pipelineIdentification)}
|
|
@@ -6279,7 +6441,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6279
6441
|
return /* not await */ executeAttempts(options);
|
|
6280
6442
|
}
|
|
6281
6443
|
if (jokerParameterNames.length !== 0) {
|
|
6282
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6444
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6283
6445
|
JOKER parameters are not supported together with FOREACH command
|
|
6284
6446
|
|
|
6285
6447
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6292,7 +6454,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6292
6454
|
if (formatDefinition === undefined) {
|
|
6293
6455
|
throw new UnexpectedError(
|
|
6294
6456
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6295
|
-
spaceTrim((block) => `
|
|
6457
|
+
spaceTrim$1((block) => `
|
|
6296
6458
|
Unsupported format "${task.foreach.formatName}"
|
|
6297
6459
|
|
|
6298
6460
|
Available formats:
|
|
@@ -6309,7 +6471,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6309
6471
|
if (subvalueParser === undefined) {
|
|
6310
6472
|
throw new UnexpectedError(
|
|
6311
6473
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6312
|
-
spaceTrim((block) => `
|
|
6474
|
+
spaceTrim$1((block) => `
|
|
6313
6475
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6314
6476
|
|
|
6315
6477
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6349,7 +6511,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6349
6511
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6350
6512
|
throw error;
|
|
6351
6513
|
}
|
|
6352
|
-
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6514
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6353
6515
|
${error.message}
|
|
6354
6516
|
|
|
6355
6517
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6373,7 +6535,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6373
6535
|
...options,
|
|
6374
6536
|
priority: priority + index,
|
|
6375
6537
|
parameters: allSubparameters,
|
|
6376
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
6538
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
6377
6539
|
${block(pipelineIdentification)}
|
|
6378
6540
|
Subparameter index: ${index}
|
|
6379
6541
|
`),
|
|
@@ -6382,7 +6544,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6382
6544
|
}
|
|
6383
6545
|
catch (error) {
|
|
6384
6546
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6385
|
-
console.error(spaceTrim((block) => `
|
|
6547
|
+
console.error(spaceTrim$1((block) => `
|
|
6386
6548
|
${error.message}
|
|
6387
6549
|
|
|
6388
6550
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6560,7 +6722,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6560
6722
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6561
6723
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6562
6724
|
if (reservedParameters[parameterName] === undefined) {
|
|
6563
|
-
throw new UnexpectedError(spaceTrim
|
|
6725
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
6564
6726
|
Reserved parameter {${parameterName}} is not defined
|
|
6565
6727
|
|
|
6566
6728
|
${block(pipelineIdentification)}
|
|
@@ -6586,7 +6748,7 @@ async function executeTask(options) {
|
|
|
6586
6748
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6587
6749
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6588
6750
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6589
|
-
throw new UnexpectedError(spaceTrim
|
|
6751
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
6590
6752
|
Dependent parameters are not consistent with used parameters:
|
|
6591
6753
|
|
|
6592
6754
|
Dependent parameters:
|
|
@@ -6630,7 +6792,7 @@ async function executeTask(options) {
|
|
|
6630
6792
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6631
6793
|
// Houston, we have a problem
|
|
6632
6794
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6633
|
-
throw new UnexpectedError(spaceTrim
|
|
6795
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
6634
6796
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6635
6797
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6636
6798
|
|
|
@@ -6698,7 +6860,7 @@ function filterJustOutputParameters(options) {
|
|
|
6698
6860
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6699
6861
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6700
6862
|
// [4]
|
|
6701
|
-
$warnings.push(new PipelineExecutionError(spaceTrim
|
|
6863
|
+
$warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
6702
6864
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6703
6865
|
|
|
6704
6866
|
${block(pipelineIdentification)}
|
|
@@ -6783,7 +6945,7 @@ async function executePipeline(options) {
|
|
|
6783
6945
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
6784
6946
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
6785
6947
|
if (parameter === undefined) {
|
|
6786
|
-
warnings.push(new PipelineExecutionError(spaceTrim
|
|
6948
|
+
warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
6787
6949
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
6788
6950
|
|
|
6789
6951
|
${block(pipelineIdentification)}
|
|
@@ -6798,7 +6960,7 @@ async function executePipeline(options) {
|
|
|
6798
6960
|
// TODO: [🧠] This should be also non-critical error
|
|
6799
6961
|
return exportJson({
|
|
6800
6962
|
name: 'pipelineExecutorResult',
|
|
6801
|
-
message: spaceTrim
|
|
6963
|
+
message: spaceTrim((block) => `
|
|
6802
6964
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
6803
6965
|
|
|
6804
6966
|
${block(pipelineIdentification)}
|
|
@@ -6807,7 +6969,7 @@ async function executePipeline(options) {
|
|
|
6807
6969
|
value: {
|
|
6808
6970
|
isSuccessful: false,
|
|
6809
6971
|
errors: [
|
|
6810
|
-
new PipelineExecutionError(spaceTrim
|
|
6972
|
+
new PipelineExecutionError(spaceTrim((block) => `
|
|
6811
6973
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
6812
6974
|
|
|
6813
6975
|
${block(pipelineIdentification)}
|
|
@@ -6834,7 +6996,7 @@ async function executePipeline(options) {
|
|
|
6834
6996
|
while (unresovedTasks.length > 0) {
|
|
6835
6997
|
if (loopLimit-- < 0) {
|
|
6836
6998
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
6837
|
-
throw new UnexpectedError(spaceTrim
|
|
6999
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
6838
7000
|
Loop limit reached during resolving parameters pipeline execution
|
|
6839
7001
|
|
|
6840
7002
|
${block(pipelineIdentification)}
|
|
@@ -6844,7 +7006,7 @@ async function executePipeline(options) {
|
|
|
6844
7006
|
if (!currentTask && resolving.length === 0) {
|
|
6845
7007
|
throw new UnexpectedError(
|
|
6846
7008
|
// TODO: [🐎] DRY
|
|
6847
|
-
spaceTrim
|
|
7009
|
+
spaceTrim((block) => `
|
|
6848
7010
|
Can not resolve some parameters:
|
|
6849
7011
|
|
|
6850
7012
|
${block(pipelineIdentification)}
|
|
@@ -6884,7 +7046,7 @@ async function executePipeline(options) {
|
|
|
6884
7046
|
tools,
|
|
6885
7047
|
onProgress(newOngoingResult) {
|
|
6886
7048
|
if (isReturned) {
|
|
6887
|
-
throw new UnexpectedError(spaceTrim
|
|
7049
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
6888
7050
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
6889
7051
|
|
|
6890
7052
|
${block(pipelineIdentification)}
|
|
@@ -6900,7 +7062,7 @@ async function executePipeline(options) {
|
|
|
6900
7062
|
}
|
|
6901
7063
|
},
|
|
6902
7064
|
$executionReport: executionReport,
|
|
6903
|
-
pipelineIdentification: spaceTrim
|
|
7065
|
+
pipelineIdentification: spaceTrim((block) => `
|
|
6904
7066
|
${block(pipelineIdentification)}
|
|
6905
7067
|
Task name: ${currentTask.name}
|
|
6906
7068
|
Task title: ${currentTask.title}
|
|
@@ -7009,7 +7171,7 @@ function createPipelineExecutor(options) {
|
|
|
7009
7171
|
preparedPipeline = pipeline;
|
|
7010
7172
|
}
|
|
7011
7173
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7012
|
-
console.warn(spaceTrim
|
|
7174
|
+
console.warn(spaceTrim((block) => `
|
|
7013
7175
|
Pipeline is not prepared
|
|
7014
7176
|
|
|
7015
7177
|
${block(pipelineIdentification)}
|
|
@@ -7033,7 +7195,7 @@ function createPipelineExecutor(options) {
|
|
|
7033
7195
|
inputParameters,
|
|
7034
7196
|
tools,
|
|
7035
7197
|
onProgress,
|
|
7036
|
-
pipelineIdentification: spaceTrim
|
|
7198
|
+
pipelineIdentification: spaceTrim((block) => `
|
|
7037
7199
|
${block(pipelineIdentification)}
|
|
7038
7200
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7039
7201
|
`),
|
|
@@ -7444,14 +7606,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
7444
7606
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
7445
7607
|
});
|
|
7446
7608
|
if (metadata.length === 0) {
|
|
7447
|
-
return spaceTrim(`
|
|
7609
|
+
return spaceTrim$1(`
|
|
7448
7610
|
**No scrapers are available**
|
|
7449
7611
|
|
|
7450
7612
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
7451
7613
|
At least there should be available the metadata of the scrapers
|
|
7452
7614
|
`);
|
|
7453
7615
|
}
|
|
7454
|
-
return spaceTrim((block) => `
|
|
7616
|
+
return spaceTrim$1((block) => `
|
|
7455
7617
|
Available scrapers are:
|
|
7456
7618
|
${block(metadata
|
|
7457
7619
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -7796,7 +7958,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
7796
7958
|
const fileExtension = getFileExtension(filename);
|
|
7797
7959
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
7798
7960
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
7799
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
7961
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
7800
7962
|
Can not make source handler for file which does not exist:
|
|
7801
7963
|
|
|
7802
7964
|
File:
|
|
@@ -7883,7 +8045,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
7883
8045
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
7884
8046
|
break;
|
|
7885
8047
|
}
|
|
7886
|
-
console.warn(spaceTrim((block) => `
|
|
8048
|
+
console.warn(spaceTrim$1((block) => `
|
|
7887
8049
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
7888
8050
|
|
|
7889
8051
|
The source:
|
|
@@ -7899,7 +8061,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
7899
8061
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7900
8062
|
}
|
|
7901
8063
|
if (partialPieces === null) {
|
|
7902
|
-
throw new KnowledgeScrapeError(spaceTrim((block) => `
|
|
8064
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
7903
8065
|
Cannot scrape knowledge
|
|
7904
8066
|
|
|
7905
8067
|
The source:
|
|
@@ -7978,7 +8140,7 @@ async function prepareTasks(pipeline, tools, options) {
|
|
|
7978
8140
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
7979
8141
|
knowledgePiecesCount > 0 &&
|
|
7980
8142
|
!dependentParameterNames.includes('knowledge')) {
|
|
7981
|
-
preparedContent = spaceTrim
|
|
8143
|
+
preparedContent = spaceTrim(`
|
|
7982
8144
|
{content}
|
|
7983
8145
|
|
|
7984
8146
|
## Knowledge
|
|
@@ -8237,7 +8399,7 @@ const knowledgeCommandParser = {
|
|
|
8237
8399
|
*/
|
|
8238
8400
|
parse(input) {
|
|
8239
8401
|
const { args } = input;
|
|
8240
|
-
const knowledgeSourceContent = spaceTrim(args[0] || '');
|
|
8402
|
+
const knowledgeSourceContent = spaceTrim$1(args[0] || '');
|
|
8241
8403
|
if (knowledgeSourceContent === '') {
|
|
8242
8404
|
throw new ParseError(`Source is not defined`);
|
|
8243
8405
|
}
|
|
@@ -8381,7 +8543,7 @@ const sectionCommandParser = {
|
|
|
8381
8543
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
8382
8544
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
8383
8545
|
if (taskTypes.length !== 1) {
|
|
8384
|
-
throw new ParseError(spaceTrim((block) => `
|
|
8546
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8385
8547
|
Unknown section type "${normalized}"
|
|
8386
8548
|
|
|
8387
8549
|
Supported section types are:
|
|
@@ -8401,7 +8563,7 @@ const sectionCommandParser = {
|
|
|
8401
8563
|
*/
|
|
8402
8564
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
8403
8565
|
if ($taskJson.isSectionTypeSet === true) {
|
|
8404
|
-
throw new ParseError(spaceTrim(`
|
|
8566
|
+
throw new ParseError(spaceTrim$1(`
|
|
8405
8567
|
Section type is already defined in the section.
|
|
8406
8568
|
It can be defined only once.
|
|
8407
8569
|
`));
|
|
@@ -8749,7 +8911,7 @@ const expectCommandParser = {
|
|
|
8749
8911
|
/**
|
|
8750
8912
|
* Description of the FORMAT command
|
|
8751
8913
|
*/
|
|
8752
|
-
description: spaceTrim(`
|
|
8914
|
+
description: spaceTrim$1(`
|
|
8753
8915
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
8754
8916
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
8755
8917
|
`),
|
|
@@ -8823,7 +8985,7 @@ const expectCommandParser = {
|
|
|
8823
8985
|
}
|
|
8824
8986
|
catch (error) {
|
|
8825
8987
|
assertsError(error);
|
|
8826
|
-
throw new ParseError(spaceTrim((block) => `
|
|
8988
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8827
8989
|
Invalid FORMAT command
|
|
8828
8990
|
${block(error.message)}:
|
|
8829
8991
|
`));
|
|
@@ -9008,7 +9170,7 @@ function validateParameterName(parameterName) {
|
|
|
9008
9170
|
if (!(error instanceof ParseError)) {
|
|
9009
9171
|
throw error;
|
|
9010
9172
|
}
|
|
9011
|
-
throw new ParseError(spaceTrim((block) => `
|
|
9173
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9012
9174
|
${block(error.message)}
|
|
9013
9175
|
|
|
9014
9176
|
Tried to validate parameter name:
|
|
@@ -9067,7 +9229,7 @@ const foreachCommandParser = {
|
|
|
9067
9229
|
const assignSign = args[3];
|
|
9068
9230
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
9069
9231
|
if (formatDefinition === undefined) {
|
|
9070
|
-
throw new ParseError(spaceTrim((block) => `
|
|
9232
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9071
9233
|
Unsupported format "${formatName}"
|
|
9072
9234
|
|
|
9073
9235
|
Available formats:
|
|
@@ -9079,7 +9241,7 @@ const foreachCommandParser = {
|
|
|
9079
9241
|
}
|
|
9080
9242
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
9081
9243
|
if (subvalueParser === undefined) {
|
|
9082
|
-
throw new ParseError(spaceTrim((block) => `
|
|
9244
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9083
9245
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
9084
9246
|
|
|
9085
9247
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -9127,7 +9289,7 @@ const foreachCommandParser = {
|
|
|
9127
9289
|
outputSubparameterName = 'newLine';
|
|
9128
9290
|
}
|
|
9129
9291
|
else {
|
|
9130
|
-
throw new ParseError(spaceTrim(`
|
|
9292
|
+
throw new ParseError(spaceTrim$1(`
|
|
9131
9293
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
9132
9294
|
|
|
9133
9295
|
Correct example:
|
|
@@ -9203,7 +9365,7 @@ const formatCommandParser = {
|
|
|
9203
9365
|
/**
|
|
9204
9366
|
* Description of the FORMAT command
|
|
9205
9367
|
*/
|
|
9206
|
-
description: spaceTrim(`
|
|
9368
|
+
description: spaceTrim$1(`
|
|
9207
9369
|
Format command describes the desired output of the task (after post-processing)
|
|
9208
9370
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
9209
9371
|
`),
|
|
@@ -9575,7 +9737,7 @@ const formfactorCommandParser = {
|
|
|
9575
9737
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
9576
9738
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
9577
9739
|
if (formfactor === undefined) {
|
|
9578
|
-
throw new ParseError(spaceTrim((block) => `
|
|
9740
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9579
9741
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
9580
9742
|
|
|
9581
9743
|
Available formfactors:
|
|
@@ -9594,7 +9756,7 @@ const formfactorCommandParser = {
|
|
|
9594
9756
|
*/
|
|
9595
9757
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
9596
9758
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
9597
|
-
throw new ParseError(spaceTrim(`
|
|
9759
|
+
throw new ParseError(spaceTrim$1(`
|
|
9598
9760
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
9599
9761
|
|
|
9600
9762
|
You have used:
|
|
@@ -9737,7 +9899,7 @@ const modelCommandParser = {
|
|
|
9737
9899
|
*/
|
|
9738
9900
|
parse(input) {
|
|
9739
9901
|
const { args, normalized } = input;
|
|
9740
|
-
const availableVariantsMessage = spaceTrim((block) => `
|
|
9902
|
+
const availableVariantsMessage = spaceTrim$1((block) => `
|
|
9741
9903
|
Available variants are:
|
|
9742
9904
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
9743
9905
|
`);
|
|
@@ -9759,14 +9921,14 @@ const modelCommandParser = {
|
|
|
9759
9921
|
// <- Note: [🤖]
|
|
9760
9922
|
}
|
|
9761
9923
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
9762
|
-
spaceTrim((block) => `
|
|
9924
|
+
spaceTrim$1((block) => `
|
|
9763
9925
|
Embedding model can not be used in pipeline
|
|
9764
9926
|
|
|
9765
9927
|
${block(availableVariantsMessage)}
|
|
9766
9928
|
`);
|
|
9767
9929
|
}
|
|
9768
9930
|
else {
|
|
9769
|
-
throw new ParseError(spaceTrim((block) => `
|
|
9931
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9770
9932
|
Unknown model variant in command:
|
|
9771
9933
|
|
|
9772
9934
|
${block(availableVariantsMessage)}
|
|
@@ -9781,7 +9943,7 @@ const modelCommandParser = {
|
|
|
9781
9943
|
};
|
|
9782
9944
|
}
|
|
9783
9945
|
else {
|
|
9784
|
-
throw new ParseError(spaceTrim((block) => `
|
|
9946
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9785
9947
|
Unknown model key in command.
|
|
9786
9948
|
|
|
9787
9949
|
Supported model keys are:
|
|
@@ -9808,7 +9970,7 @@ const modelCommandParser = {
|
|
|
9808
9970
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9809
9971
|
}
|
|
9810
9972
|
else {
|
|
9811
|
-
throw new ParseError(spaceTrim(`
|
|
9973
|
+
throw new ParseError(spaceTrim$1(`
|
|
9812
9974
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
9813
9975
|
|
|
9814
9976
|
You have used:
|
|
@@ -9840,7 +10002,7 @@ const modelCommandParser = {
|
|
|
9840
10002
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9841
10003
|
}
|
|
9842
10004
|
else {
|
|
9843
|
-
throw new ParseError(spaceTrim(`
|
|
10005
|
+
throw new ParseError(spaceTrim$1(`
|
|
9844
10006
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
9845
10007
|
|
|
9846
10008
|
You have used:
|
|
@@ -9850,7 +10012,7 @@ const modelCommandParser = {
|
|
|
9850
10012
|
}
|
|
9851
10013
|
}
|
|
9852
10014
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
9853
|
-
console.log(spaceTrim(`
|
|
10015
|
+
console.log(spaceTrim$1(`
|
|
9854
10016
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
9855
10017
|
|
|
9856
10018
|
In pipeline head:
|
|
@@ -9933,7 +10095,7 @@ const parameterCommandParser = {
|
|
|
9933
10095
|
// <- TODO: When [🥶] fixed, change to:
|
|
9934
10096
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
9935
10097
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
9936
|
-
throw new ParseError(spaceTrim((block) => `
|
|
10098
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9937
10099
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
9938
10100
|
|
|
9939
10101
|
The description:
|
|
@@ -10115,7 +10277,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
10115
10277
|
persona.description = personaDescription;
|
|
10116
10278
|
return;
|
|
10117
10279
|
}
|
|
10118
|
-
console.warn(spaceTrim(`
|
|
10280
|
+
console.warn(spaceTrim$1(`
|
|
10119
10281
|
|
|
10120
10282
|
Persona "${personaName}" is defined multiple times with different description:
|
|
10121
10283
|
|
|
@@ -10126,7 +10288,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
10126
10288
|
${personaDescription}
|
|
10127
10289
|
|
|
10128
10290
|
`));
|
|
10129
|
-
persona.description += spaceTrim('\n\n' + personaDescription);
|
|
10291
|
+
persona.description += spaceTrim$1('\n\n' + personaDescription);
|
|
10130
10292
|
}
|
|
10131
10293
|
|
|
10132
10294
|
/**
|
|
@@ -10491,7 +10653,7 @@ const COMMANDS = [
|
|
|
10491
10653
|
function getParserForCommand(command) {
|
|
10492
10654
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
10493
10655
|
if (commandParser === undefined) {
|
|
10494
|
-
throw new UnexpectedError(spaceTrim
|
|
10656
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
10495
10657
|
Command ${command.type} parser is not found
|
|
10496
10658
|
|
|
10497
10659
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -10567,7 +10729,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
10567
10729
|
.map(removeMarkdownFormatting)
|
|
10568
10730
|
.map((item) => item.trim());
|
|
10569
10731
|
if (items.length === 0 || items[0] === '') {
|
|
10570
|
-
throw new ParseError(spaceTrim
|
|
10732
|
+
throw new ParseError(spaceTrim((block) => `
|
|
10571
10733
|
Malformed command:
|
|
10572
10734
|
- ${raw}
|
|
10573
10735
|
|
|
@@ -10603,7 +10765,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
10603
10765
|
return command;
|
|
10604
10766
|
}
|
|
10605
10767
|
}
|
|
10606
|
-
throw new ParseError(spaceTrim
|
|
10768
|
+
throw new ParseError(spaceTrim((block) => `
|
|
10607
10769
|
Malformed or unknown command:
|
|
10608
10770
|
- ${raw}
|
|
10609
10771
|
|
|
@@ -10654,7 +10816,7 @@ function parseCommandVariant(input) {
|
|
|
10654
10816
|
if (!(error instanceof ParseError)) {
|
|
10655
10817
|
throw error;
|
|
10656
10818
|
}
|
|
10657
|
-
throw new ParseError(spaceTrim
|
|
10819
|
+
throw new ParseError(spaceTrim((block) => `
|
|
10658
10820
|
Invalid ${commandName} command:
|
|
10659
10821
|
|
|
10660
10822
|
Your command:
|
|
@@ -10928,7 +11090,7 @@ const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
|
10928
11090
|
* @public exported from `@promptbook/markdown-utils`
|
|
10929
11091
|
*/
|
|
10930
11092
|
function removeMarkdownComments(content) {
|
|
10931
|
-
return spaceTrim
|
|
11093
|
+
return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
10932
11094
|
}
|
|
10933
11095
|
|
|
10934
11096
|
/**
|
|
@@ -10939,7 +11101,7 @@ function removeMarkdownComments(content) {
|
|
|
10939
11101
|
*/
|
|
10940
11102
|
function isFlatPipeline(pipelineString) {
|
|
10941
11103
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
10942
|
-
pipelineString = spaceTrim(pipelineString);
|
|
11104
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
10943
11105
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
10944
11106
|
//const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
|
|
10945
11107
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -10977,19 +11139,19 @@ function deflatePipeline(pipelineString) {
|
|
|
10977
11139
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
10978
11140
|
pipelineStringLines.push(potentialReturnStatement);
|
|
10979
11141
|
}
|
|
10980
|
-
const prompt = spaceTrim(pipelineStringLines.join('\n'));
|
|
11142
|
+
const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
|
|
10981
11143
|
let quotedPrompt;
|
|
10982
11144
|
if (prompt.split('\n').length <= 1) {
|
|
10983
11145
|
quotedPrompt = `> ${prompt}`;
|
|
10984
11146
|
}
|
|
10985
11147
|
else {
|
|
10986
|
-
quotedPrompt = spaceTrim((block) => `
|
|
11148
|
+
quotedPrompt = spaceTrim$1((block) => `
|
|
10987
11149
|
\`\`\`
|
|
10988
11150
|
${block(prompt.split('`').join('\\`'))}
|
|
10989
11151
|
\`\`\`
|
|
10990
11152
|
`);
|
|
10991
11153
|
}
|
|
10992
|
-
pipelineString = validatePipelineString(spaceTrim((block) => `
|
|
11154
|
+
pipelineString = validatePipelineString(spaceTrim$1((block) => `
|
|
10993
11155
|
# ${DEFAULT_BOOK_TITLE}
|
|
10994
11156
|
|
|
10995
11157
|
## Prompt
|
|
@@ -11053,7 +11215,7 @@ function extractAllListItemsFromMarkdown(markdown) {
|
|
|
11053
11215
|
function extractOneBlockFromMarkdown(markdown) {
|
|
11054
11216
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
11055
11217
|
if (codeBlocks.length !== 1) {
|
|
11056
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11218
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
11057
11219
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
11058
11220
|
|
|
11059
11221
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -11078,7 +11240,7 @@ function parseMarkdownSection(value) {
|
|
|
11078
11240
|
}
|
|
11079
11241
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
11080
11242
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
11081
|
-
const content = spaceTrim(lines.slice(1).join('\n'));
|
|
11243
|
+
const content = spaceTrim$1(lines.slice(1).join('\n'));
|
|
11082
11244
|
if (level < 1 || level > 6) {
|
|
11083
11245
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
11084
11246
|
}
|
|
@@ -11106,7 +11268,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
11106
11268
|
if (buffer.length === 0) {
|
|
11107
11269
|
return;
|
|
11108
11270
|
}
|
|
11109
|
-
let section = spaceTrim(buffer.join('\n'));
|
|
11271
|
+
let section = spaceTrim$1(buffer.join('\n'));
|
|
11110
11272
|
if (section === '') {
|
|
11111
11273
|
return;
|
|
11112
11274
|
}
|
|
@@ -11181,7 +11343,7 @@ function flattenMarkdown(markdown) {
|
|
|
11181
11343
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
11182
11344
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
11183
11345
|
}
|
|
11184
|
-
return spaceTrim(flattenedMarkdown);
|
|
11346
|
+
return spaceTrim$1(flattenedMarkdown);
|
|
11185
11347
|
}
|
|
11186
11348
|
/**
|
|
11187
11349
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -11243,7 +11405,7 @@ function parsePipeline(pipelineString) {
|
|
|
11243
11405
|
if (pipelineString.startsWith('#!')) {
|
|
11244
11406
|
const [shebangLine, ...restLines] = pipelineString.split('\n');
|
|
11245
11407
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
11246
|
-
throw new ParseError(spaceTrim
|
|
11408
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11247
11409
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
11248
11410
|
Shebang line must contain 'ptbk'
|
|
11249
11411
|
|
|
@@ -11259,7 +11421,7 @@ function parsePipeline(pipelineString) {
|
|
|
11259
11421
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
11260
11422
|
}
|
|
11261
11423
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
11262
|
-
pipelineString = spaceTrim
|
|
11424
|
+
pipelineString = spaceTrim(pipelineString);
|
|
11263
11425
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
11264
11426
|
pipelineString = deflatePipeline(pipelineString);
|
|
11265
11427
|
// ==============
|
|
@@ -11271,7 +11433,7 @@ function parsePipeline(pipelineString) {
|
|
|
11271
11433
|
// ==============
|
|
11272
11434
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
11273
11435
|
if (pipelineHead === undefined) {
|
|
11274
|
-
throw new UnexpectedError(spaceTrim
|
|
11436
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
11275
11437
|
Pipeline head is not defined
|
|
11276
11438
|
|
|
11277
11439
|
${block(getPipelineIdentification())}
|
|
@@ -11280,7 +11442,7 @@ function parsePipeline(pipelineString) {
|
|
|
11280
11442
|
`));
|
|
11281
11443
|
}
|
|
11282
11444
|
if (pipelineHead.level !== 1) {
|
|
11283
|
-
throw new UnexpectedError(spaceTrim
|
|
11445
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
11284
11446
|
Pipeline head is not h1
|
|
11285
11447
|
|
|
11286
11448
|
${block(getPipelineIdentification())}
|
|
@@ -11289,7 +11451,7 @@ function parsePipeline(pipelineString) {
|
|
|
11289
11451
|
`));
|
|
11290
11452
|
}
|
|
11291
11453
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
11292
|
-
throw new UnexpectedError(spaceTrim
|
|
11454
|
+
throw new UnexpectedError(spaceTrim((block) => `
|
|
11293
11455
|
Not every pipeline section is h2
|
|
11294
11456
|
|
|
11295
11457
|
${block(getPipelineIdentification())}
|
|
@@ -11302,7 +11464,7 @@ function parsePipeline(pipelineString) {
|
|
|
11302
11464
|
const defineParam = (parameterCommand) => {
|
|
11303
11465
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
11304
11466
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
11305
|
-
throw new ParseError(spaceTrim
|
|
11467
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11306
11468
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
11307
11469
|
|
|
11308
11470
|
${block(getPipelineIdentification())}
|
|
@@ -11313,7 +11475,7 @@ function parsePipeline(pipelineString) {
|
|
|
11313
11475
|
existingParameter.description &&
|
|
11314
11476
|
existingParameter.description !== parameterDescription &&
|
|
11315
11477
|
parameterDescription) {
|
|
11316
|
-
throw new ParseError(spaceTrim
|
|
11478
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11317
11479
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
11318
11480
|
|
|
11319
11481
|
${block(getPipelineIdentification())}
|
|
@@ -11351,7 +11513,7 @@ function parsePipeline(pipelineString) {
|
|
|
11351
11513
|
description = description.split(/^>.*$/gm).join('');
|
|
11352
11514
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
11353
11515
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
11354
|
-
description = spaceTrim
|
|
11516
|
+
description = spaceTrim(description);
|
|
11355
11517
|
if (description === '') {
|
|
11356
11518
|
description = undefined;
|
|
11357
11519
|
}
|
|
@@ -11362,7 +11524,7 @@ function parsePipeline(pipelineString) {
|
|
|
11362
11524
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
11363
11525
|
const commandParser = getParserForCommand(command);
|
|
11364
11526
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
11365
|
-
throw new ParseError(spaceTrim
|
|
11527
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11366
11528
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
11367
11529
|
|
|
11368
11530
|
${block(getPipelineIdentification())}
|
|
@@ -11376,7 +11538,7 @@ function parsePipeline(pipelineString) {
|
|
|
11376
11538
|
if (!(error instanceof ParseError)) {
|
|
11377
11539
|
throw error;
|
|
11378
11540
|
}
|
|
11379
|
-
throw new ParseError(spaceTrim
|
|
11541
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11380
11542
|
Command ${command.type} failed to apply to the pipeline
|
|
11381
11543
|
|
|
11382
11544
|
The error:
|
|
@@ -11429,7 +11591,7 @@ function parsePipeline(pipelineString) {
|
|
|
11429
11591
|
description = description.split(/^>.*$/gm).join('');
|
|
11430
11592
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
11431
11593
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
11432
|
-
description = spaceTrim
|
|
11594
|
+
description = spaceTrim(description);
|
|
11433
11595
|
if (description === '') {
|
|
11434
11596
|
description = undefined;
|
|
11435
11597
|
}
|
|
@@ -11463,7 +11625,7 @@ function parsePipeline(pipelineString) {
|
|
|
11463
11625
|
for (const { listItem, command } of commands) {
|
|
11464
11626
|
const commandParser = getParserForCommand(command);
|
|
11465
11627
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
11466
|
-
throw new ParseError(spaceTrim
|
|
11628
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11467
11629
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
11468
11630
|
|
|
11469
11631
|
${block(getPipelineIdentification())}
|
|
@@ -11478,7 +11640,7 @@ function parsePipeline(pipelineString) {
|
|
|
11478
11640
|
if (!(error instanceof ParseError)) {
|
|
11479
11641
|
throw error;
|
|
11480
11642
|
}
|
|
11481
|
-
throw new ParseError(spaceTrim
|
|
11643
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11482
11644
|
Command \`${command.type}\` failed to apply to the task
|
|
11483
11645
|
|
|
11484
11646
|
The error:
|
|
@@ -11509,14 +11671,14 @@ function parsePipeline(pipelineString) {
|
|
|
11509
11671
|
// TODO: [🍧] Should be done in SECTION command
|
|
11510
11672
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
11511
11673
|
if (!language) {
|
|
11512
|
-
throw new ParseError(spaceTrim
|
|
11674
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11513
11675
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
11514
11676
|
|
|
11515
11677
|
${block(getPipelineIdentification())}
|
|
11516
11678
|
`));
|
|
11517
11679
|
}
|
|
11518
11680
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
11519
|
-
throw new ParseError(spaceTrim
|
|
11681
|
+
throw new ParseError(spaceTrim((block) => `
|
|
11520
11682
|
Script language ${language} is not supported.
|
|
11521
11683
|
|
|
11522
11684
|
Supported languages are:
|
|
@@ -11678,7 +11840,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
11678
11840
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
11679
11841
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
11680
11842
|
const sectionMatch = content.match(sectionRegex);
|
|
11681
|
-
const contentToInsert = spaceTrim
|
|
11843
|
+
const contentToInsert = spaceTrim((block) => `
|
|
11682
11844
|
<!--${sectionName}-->
|
|
11683
11845
|
${block(warningLine)}
|
|
11684
11846
|
${block(sectionContent)}
|
|
@@ -11691,7 +11853,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
11691
11853
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
11692
11854
|
if (placeForSection !== null) {
|
|
11693
11855
|
const [heading] = placeForSection;
|
|
11694
|
-
return content.replace(heading, spaceTrim
|
|
11856
|
+
return content.replace(heading, spaceTrim((block) => `
|
|
11695
11857
|
${block(contentToInsert)}
|
|
11696
11858
|
|
|
11697
11859
|
${block(heading)}
|
|
@@ -11700,7 +11862,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
11700
11862
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
11701
11863
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
11702
11864
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
11703
|
-
return spaceTrim
|
|
11865
|
+
return spaceTrim((block) => `
|
|
11704
11866
|
${block(content)}
|
|
11705
11867
|
|
|
11706
11868
|
${block(contentToInsert)}
|
|
@@ -11776,7 +11938,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
11776
11938
|
.filter(([MERMAID_NAME]) => (inputAndIntermediateParametersMermaid + outputParametersMermaid).includes(MERMAID_NAME))
|
|
11777
11939
|
.map(([MERMAID_NAME, title]) => `${MERMAID_NAME}((${title})):::${MERMAID_NAME}`)
|
|
11778
11940
|
.join('\n');
|
|
11779
|
-
const promptbookMermaid = spaceTrim
|
|
11941
|
+
const promptbookMermaid = spaceTrim((block) => `
|
|
11780
11942
|
|
|
11781
11943
|
%% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
|
|
11782
11944
|
|
|
@@ -11832,7 +11994,7 @@ async function prettifyPipelineString(pipelineString, options) {
|
|
|
11832
11994
|
return { href: `#${task.name}`, title: task.title };
|
|
11833
11995
|
},
|
|
11834
11996
|
});
|
|
11835
|
-
const promptbookMermaidBlock = spaceTrim
|
|
11997
|
+
const promptbookMermaidBlock = spaceTrim((block) => `
|
|
11836
11998
|
\`\`\`mermaid
|
|
11837
11999
|
${block(promptbookMermaid)}
|
|
11838
12000
|
\`\`\`
|
|
@@ -11870,7 +12032,7 @@ class CallbackInterfaceTools {
|
|
|
11870
12032
|
async promptDialog(options) {
|
|
11871
12033
|
const answer = await this.options.callback(options);
|
|
11872
12034
|
if (this.options.isVerbose) {
|
|
11873
|
-
console.info(spaceTrim
|
|
12035
|
+
console.info(spaceTrim((block) => `
|
|
11874
12036
|
📖 ${block(options.promptTitle)}
|
|
11875
12037
|
👤 ${block(answer)}
|
|
11876
12038
|
`));
|
|
@@ -12009,7 +12171,7 @@ function countWorkingDuration(items) {
|
|
|
12009
12171
|
function executionReportJsonToString(executionReportJson, options) {
|
|
12010
12172
|
var _a, _b, _c, _d, _e, _f;
|
|
12011
12173
|
const { taxRate, chartsWidth } = { ...ExecutionReportStringOptionsDefaults, ...(options || {}) };
|
|
12012
|
-
let executionReportString = spaceTrim
|
|
12174
|
+
let executionReportString = spaceTrim((block) => `
|
|
12013
12175
|
# ${executionReportJson.title || 'Execution report'}
|
|
12014
12176
|
|
|
12015
12177
|
${block(executionReportJson.description || '')}
|
|
@@ -12131,7 +12293,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
12131
12293
|
if (just(true)) {
|
|
12132
12294
|
executionReportString +=
|
|
12133
12295
|
'\n\n\n\n' +
|
|
12134
|
-
spaceTrim
|
|
12296
|
+
spaceTrim((block) => {
|
|
12135
12297
|
var _a;
|
|
12136
12298
|
return `
|
|
12137
12299
|
|
|
@@ -12150,7 +12312,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
12150
12312
|
executionReportString += '*No result*';
|
|
12151
12313
|
}
|
|
12152
12314
|
else if (typeof promptExecution.result.content === 'string') {
|
|
12153
|
-
executionReportString += spaceTrim
|
|
12315
|
+
executionReportString += spaceTrim((block) => `
|
|
12154
12316
|
\`\`\`
|
|
12155
12317
|
${block(escapeMarkdownBlock(promptExecution.result.content))}
|
|
12156
12318
|
\`\`\`
|
|
@@ -12163,7 +12325,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
12163
12325
|
if (promptExecution.error && promptExecution.error.message) {
|
|
12164
12326
|
executionReportString +=
|
|
12165
12327
|
'\n\n\n\n' +
|
|
12166
|
-
spaceTrim
|
|
12328
|
+
spaceTrim((block) => `
|
|
12167
12329
|
|
|
12168
12330
|
### Error
|
|
12169
12331
|
|
|
@@ -12239,7 +12401,7 @@ function usageToHuman(usage) {
|
|
|
12239
12401
|
// Note: For negligible usage, we report at least something
|
|
12240
12402
|
reportItems.push('Negligible');
|
|
12241
12403
|
}
|
|
12242
|
-
return spaceTrim((block) => `
|
|
12404
|
+
return spaceTrim$1((block) => `
|
|
12243
12405
|
Usage:
|
|
12244
12406
|
${block(reportItems.map((item) => `- ${item}`).join('\n'))}
|
|
12245
12407
|
`);
|
|
@@ -12484,13 +12646,13 @@ function $registeredLlmToolsMessage() {
|
|
|
12484
12646
|
});
|
|
12485
12647
|
const usedEnvMessage = `Unknown \`.env\` file` ;
|
|
12486
12648
|
if (metadata.length === 0) {
|
|
12487
|
-
return spaceTrim((block) => `
|
|
12649
|
+
return spaceTrim$1((block) => `
|
|
12488
12650
|
No LLM providers are available.
|
|
12489
12651
|
|
|
12490
12652
|
${block(usedEnvMessage)}
|
|
12491
12653
|
`);
|
|
12492
12654
|
}
|
|
12493
|
-
return spaceTrim((block) => `
|
|
12655
|
+
return spaceTrim$1((block) => `
|
|
12494
12656
|
|
|
12495
12657
|
${block(usedEnvMessage)}
|
|
12496
12658
|
|
|
@@ -12536,7 +12698,7 @@ function $registeredLlmToolsMessage() {
|
|
|
12536
12698
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
12537
12699
|
}
|
|
12538
12700
|
}
|
|
12539
|
-
let providerMessage = spaceTrim(`
|
|
12701
|
+
let providerMessage = spaceTrim$1(`
|
|
12540
12702
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
12541
12703
|
${morePieces.join('; ')}
|
|
12542
12704
|
`);
|
|
@@ -12582,7 +12744,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
|
12582
12744
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
12583
12745
|
if (registeredItem === undefined) {
|
|
12584
12746
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
12585
|
-
throw new Error(spaceTrim((block) => `
|
|
12747
|
+
throw new Error(spaceTrim$1((block) => `
|
|
12586
12748
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
12587
12749
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
12588
12750
|
|
|
@@ -12719,7 +12881,7 @@ function cacheLlmTools(llmTools, options = {}) {
|
|
|
12719
12881
|
let normalizedContent = content;
|
|
12720
12882
|
normalizedContent = normalizedContent.replace(/\s+/g, ' ');
|
|
12721
12883
|
normalizedContent = normalizedContent.split('\r\n').join('\n');
|
|
12722
|
-
normalizedContent = spaceTrim(normalizedContent);
|
|
12884
|
+
normalizedContent = spaceTrim$1(normalizedContent);
|
|
12723
12885
|
// Note: Do not need to save everything in the cache, just the relevant parameters
|
|
12724
12886
|
const relevantParameterNames = extractParameterNames(content);
|
|
12725
12887
|
const relevantParameters = Object.fromEntries(Object.entries(parameters).filter(([key]) => relevantParameterNames.has(key)));
|
|
@@ -13399,7 +13561,7 @@ function isValidPipelineString(pipelineString) {
|
|
|
13399
13561
|
*/
|
|
13400
13562
|
function prompt(strings, ...values) {
|
|
13401
13563
|
if (values.length === 0) {
|
|
13402
|
-
return spaceTrim(strings.join(''));
|
|
13564
|
+
return spaceTrim$1(strings.join(''));
|
|
13403
13565
|
}
|
|
13404
13566
|
const stringsWithHiddenParameters = strings.map((stringsItem) =>
|
|
13405
13567
|
// TODO: [0] DRY
|
|
@@ -13410,7 +13572,7 @@ function prompt(strings, ...values) {
|
|
|
13410
13572
|
let pipelineString = stringsWithHiddenParameters.reduce((result, stringsItem, i) => placeholderParameterNames[i] === undefined
|
|
13411
13573
|
? `${result}${stringsItem}`
|
|
13412
13574
|
: `${result}${stringsItem}{${placeholderParameterNames[i]}}`, '');
|
|
13413
|
-
pipelineString = spaceTrim(pipelineString);
|
|
13575
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
13414
13576
|
try {
|
|
13415
13577
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
13416
13578
|
}
|
|
@@ -13419,7 +13581,7 @@ function prompt(strings, ...values) {
|
|
|
13419
13581
|
throw error;
|
|
13420
13582
|
}
|
|
13421
13583
|
console.error({ pipelineString, parameters, placeholderParameterNames, error });
|
|
13422
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
13584
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
13423
13585
|
Internal error in prompt template literal
|
|
13424
13586
|
|
|
13425
13587
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -13456,7 +13618,7 @@ function book(strings, ...values) {
|
|
|
13456
13618
|
const bookString = prompt(strings, ...values);
|
|
13457
13619
|
if (!isValidPipelineString(bookString)) {
|
|
13458
13620
|
// TODO: Make the CustomError for this
|
|
13459
|
-
throw new Error(spaceTrim(`
|
|
13621
|
+
throw new Error(spaceTrim$1(`
|
|
13460
13622
|
The string is not a valid pipeline string
|
|
13461
13623
|
|
|
13462
13624
|
book\`
|
|
@@ -13466,7 +13628,7 @@ function book(strings, ...values) {
|
|
|
13466
13628
|
}
|
|
13467
13629
|
if (!isValidBook(bookString)) {
|
|
13468
13630
|
// TODO: Make the CustomError for this
|
|
13469
|
-
throw new Error(spaceTrim(`
|
|
13631
|
+
throw new Error(spaceTrim$1(`
|
|
13470
13632
|
The string is not a valid book
|
|
13471
13633
|
|
|
13472
13634
|
book\`
|