@promptbook/node 0.112.0-13 → 0.112.0-16
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 +185 -185
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/esm/src/cli/cli-commands/coder.d.ts +1 -1
- package/esm/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/esm/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/esm/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/esm/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/esm/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/esm/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +387 -387
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/umd/src/cli/cli-commands/coder.d.ts +1 -1
- package/umd/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/umd/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/umd/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/umd/src/llm-providers/google/google-models.d.ts +1 -1
- package/umd/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/umd/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/umd/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/umd/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/umd/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/umd/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
2
|
import { stat, access, constants, readFile, writeFile, readdir, mkdir, watch, rm, unlink } from 'fs/promises';
|
|
3
3
|
import { basename, join, dirname, isAbsolute, relative } from 'path';
|
|
4
|
-
import
|
|
4
|
+
import _spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
5
5
|
import JSZip from 'jszip';
|
|
6
6
|
import { randomBytes } from 'crypto';
|
|
7
7
|
import { SHA256 } from 'crypto-js';
|
|
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
35
35
|
* @generated
|
|
36
36
|
* @see https://github.com/webgptorg/promptbook
|
|
37
37
|
*/
|
|
38
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
39
39
|
/**
|
|
40
40
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
41
41
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1213,7 +1213,7 @@ true);
|
|
|
1213
1213
|
function getErrorReportUrl(error) {
|
|
1214
1214
|
const report = {
|
|
1215
1215
|
title: `🐜 Error report from ${NAME}`,
|
|
1216
|
-
body: spaceTrim$
|
|
1216
|
+
body: spaceTrim$1((block) => `
|
|
1217
1217
|
|
|
1218
1218
|
|
|
1219
1219
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1286,7 +1286,7 @@ function jsonParse(value) {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
else if (typeof value !== 'string') {
|
|
1288
1288
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
1289
|
-
throw new Error(spaceTrim$
|
|
1289
|
+
throw new Error(spaceTrim$1(`
|
|
1290
1290
|
Can not parse JSON from non-string value.
|
|
1291
1291
|
|
|
1292
1292
|
The value type: ${typeof value}
|
|
@@ -1300,7 +1300,7 @@ function jsonParse(value) {
|
|
|
1300
1300
|
if (!(error instanceof Error)) {
|
|
1301
1301
|
throw error;
|
|
1302
1302
|
}
|
|
1303
|
-
throw new Error(spaceTrim$
|
|
1303
|
+
throw new Error(spaceTrim$1((block) => `
|
|
1304
1304
|
${block(error.message)}
|
|
1305
1305
|
|
|
1306
1306
|
The expected JSON text:
|
|
@@ -1449,7 +1449,7 @@ function checkSerializableAsJson(options) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
else if (typeof value === 'object') {
|
|
1451
1451
|
if (value instanceof Date) {
|
|
1452
|
-
throw new UnexpectedError(spaceTrim$
|
|
1452
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1453
1453
|
\`${name}\` is Date
|
|
1454
1454
|
|
|
1455
1455
|
Use \`string_date_iso8601\` instead
|
|
@@ -1468,7 +1468,7 @@ function checkSerializableAsJson(options) {
|
|
|
1468
1468
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1469
1469
|
}
|
|
1470
1470
|
else if (value instanceof Error) {
|
|
1471
|
-
throw new UnexpectedError(spaceTrim$
|
|
1471
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1472
1472
|
\`${name}\` is unserialized Error
|
|
1473
1473
|
|
|
1474
1474
|
Use function \`serializeError\`
|
|
@@ -1491,7 +1491,7 @@ function checkSerializableAsJson(options) {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
catch (error) {
|
|
1493
1493
|
assertsError(error);
|
|
1494
|
-
throw new UnexpectedError(spaceTrim$
|
|
1494
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1495
1495
|
\`${name}\` is not serializable
|
|
1496
1496
|
|
|
1497
1497
|
${block(error.stack || error.message)}
|
|
@@ -1523,7 +1523,7 @@ function checkSerializableAsJson(options) {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
1525
|
else {
|
|
1526
|
-
throw new UnexpectedError(spaceTrim$
|
|
1526
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1527
1527
|
\`${name}\` is unknown type
|
|
1528
1528
|
|
|
1529
1529
|
Additional message for \`${name}\`:
|
|
@@ -2429,7 +2429,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2429
2429
|
pipelineString += '\n\n';
|
|
2430
2430
|
pipelineString += '```' + contentLanguage;
|
|
2431
2431
|
pipelineString += '\n';
|
|
2432
|
-
pipelineString += spaceTrim$
|
|
2432
|
+
pipelineString += spaceTrim$1(content);
|
|
2433
2433
|
// <- TODO: [main] !!3 Escape
|
|
2434
2434
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2435
2435
|
pipelineString += '\n';
|
|
@@ -3011,7 +3011,7 @@ function serializeError(error) {
|
|
|
3011
3011
|
const { name, message, stack } = error;
|
|
3012
3012
|
const { id } = error;
|
|
3013
3013
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3014
|
-
console.error(spaceTrim$
|
|
3014
|
+
console.error(spaceTrim$1((block) => `
|
|
3015
3015
|
|
|
3016
3016
|
Cannot serialize error with name "${name}"
|
|
3017
3017
|
|
|
@@ -3075,7 +3075,7 @@ function deserializeError(error, isStackAddedToMessage = true) {
|
|
|
3075
3075
|
message = `${name}: ${message}`;
|
|
3076
3076
|
}
|
|
3077
3077
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
3078
|
-
message = spaceTrim$
|
|
3078
|
+
message = spaceTrim$1((block) => `
|
|
3079
3079
|
${block(message)}
|
|
3080
3080
|
|
|
3081
3081
|
Original stack trace:
|
|
@@ -3762,7 +3762,7 @@ const CsvFormatParser = {
|
|
|
3762
3762
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
3763
3763
|
const csv = csvParse(value, settings);
|
|
3764
3764
|
if (csv.errors.length !== 0) {
|
|
3765
|
-
throw new CsvFormatError(spaceTrim$
|
|
3765
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
3766
3766
|
CSV parsing error
|
|
3767
3767
|
|
|
3768
3768
|
Error(s) from CSV parsing:
|
|
@@ -3807,7 +3807,7 @@ const CsvFormatParser = {
|
|
|
3807
3807
|
const { value, settings, mapCallback, onProgress } = options;
|
|
3808
3808
|
const csv = csvParse(value, settings);
|
|
3809
3809
|
if (csv.errors.length !== 0) {
|
|
3810
|
-
throw new CsvFormatError(spaceTrim$
|
|
3810
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
3811
3811
|
CSV parsing error
|
|
3812
3812
|
|
|
3813
3813
|
Error(s) from CSV parsing:
|
|
@@ -4017,7 +4017,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4017
4017
|
}
|
|
4018
4018
|
// Phase 2️⃣: Non-matching mapping
|
|
4019
4019
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
4020
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4020
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
4021
4021
|
Can not map available parameters to expected parameters
|
|
4022
4022
|
|
|
4023
4023
|
Mapped parameters:
|
|
@@ -4095,14 +4095,14 @@ class MultipleLlmExecutionTools {
|
|
|
4095
4095
|
if (description === undefined) {
|
|
4096
4096
|
return headLine;
|
|
4097
4097
|
}
|
|
4098
|
-
return spaceTrim$
|
|
4098
|
+
return spaceTrim$1((block) => `
|
|
4099
4099
|
${headLine}
|
|
4100
4100
|
|
|
4101
4101
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4102
4102
|
`);
|
|
4103
4103
|
})
|
|
4104
4104
|
.join('\n\n');
|
|
4105
|
-
return spaceTrim$
|
|
4105
|
+
return spaceTrim$1((block) => `
|
|
4106
4106
|
Multiple LLM Providers:
|
|
4107
4107
|
|
|
4108
4108
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4204,7 +4204,7 @@ class MultipleLlmExecutionTools {
|
|
|
4204
4204
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4205
4205
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4206
4206
|
// 3) ...
|
|
4207
|
-
spaceTrim$
|
|
4207
|
+
spaceTrim$1((block) => `
|
|
4208
4208
|
All execution tools of ${this.title} failed:
|
|
4209
4209
|
|
|
4210
4210
|
${block(errors
|
|
@@ -4217,7 +4217,7 @@ class MultipleLlmExecutionTools {
|
|
|
4217
4217
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4218
4218
|
}
|
|
4219
4219
|
else {
|
|
4220
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4220
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
4221
4221
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4222
4222
|
|
|
4223
4223
|
Available \`LlmExecutionTools\`:
|
|
@@ -4254,7 +4254,7 @@ class MultipleLlmExecutionTools {
|
|
|
4254
4254
|
*/
|
|
4255
4255
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4256
4256
|
if (llmExecutionTools.length === 0) {
|
|
4257
|
-
const warningMessage = spaceTrim$
|
|
4257
|
+
const warningMessage = spaceTrim$1(`
|
|
4258
4258
|
You have not provided any \`LlmExecutionTools\`
|
|
4259
4259
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4260
4260
|
|
|
@@ -5344,7 +5344,7 @@ async function executeFormatSubvalues(options) {
|
|
|
5344
5344
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
5345
5345
|
}
|
|
5346
5346
|
if (jokerParameterNames.length !== 0) {
|
|
5347
|
-
throw new UnexpectedError(spaceTrim$
|
|
5347
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
5348
5348
|
JOKER parameters are not supported together with FOREACH command
|
|
5349
5349
|
|
|
5350
5350
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -5357,7 +5357,7 @@ async function executeFormatSubvalues(options) {
|
|
|
5357
5357
|
if (formatDefinition === undefined) {
|
|
5358
5358
|
throw new UnexpectedError(
|
|
5359
5359
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
5360
|
-
spaceTrim$
|
|
5360
|
+
spaceTrim$1((block) => `
|
|
5361
5361
|
Unsupported format "${task.foreach.formatName}"
|
|
5362
5362
|
|
|
5363
5363
|
Available formats:
|
|
@@ -5374,7 +5374,7 @@ async function executeFormatSubvalues(options) {
|
|
|
5374
5374
|
if (subvalueParser === undefined) {
|
|
5375
5375
|
throw new UnexpectedError(
|
|
5376
5376
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
5377
|
-
spaceTrim$
|
|
5377
|
+
spaceTrim$1((block) => `
|
|
5378
5378
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
5379
5379
|
|
|
5380
5380
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -5414,7 +5414,7 @@ async function executeFormatSubvalues(options) {
|
|
|
5414
5414
|
if (!(error instanceof PipelineExecutionError)) {
|
|
5415
5415
|
throw error;
|
|
5416
5416
|
}
|
|
5417
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
5417
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5418
5418
|
${error.message}
|
|
5419
5419
|
|
|
5420
5420
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -5438,7 +5438,7 @@ async function executeFormatSubvalues(options) {
|
|
|
5438
5438
|
...options,
|
|
5439
5439
|
priority: priority + index,
|
|
5440
5440
|
parameters: allSubparameters,
|
|
5441
|
-
pipelineIdentification: spaceTrim$
|
|
5441
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
5442
5442
|
${block(pipelineIdentification)}
|
|
5443
5443
|
Subparameter index: ${index}
|
|
5444
5444
|
`),
|
|
@@ -5447,7 +5447,7 @@ async function executeFormatSubvalues(options) {
|
|
|
5447
5447
|
}
|
|
5448
5448
|
catch (error) {
|
|
5449
5449
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
5450
|
-
console.error(spaceTrim$
|
|
5450
|
+
console.error(spaceTrim$1((block) => `
|
|
5451
5451
|
${error.message}
|
|
5452
5452
|
|
|
5453
5453
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6619,14 +6619,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
6619
6619
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
6620
6620
|
});
|
|
6621
6621
|
if (metadata.length === 0) {
|
|
6622
|
-
return spaceTrim$
|
|
6622
|
+
return spaceTrim$1(`
|
|
6623
6623
|
**No scrapers are available**
|
|
6624
6624
|
|
|
6625
6625
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
6626
6626
|
At least there should be available the metadata of the scrapers
|
|
6627
6627
|
`);
|
|
6628
6628
|
}
|
|
6629
|
-
return spaceTrim$
|
|
6629
|
+
return spaceTrim$1((block) => `
|
|
6630
6630
|
Available scrapers are:
|
|
6631
6631
|
${block(metadata
|
|
6632
6632
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -6869,7 +6869,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
6869
6869
|
else if (urlOrRequest instanceof Request) {
|
|
6870
6870
|
url = urlOrRequest.url;
|
|
6871
6871
|
}
|
|
6872
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
6872
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
6873
6873
|
Can not fetch "${url}"
|
|
6874
6874
|
|
|
6875
6875
|
Fetch error:
|
|
@@ -7029,7 +7029,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
7029
7029
|
const fileExtension = getFileExtension(filename);
|
|
7030
7030
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
7031
7031
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
7032
|
-
throw new NotFoundError(spaceTrim$
|
|
7032
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
7033
7033
|
Can not make source handler for file which does not exist:
|
|
7034
7034
|
|
|
7035
7035
|
File:
|
|
@@ -7122,7 +7122,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
7122
7122
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
7123
7123
|
break;
|
|
7124
7124
|
}
|
|
7125
|
-
console.warn(spaceTrim$
|
|
7125
|
+
console.warn(spaceTrim$1((block) => `
|
|
7126
7126
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
7127
7127
|
|
|
7128
7128
|
The source:
|
|
@@ -7138,7 +7138,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
7138
7138
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7139
7139
|
}
|
|
7140
7140
|
if (partialPieces === null) {
|
|
7141
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
7141
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
7142
7142
|
Cannot scrape knowledge
|
|
7143
7143
|
|
|
7144
7144
|
The source:
|
|
@@ -7474,7 +7474,7 @@ const knowledgeCommandParser = {
|
|
|
7474
7474
|
*/
|
|
7475
7475
|
parse(input) {
|
|
7476
7476
|
const { args } = input;
|
|
7477
|
-
const knowledgeSourceContent = spaceTrim$
|
|
7477
|
+
const knowledgeSourceContent = spaceTrim$1(args[0] || '');
|
|
7478
7478
|
if (knowledgeSourceContent === '') {
|
|
7479
7479
|
throw new ParseError(`Source is not defined`);
|
|
7480
7480
|
}
|
|
@@ -7618,7 +7618,7 @@ const sectionCommandParser = {
|
|
|
7618
7618
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
7619
7619
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
7620
7620
|
if (taskTypes.length !== 1) {
|
|
7621
|
-
throw new ParseError(spaceTrim$
|
|
7621
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
7622
7622
|
Unknown section type "${normalized}"
|
|
7623
7623
|
|
|
7624
7624
|
Supported section types are:
|
|
@@ -7638,7 +7638,7 @@ const sectionCommandParser = {
|
|
|
7638
7638
|
*/
|
|
7639
7639
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
7640
7640
|
if ($taskJson.isSectionTypeSet === true) {
|
|
7641
|
-
throw new ParseError(spaceTrim$
|
|
7641
|
+
throw new ParseError(spaceTrim$1(`
|
|
7642
7642
|
Section type is already defined in the section.
|
|
7643
7643
|
It can be defined only once.
|
|
7644
7644
|
`));
|
|
@@ -7990,7 +7990,7 @@ const expectCommandParser = {
|
|
|
7990
7990
|
/**
|
|
7991
7991
|
* Description of the FORMAT command
|
|
7992
7992
|
*/
|
|
7993
|
-
description: spaceTrim$
|
|
7993
|
+
description: spaceTrim$1(`
|
|
7994
7994
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
7995
7995
|
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.
|
|
7996
7996
|
`),
|
|
@@ -8064,7 +8064,7 @@ const expectCommandParser = {
|
|
|
8064
8064
|
}
|
|
8065
8065
|
catch (error) {
|
|
8066
8066
|
assertsError(error);
|
|
8067
|
-
throw new ParseError(spaceTrim$
|
|
8067
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8068
8068
|
Invalid FORMAT command
|
|
8069
8069
|
${block(error.message)}:
|
|
8070
8070
|
`));
|
|
@@ -8254,7 +8254,7 @@ function validateParameterName(parameterName) {
|
|
|
8254
8254
|
if (!(error instanceof ParseError)) {
|
|
8255
8255
|
throw error;
|
|
8256
8256
|
}
|
|
8257
|
-
throw new ParseError(spaceTrim$
|
|
8257
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8258
8258
|
${block(error.message)}
|
|
8259
8259
|
|
|
8260
8260
|
Tried to validate parameter name:
|
|
@@ -8313,7 +8313,7 @@ const foreachCommandParser = {
|
|
|
8313
8313
|
const assignSign = args[3];
|
|
8314
8314
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
8315
8315
|
if (formatDefinition === undefined) {
|
|
8316
|
-
throw new ParseError(spaceTrim$
|
|
8316
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8317
8317
|
Unsupported format "${formatName}"
|
|
8318
8318
|
|
|
8319
8319
|
Available formats:
|
|
@@ -8325,7 +8325,7 @@ const foreachCommandParser = {
|
|
|
8325
8325
|
}
|
|
8326
8326
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
8327
8327
|
if (subvalueParser === undefined) {
|
|
8328
|
-
throw new ParseError(spaceTrim$
|
|
8328
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8329
8329
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
8330
8330
|
|
|
8331
8331
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -8373,7 +8373,7 @@ const foreachCommandParser = {
|
|
|
8373
8373
|
outputSubparameterName = 'newLine';
|
|
8374
8374
|
}
|
|
8375
8375
|
else {
|
|
8376
|
-
throw new ParseError(spaceTrim$
|
|
8376
|
+
throw new ParseError(spaceTrim$1(`
|
|
8377
8377
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
8378
8378
|
|
|
8379
8379
|
Correct example:
|
|
@@ -8449,7 +8449,7 @@ const formatCommandParser = {
|
|
|
8449
8449
|
/**
|
|
8450
8450
|
* Description of the FORMAT command
|
|
8451
8451
|
*/
|
|
8452
|
-
description: spaceTrim$
|
|
8452
|
+
description: spaceTrim$1(`
|
|
8453
8453
|
Format command describes the desired output of the task (after post-processing)
|
|
8454
8454
|
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.
|
|
8455
8455
|
`),
|
|
@@ -8821,7 +8821,7 @@ const formfactorCommandParser = {
|
|
|
8821
8821
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
8822
8822
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
8823
8823
|
if (formfactor === undefined) {
|
|
8824
|
-
throw new ParseError(spaceTrim$
|
|
8824
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
8825
8825
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
8826
8826
|
|
|
8827
8827
|
Available formfactors:
|
|
@@ -8840,7 +8840,7 @@ const formfactorCommandParser = {
|
|
|
8840
8840
|
*/
|
|
8841
8841
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
8842
8842
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
8843
|
-
throw new ParseError(spaceTrim$
|
|
8843
|
+
throw new ParseError(spaceTrim$1(`
|
|
8844
8844
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
8845
8845
|
|
|
8846
8846
|
You have used:
|
|
@@ -8988,7 +8988,7 @@ const modelCommandParser = {
|
|
|
8988
8988
|
*/
|
|
8989
8989
|
parse(input) {
|
|
8990
8990
|
const { args, normalized } = input;
|
|
8991
|
-
const availableVariantsMessage = spaceTrim$
|
|
8991
|
+
const availableVariantsMessage = spaceTrim$1((block) => `
|
|
8992
8992
|
Available variants are:
|
|
8993
8993
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
8994
8994
|
`);
|
|
@@ -9010,14 +9010,14 @@ const modelCommandParser = {
|
|
|
9010
9010
|
// <- Note: [🤖]
|
|
9011
9011
|
}
|
|
9012
9012
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
9013
|
-
spaceTrim$
|
|
9013
|
+
spaceTrim$1((block) => `
|
|
9014
9014
|
Embedding model can not be used in pipeline
|
|
9015
9015
|
|
|
9016
9016
|
${block(availableVariantsMessage)}
|
|
9017
9017
|
`);
|
|
9018
9018
|
}
|
|
9019
9019
|
else {
|
|
9020
|
-
throw new ParseError(spaceTrim$
|
|
9020
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9021
9021
|
Unknown model variant in command:
|
|
9022
9022
|
|
|
9023
9023
|
${block(availableVariantsMessage)}
|
|
@@ -9032,7 +9032,7 @@ const modelCommandParser = {
|
|
|
9032
9032
|
};
|
|
9033
9033
|
}
|
|
9034
9034
|
else {
|
|
9035
|
-
throw new ParseError(spaceTrim$
|
|
9035
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9036
9036
|
Unknown model key in command.
|
|
9037
9037
|
|
|
9038
9038
|
Supported model keys are:
|
|
@@ -9059,7 +9059,7 @@ const modelCommandParser = {
|
|
|
9059
9059
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9060
9060
|
}
|
|
9061
9061
|
else {
|
|
9062
|
-
throw new ParseError(spaceTrim$
|
|
9062
|
+
throw new ParseError(spaceTrim$1(`
|
|
9063
9063
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
9064
9064
|
|
|
9065
9065
|
You have used:
|
|
@@ -9087,7 +9087,7 @@ const modelCommandParser = {
|
|
|
9087
9087
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9088
9088
|
}
|
|
9089
9089
|
else {
|
|
9090
|
-
throw new ParseError(spaceTrim$
|
|
9090
|
+
throw new ParseError(spaceTrim$1(`
|
|
9091
9091
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
9092
9092
|
|
|
9093
9093
|
You have used:
|
|
@@ -9097,7 +9097,7 @@ const modelCommandParser = {
|
|
|
9097
9097
|
}
|
|
9098
9098
|
}
|
|
9099
9099
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
9100
|
-
console.log(spaceTrim$
|
|
9100
|
+
console.log(spaceTrim$1(`
|
|
9101
9101
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
9102
9102
|
|
|
9103
9103
|
In pipeline head:
|
|
@@ -9180,7 +9180,7 @@ const parameterCommandParser = {
|
|
|
9180
9180
|
// <- TODO: When [🥶] fixed, change to:
|
|
9181
9181
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
9182
9182
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
9183
|
-
throw new ParseError(spaceTrim$
|
|
9183
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
9184
9184
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
9185
9185
|
|
|
9186
9186
|
The description:
|
|
@@ -9362,7 +9362,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
9362
9362
|
persona.description = personaDescription;
|
|
9363
9363
|
return;
|
|
9364
9364
|
}
|
|
9365
|
-
console.warn(spaceTrim$
|
|
9365
|
+
console.warn(spaceTrim$1(`
|
|
9366
9366
|
|
|
9367
9367
|
Persona "${personaName}" is defined multiple times with different description:
|
|
9368
9368
|
|
|
@@ -9373,7 +9373,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
9373
9373
|
${personaDescription}
|
|
9374
9374
|
|
|
9375
9375
|
`));
|
|
9376
|
-
persona.description += spaceTrim$
|
|
9376
|
+
persona.description += spaceTrim$1('\n\n' + personaDescription);
|
|
9377
9377
|
}
|
|
9378
9378
|
|
|
9379
9379
|
/**
|
|
@@ -10228,7 +10228,7 @@ function removeMarkdownComments(content) {
|
|
|
10228
10228
|
*/
|
|
10229
10229
|
function isFlatPipeline(pipelineString) {
|
|
10230
10230
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
10231
|
-
pipelineString = spaceTrim$
|
|
10231
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
10232
10232
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
10233
10233
|
//const isLastLineReturnStatement = pipelineString.split(/\r?\n/).pop()!.split('`').join('').startsWith('->');
|
|
10234
10234
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -10254,7 +10254,7 @@ function deflatePipeline(pipelineString) {
|
|
|
10254
10254
|
if (!isFlatPipeline(pipelineString)) {
|
|
10255
10255
|
return pipelineString;
|
|
10256
10256
|
}
|
|
10257
|
-
pipelineString = spaceTrim$
|
|
10257
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
10258
10258
|
const pipelineStringLines = pipelineString.split(/\r?\n/);
|
|
10259
10259
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
10260
10260
|
let returnStatement;
|
|
@@ -10267,19 +10267,19 @@ function deflatePipeline(pipelineString) {
|
|
|
10267
10267
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
10268
10268
|
pipelineStringLines.push(potentialReturnStatement);
|
|
10269
10269
|
}
|
|
10270
|
-
const prompt = spaceTrim$
|
|
10270
|
+
const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
|
|
10271
10271
|
let quotedPrompt;
|
|
10272
10272
|
if (prompt.split(/\r?\n/).length <= 1) {
|
|
10273
10273
|
quotedPrompt = `> ${prompt}`;
|
|
10274
10274
|
}
|
|
10275
10275
|
else {
|
|
10276
|
-
quotedPrompt = spaceTrim$
|
|
10276
|
+
quotedPrompt = spaceTrim$1((block) => `
|
|
10277
10277
|
\`\`\`
|
|
10278
10278
|
${block(prompt.split('`').join('\\`'))}
|
|
10279
10279
|
\`\`\`
|
|
10280
10280
|
`);
|
|
10281
10281
|
}
|
|
10282
|
-
pipelineString = validatePipelineString(spaceTrim$
|
|
10282
|
+
pipelineString = validatePipelineString(spaceTrim$1((block) => `
|
|
10283
10283
|
# ${DEFAULT_BOOK_TITLE}
|
|
10284
10284
|
|
|
10285
10285
|
## Prompt
|
|
@@ -10343,7 +10343,7 @@ function extractAllListItemsFromMarkdown(markdown) {
|
|
|
10343
10343
|
function extractOneBlockFromMarkdown(markdown) {
|
|
10344
10344
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
10345
10345
|
if (codeBlocks.length !== 1) {
|
|
10346
|
-
throw new ParseError(spaceTrim$
|
|
10346
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
10347
10347
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
10348
10348
|
|
|
10349
10349
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -10368,7 +10368,7 @@ function parseMarkdownSection(value) {
|
|
|
10368
10368
|
}
|
|
10369
10369
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
10370
10370
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
10371
|
-
const content = spaceTrim$
|
|
10371
|
+
const content = spaceTrim$1(lines.slice(1).join('\n'));
|
|
10372
10372
|
if (level < 1 || level > 6) {
|
|
10373
10373
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
10374
10374
|
}
|
|
@@ -10396,7 +10396,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
10396
10396
|
if (buffer.length === 0) {
|
|
10397
10397
|
return;
|
|
10398
10398
|
}
|
|
10399
|
-
let section = spaceTrim$
|
|
10399
|
+
let section = spaceTrim$1(buffer.join('\n'));
|
|
10400
10400
|
if (section === '') {
|
|
10401
10401
|
return;
|
|
10402
10402
|
}
|
|
@@ -10471,7 +10471,7 @@ function flattenMarkdown(markdown) {
|
|
|
10471
10471
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
10472
10472
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
10473
10473
|
}
|
|
10474
|
-
return spaceTrim$
|
|
10474
|
+
return spaceTrim$1(flattenedMarkdown);
|
|
10475
10475
|
}
|
|
10476
10476
|
/**
|
|
10477
10477
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -11214,7 +11214,7 @@ function buildParametersSection(items) {
|
|
|
11214
11214
|
const entries = items
|
|
11215
11215
|
.flatMap((item) => formatParameterListItem(item).split(/\r?\n/))
|
|
11216
11216
|
.filter((line) => line !== '');
|
|
11217
|
-
return spaceTrim$
|
|
11217
|
+
return spaceTrim$1((block) => `
|
|
11218
11218
|
**Parameters:**
|
|
11219
11219
|
${block(entries.join('\n'))}
|
|
11220
11220
|
|
|
@@ -11287,7 +11287,7 @@ function isPromptString(value) {
|
|
|
11287
11287
|
*/
|
|
11288
11288
|
function prompt(strings, ...values) {
|
|
11289
11289
|
if (values.length === 0) {
|
|
11290
|
-
return new PromptString(spaceTrim$
|
|
11290
|
+
return new PromptString(spaceTrim$1(strings.join('')));
|
|
11291
11291
|
}
|
|
11292
11292
|
const stringsWithHiddenParameters = strings.map((stringsItem) => ParameterEscaping.hideBrackets(stringsItem));
|
|
11293
11293
|
const parameterMetadata = values.map((value) => {
|
|
@@ -11328,7 +11328,7 @@ function prompt(strings, ...values) {
|
|
|
11328
11328
|
? `${result}${stringsItem}`
|
|
11329
11329
|
: `${result}${stringsItem}${ParameterSection.formatParameterPlaceholder(parameterName)}`;
|
|
11330
11330
|
}, '');
|
|
11331
|
-
pipelineString = spaceTrim$
|
|
11331
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
11332
11332
|
try {
|
|
11333
11333
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
11334
11334
|
}
|
|
@@ -11337,7 +11337,7 @@ function prompt(strings, ...values) {
|
|
|
11337
11337
|
throw error;
|
|
11338
11338
|
}
|
|
11339
11339
|
console.error({ pipelineString, parameters, parameterNames: parameterNamesOrdered, error });
|
|
11340
|
-
throw new UnexpectedError(spaceTrim$
|
|
11340
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
11341
11341
|
Internal error in prompt template literal
|
|
11342
11342
|
|
|
11343
11343
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -11478,7 +11478,7 @@ function $isRunningInWebWorker() {
|
|
|
11478
11478
|
* @public exported from `@promptbook/utils`
|
|
11479
11479
|
*/
|
|
11480
11480
|
function computeHash(value) {
|
|
11481
|
-
return SHA256(hexEncoder.parse(spaceTrim$
|
|
11481
|
+
return SHA256(hexEncoder.parse(spaceTrim$1(valueToString(value)))).toString( /* hex */);
|
|
11482
11482
|
}
|
|
11483
11483
|
/**
|
|
11484
11484
|
* TODO: [🥬][🥬] Use this ACRY
|
|
@@ -13442,8 +13442,8 @@ class MarkdownScraper {
|
|
|
13442
13442
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
13443
13443
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
13444
13444
|
let name = `piece-${i}`;
|
|
13445
|
-
let title = spaceTrim$
|
|
13446
|
-
const knowledgePieceContent = spaceTrim$
|
|
13445
|
+
let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
13446
|
+
const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
|
|
13447
13447
|
let keywords = [];
|
|
13448
13448
|
const index = [];
|
|
13449
13449
|
/*
|
|
@@ -13456,7 +13456,7 @@ class MarkdownScraper {
|
|
|
13456
13456
|
isCrashedOnError: true,
|
|
13457
13457
|
});
|
|
13458
13458
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
13459
|
-
title = spaceTrim$
|
|
13459
|
+
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
13460
13460
|
name = titleToName(title);
|
|
13461
13461
|
// --- Keywords
|
|
13462
13462
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -25255,13 +25255,13 @@ function $registeredLlmToolsMessage() {
|
|
|
25255
25255
|
});
|
|
25256
25256
|
const usedEnvMessage = $usedEnvFilename === null ? `Unknown \`.env\` file` : `Used \`.env\` file:\n${$usedEnvFilename}`;
|
|
25257
25257
|
if (metadata.length === 0) {
|
|
25258
|
-
return spaceTrim$
|
|
25258
|
+
return spaceTrim$1((block) => `
|
|
25259
25259
|
No LLM providers are available.
|
|
25260
25260
|
|
|
25261
25261
|
${block(usedEnvMessage)}
|
|
25262
25262
|
`);
|
|
25263
25263
|
}
|
|
25264
|
-
return spaceTrim$
|
|
25264
|
+
return spaceTrim$1((block) => `
|
|
25265
25265
|
|
|
25266
25266
|
${block(usedEnvMessage)}
|
|
25267
25267
|
|
|
@@ -25307,7 +25307,7 @@ function $registeredLlmToolsMessage() {
|
|
|
25307
25307
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
25308
25308
|
}
|
|
25309
25309
|
}
|
|
25310
|
-
let providerMessage = spaceTrim$
|
|
25310
|
+
let providerMessage = spaceTrim$1(`
|
|
25311
25311
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
25312
25312
|
${morePieces.join('; ')}
|
|
25313
25313
|
`);
|
|
@@ -25429,7 +25429,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
|
25429
25429
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
25430
25430
|
if (registeredItem === undefined) {
|
|
25431
25431
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
25432
|
-
throw new Error(spaceTrim$
|
|
25432
|
+
throw new Error(spaceTrim$1((block) => `
|
|
25433
25433
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
25434
25434
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
25435
25435
|
|
|
@@ -25497,14 +25497,14 @@ async function $provideLlmToolsFromEnv(options = {}) {
|
|
|
25497
25497
|
const configuration = await $provideLlmToolsConfigurationFromEnv();
|
|
25498
25498
|
if (configuration.length === 0) {
|
|
25499
25499
|
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
25500
|
-
throw new UnexpectedError(spaceTrim$
|
|
25500
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
25501
25501
|
No LLM tools registered, this is probably a bug in the Promptbook library
|
|
25502
25502
|
|
|
25503
25503
|
${block($registeredLlmToolsMessage())}}
|
|
25504
25504
|
`));
|
|
25505
25505
|
}
|
|
25506
25506
|
// TODO: [🥃]
|
|
25507
|
-
throw new Error(spaceTrim$
|
|
25507
|
+
throw new Error(spaceTrim$1((block) => `
|
|
25508
25508
|
No LLM tools found in the environment
|
|
25509
25509
|
|
|
25510
25510
|
${block($registeredLlmToolsMessage())}}
|
|
@@ -25656,7 +25656,7 @@ class JavascriptEvalExecutionTools {
|
|
|
25656
25656
|
}
|
|
25657
25657
|
// Note: [💎]
|
|
25658
25658
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
25659
|
-
const spaceTrim = (_) =>
|
|
25659
|
+
const spaceTrim = (_) => _spaceTrim(_);
|
|
25660
25660
|
$preserve(spaceTrim);
|
|
25661
25661
|
const removeQuotes$1 = removeQuotes;
|
|
25662
25662
|
$preserve(removeQuotes$1);
|
|
@@ -25747,7 +25747,7 @@ class JavascriptEvalExecutionTools {
|
|
|
25747
25747
|
.join('\n');
|
|
25748
25748
|
// script = templateParameters(script, parameters);
|
|
25749
25749
|
// <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
|
|
25750
|
-
const statementToEvaluate =
|
|
25750
|
+
const statementToEvaluate = _spaceTrim((block) => `
|
|
25751
25751
|
|
|
25752
25752
|
// Build-in functions:
|
|
25753
25753
|
${block(buildinFunctionsStatement)}
|
|
@@ -25762,7 +25762,7 @@ class JavascriptEvalExecutionTools {
|
|
|
25762
25762
|
(async ()=>{ ${script} })()
|
|
25763
25763
|
`);
|
|
25764
25764
|
if (this.options.isVerbose) {
|
|
25765
|
-
console.info(
|
|
25765
|
+
console.info(_spaceTrim((block) => `
|
|
25766
25766
|
🚀 Evaluating ${scriptLanguage} script:
|
|
25767
25767
|
|
|
25768
25768
|
${block(statementToEvaluate)}`));
|
|
@@ -25771,7 +25771,7 @@ class JavascriptEvalExecutionTools {
|
|
|
25771
25771
|
try {
|
|
25772
25772
|
result = await eval(statementToEvaluate);
|
|
25773
25773
|
if (this.options.isVerbose) {
|
|
25774
|
-
console.info(
|
|
25774
|
+
console.info(_spaceTrim((block) => `
|
|
25775
25775
|
🚀 Script evaluated successfully, result:
|
|
25776
25776
|
${block(valueToString(result))}
|
|
25777
25777
|
`));
|
|
@@ -25790,7 +25790,7 @@ class JavascriptEvalExecutionTools {
|
|
|
25790
25790
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
25791
25791
|
*/
|
|
25792
25792
|
if (!statementToEvaluate.includes(undefinedName + '(')) {
|
|
25793
|
-
throw new PipelineExecutionError(
|
|
25793
|
+
throw new PipelineExecutionError(_spaceTrim((block) => `
|
|
25794
25794
|
|
|
25795
25795
|
Parameter \`{${undefinedName}}\` is not defined
|
|
25796
25796
|
|
|
@@ -25812,7 +25812,7 @@ class JavascriptEvalExecutionTools {
|
|
|
25812
25812
|
`));
|
|
25813
25813
|
}
|
|
25814
25814
|
else {
|
|
25815
|
-
throw new PipelineExecutionError(
|
|
25815
|
+
throw new PipelineExecutionError(_spaceTrim((block) => `
|
|
25816
25816
|
Function ${undefinedName}() is not defined
|
|
25817
25817
|
|
|
25818
25818
|
- Make sure that the function is one of built-in functions
|
|
@@ -26065,7 +26065,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
26065
26065
|
catch (error) {
|
|
26066
26066
|
assertsError(error);
|
|
26067
26067
|
// TODO: [7] DRY
|
|
26068
|
-
const wrappedErrorMessage = spaceTrim$
|
|
26068
|
+
const wrappedErrorMessage = spaceTrim$1((block) => `
|
|
26069
26069
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
26070
26070
|
|
|
26071
26071
|
Original error message:
|
|
@@ -26100,7 +26100,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
26100
26100
|
pipeline = { ...pipeline, pipelineUrl };
|
|
26101
26101
|
}
|
|
26102
26102
|
else if (!pipeline.pipelineUrl.startsWith(rootUrl)) {
|
|
26103
|
-
throw new PipelineUrlError(spaceTrim$
|
|
26103
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
26104
26104
|
Pipeline with URL ${pipeline.pipelineUrl} is not a child of the root URL ${rootUrl} 🍏
|
|
26105
26105
|
|
|
26106
26106
|
File:
|
|
@@ -26138,7 +26138,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
26138
26138
|
}
|
|
26139
26139
|
else {
|
|
26140
26140
|
const existing = collection.get(pipeline.pipelineUrl);
|
|
26141
|
-
throw new PipelineUrlError(spaceTrim$
|
|
26141
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
26142
26142
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍏
|
|
26143
26143
|
|
|
26144
26144
|
Conflicting files:
|
|
@@ -26156,7 +26156,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
26156
26156
|
catch (error) {
|
|
26157
26157
|
assertsError(error);
|
|
26158
26158
|
// TODO: [7] DRY
|
|
26159
|
-
const wrappedErrorMessage = spaceTrim$
|
|
26159
|
+
const wrappedErrorMessage = spaceTrim$1((block) => `
|
|
26160
26160
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
26161
26161
|
|
|
26162
26162
|
Original error message:
|
|
@@ -26214,7 +26214,7 @@ async function $provideScriptingForNode(options) {
|
|
|
26214
26214
|
*/
|
|
26215
26215
|
function stringifyPipelineJson(pipeline) {
|
|
26216
26216
|
if (!isSerializableAsJson(pipeline)) {
|
|
26217
|
-
throw new UnexpectedError(spaceTrim$
|
|
26217
|
+
throw new UnexpectedError(spaceTrim$1(`
|
|
26218
26218
|
Cannot stringify the pipeline, because it is not serializable as JSON
|
|
26219
26219
|
|
|
26220
26220
|
There can be multiple reasons:
|
|
@@ -26393,7 +26393,7 @@ function validateBook(source) {
|
|
|
26393
26393
|
* @deprecated Use `$generateBookBoilerplate` instead
|
|
26394
26394
|
* @public exported from `@promptbook/core`
|
|
26395
26395
|
*/
|
|
26396
|
-
padBook(validateBook(spaceTrim$
|
|
26396
|
+
padBook(validateBook(spaceTrim$1(`
|
|
26397
26397
|
AI Avatar
|
|
26398
26398
|
|
|
26399
26399
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -26442,7 +26442,7 @@ function book(strings, ...values) {
|
|
|
26442
26442
|
const bookString = prompt(strings, ...values).toString();
|
|
26443
26443
|
if (!isValidPipelineString(bookString)) {
|
|
26444
26444
|
// TODO: Make the CustomError for this
|
|
26445
|
-
throw new Error(spaceTrim$
|
|
26445
|
+
throw new Error(spaceTrim$1(`
|
|
26446
26446
|
The string is not a valid pipeline string
|
|
26447
26447
|
|
|
26448
26448
|
book\`
|
|
@@ -26452,7 +26452,7 @@ function book(strings, ...values) {
|
|
|
26452
26452
|
}
|
|
26453
26453
|
if (!isValidBook(bookString)) {
|
|
26454
26454
|
// TODO: Make the CustomError for this
|
|
26455
|
-
throw new Error(spaceTrim$
|
|
26455
|
+
throw new Error(spaceTrim$1(`
|
|
26456
26456
|
The string is not a valid book
|
|
26457
26457
|
|
|
26458
26458
|
book\`
|
|
@@ -26736,7 +26736,7 @@ function computeAgentHash(agentSource) {
|
|
|
26736
26736
|
* @public exported from `@promptbook/core`
|
|
26737
26737
|
*/
|
|
26738
26738
|
function normalizeAgentName(rawAgentName) {
|
|
26739
|
-
return titleToName(spaceTrim$
|
|
26739
|
+
return titleToName(spaceTrim$1(rawAgentName));
|
|
26740
26740
|
}
|
|
26741
26741
|
|
|
26742
26742
|
/**
|
|
@@ -27180,7 +27180,7 @@ function parseAgentSource(agentSource) {
|
|
|
27180
27180
|
continue;
|
|
27181
27181
|
}
|
|
27182
27182
|
if (commitment.type === 'FROM') {
|
|
27183
|
-
const content = spaceTrim$
|
|
27183
|
+
const content = spaceTrim$1(commitment.content).split(/\r?\n/)[0] || '';
|
|
27184
27184
|
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
27185
27185
|
continue;
|
|
27186
27186
|
}
|
|
@@ -27203,7 +27203,7 @@ function parseAgentSource(agentSource) {
|
|
|
27203
27203
|
continue;
|
|
27204
27204
|
}
|
|
27205
27205
|
if (commitment.type === 'IMPORT') {
|
|
27206
|
-
const content = spaceTrim$
|
|
27206
|
+
const content = spaceTrim$1(commitment.content).split(/\r?\n/)[0] || '';
|
|
27207
27207
|
let label = content;
|
|
27208
27208
|
let iconName = 'ExternalLink'; // Import remote
|
|
27209
27209
|
try {
|
|
@@ -27241,7 +27241,7 @@ function parseAgentSource(agentSource) {
|
|
|
27241
27241
|
continue;
|
|
27242
27242
|
}
|
|
27243
27243
|
if (commitment.type === 'KNOWLEDGE') {
|
|
27244
|
-
const content = spaceTrim$
|
|
27244
|
+
const content = spaceTrim$1(commitment.content);
|
|
27245
27245
|
const extractedUrls = extractUrlsFromText(content);
|
|
27246
27246
|
let label = content;
|
|
27247
27247
|
let iconName = 'Book';
|
|
@@ -27300,7 +27300,7 @@ function parseAgentSource(agentSource) {
|
|
|
27300
27300
|
continue;
|
|
27301
27301
|
}
|
|
27302
27302
|
if (commitment.type === 'META LINK') {
|
|
27303
|
-
const linkValue = spaceTrim$
|
|
27303
|
+
const linkValue = spaceTrim$1(commitment.content);
|
|
27304
27304
|
links.push(linkValue);
|
|
27305
27305
|
meta.link = linkValue;
|
|
27306
27306
|
continue;
|
|
@@ -27310,11 +27310,11 @@ function parseAgentSource(agentSource) {
|
|
|
27310
27310
|
continue;
|
|
27311
27311
|
}
|
|
27312
27312
|
if (commitment.type === 'META IMAGE') {
|
|
27313
|
-
meta.image = spaceTrim$
|
|
27313
|
+
meta.image = spaceTrim$1(commitment.content);
|
|
27314
27314
|
continue;
|
|
27315
27315
|
}
|
|
27316
27316
|
if (commitment.type === 'META DESCRIPTION') {
|
|
27317
|
-
meta.description = spaceTrim$
|
|
27317
|
+
meta.description = spaceTrim$1(commitment.content);
|
|
27318
27318
|
continue;
|
|
27319
27319
|
}
|
|
27320
27320
|
if (commitment.type === 'META DISCLAIMER') {
|
|
@@ -27322,7 +27322,7 @@ function parseAgentSource(agentSource) {
|
|
|
27322
27322
|
continue;
|
|
27323
27323
|
}
|
|
27324
27324
|
if (commitment.type === 'META INPUT PLACEHOLDER') {
|
|
27325
|
-
meta.inputPlaceholder = spaceTrim$
|
|
27325
|
+
meta.inputPlaceholder = spaceTrim$1(commitment.content);
|
|
27326
27326
|
continue;
|
|
27327
27327
|
}
|
|
27328
27328
|
if (commitment.type === 'MESSAGE SUFFIX') {
|
|
@@ -27338,7 +27338,7 @@ function parseAgentSource(agentSource) {
|
|
|
27338
27338
|
continue;
|
|
27339
27339
|
}
|
|
27340
27340
|
if (commitment.type === 'META VOICE') {
|
|
27341
|
-
meta.voice = spaceTrim$
|
|
27341
|
+
meta.voice = spaceTrim$1(commitment.content);
|
|
27342
27342
|
continue;
|
|
27343
27343
|
}
|
|
27344
27344
|
if (commitment.type !== 'META') {
|
|
@@ -27347,10 +27347,10 @@ function parseAgentSource(agentSource) {
|
|
|
27347
27347
|
// Parse META commitments - format is "META TYPE content"
|
|
27348
27348
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
27349
27349
|
if (metaTypeRaw === 'LINK') {
|
|
27350
|
-
links.push(spaceTrim$
|
|
27350
|
+
links.push(spaceTrim$1(commitment.content.substring(metaTypeRaw.length)));
|
|
27351
27351
|
}
|
|
27352
27352
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
27353
|
-
meta[metaType] = spaceTrim$
|
|
27353
|
+
meta[metaType] = spaceTrim$1(commitment.content.substring(metaTypeRaw.length));
|
|
27354
27354
|
}
|
|
27355
27355
|
// Generate fullname fallback if no meta fullname specified
|
|
27356
27356
|
if (!meta.fullname) {
|
|
@@ -27381,7 +27381,7 @@ function parseAgentSource(agentSource) {
|
|
|
27381
27381
|
* @returns The content with normalized separators
|
|
27382
27382
|
*/
|
|
27383
27383
|
function normalizeSeparator(content) {
|
|
27384
|
-
const trimmed = spaceTrim$
|
|
27384
|
+
const trimmed = spaceTrim$1(content);
|
|
27385
27385
|
if (trimmed.includes(',')) {
|
|
27386
27386
|
return trimmed;
|
|
27387
27387
|
}
|
|
@@ -27394,7 +27394,7 @@ function normalizeSeparator(content) {
|
|
|
27394
27394
|
* @returns Normalized domain or a trimmed fallback.
|
|
27395
27395
|
*/
|
|
27396
27396
|
function normalizeMetaDomain(content) {
|
|
27397
|
-
const trimmed = spaceTrim$
|
|
27397
|
+
const trimmed = spaceTrim$1(content);
|
|
27398
27398
|
return normalizeDomainForMatching(trimmed) || trimmed.toLowerCase();
|
|
27399
27399
|
}
|
|
27400
27400
|
/**
|
|
@@ -28654,7 +28654,7 @@ function pricing(value) {
|
|
|
28654
28654
|
/**
|
|
28655
28655
|
* List of available OpenAI models with pricing
|
|
28656
28656
|
*
|
|
28657
|
-
* Note: Synced with official API docs at
|
|
28657
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
28658
28658
|
*
|
|
28659
28659
|
* @see https://platform.openai.com/docs/models/
|
|
28660
28660
|
* @see https://openai.com/api/pricing/
|
|
@@ -28776,8 +28776,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
28776
28776
|
modelName: 'gpt-4.1',
|
|
28777
28777
|
modelDescription: 'Smartest non-reasoning model with 128K context window. Enhanced version of GPT-4 with improved instruction following, better factual accuracy, and reduced hallucinations. Features advanced function calling capabilities and superior performance on coding tasks. Ideal for applications requiring high intelligence without reasoning overhead.',
|
|
28778
28778
|
pricing: {
|
|
28779
|
-
prompt: pricing(`$
|
|
28780
|
-
output: pricing(`$
|
|
28779
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
28780
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
28781
28781
|
},
|
|
28782
28782
|
},
|
|
28783
28783
|
/**/
|
|
@@ -28788,8 +28788,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
28788
28788
|
modelName: 'gpt-4.1-mini',
|
|
28789
28789
|
modelDescription: 'Smaller, faster version of GPT-4.1 with 128K context window. Balances intelligence and efficiency with 3x faster inference than base GPT-4.1. Maintains strong capabilities across text generation, reasoning, and coding while offering better cost-performance ratio for most applications.',
|
|
28790
28790
|
pricing: {
|
|
28791
|
-
prompt: pricing(`$0.
|
|
28792
|
-
output: pricing(`$
|
|
28791
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
28792
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
28793
28793
|
},
|
|
28794
28794
|
},
|
|
28795
28795
|
/**/
|
|
@@ -28800,8 +28800,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
28800
28800
|
modelName: 'gpt-4.1-nano',
|
|
28801
28801
|
modelDescription: 'Fastest, most cost-efficient version of GPT-4.1 with 128K context window. Optimized for high-throughput applications requiring good quality at minimal cost. Features 5x faster inference than GPT-4.1 while maintaining adequate performance for most general-purpose tasks.',
|
|
28802
28802
|
pricing: {
|
|
28803
|
-
prompt: pricing(`$0.
|
|
28804
|
-
output: pricing(`$0.
|
|
28803
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
28804
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
28805
28805
|
},
|
|
28806
28806
|
},
|
|
28807
28807
|
/**/
|
|
@@ -28812,8 +28812,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
28812
28812
|
modelName: 'o3',
|
|
28813
28813
|
modelDescription: 'Advanced reasoning model with 128K context window specializing in complex logical, mathematical, and analytical tasks. Successor to o1 with enhanced step-by-step problem-solving capabilities and superior performance on STEM-focused problems. Ideal for professional applications requiring deep analytical thinking and precise reasoning.',
|
|
28814
28814
|
pricing: {
|
|
28815
|
-
prompt: pricing(`$
|
|
28816
|
-
output: pricing(`$
|
|
28815
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
28816
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
28817
28817
|
},
|
|
28818
28818
|
},
|
|
28819
28819
|
/**/
|
|
@@ -28824,8 +28824,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
28824
28824
|
modelName: 'o3-pro',
|
|
28825
28825
|
modelDescription: 'Enhanced version of o3 with more compute allocated for better responses on the most challenging problems. Features extended reasoning time and improved accuracy on complex analytical tasks. Designed for applications where maximum reasoning quality is more important than response speed.',
|
|
28826
28826
|
pricing: {
|
|
28827
|
-
prompt: pricing(`$
|
|
28828
|
-
output: pricing(`$
|
|
28827
|
+
prompt: pricing(`$20.00 / 1M tokens`),
|
|
28828
|
+
output: pricing(`$80.00 / 1M tokens`),
|
|
28829
28829
|
},
|
|
28830
28830
|
},
|
|
28831
28831
|
/**/
|
|
@@ -28836,8 +28836,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
28836
28836
|
modelName: 'o4-mini',
|
|
28837
28837
|
modelDescription: 'Fast, cost-efficient reasoning model with 128K context window. Successor to o1-mini with improved analytical capabilities while maintaining speed advantages. Features enhanced mathematical reasoning and logical problem-solving at significantly lower cost than full reasoning models.',
|
|
28838
28838
|
pricing: {
|
|
28839
|
-
prompt: pricing(`$
|
|
28840
|
-
output: pricing(`$
|
|
28839
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
28840
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
28841
28841
|
},
|
|
28842
28842
|
},
|
|
28843
28843
|
/**/
|
|
@@ -29195,8 +29195,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
29195
29195
|
modelName: 'gpt-4o-2024-05-13',
|
|
29196
29196
|
modelDescription: 'May 2024 version of GPT-4o with 128K context window. Features enhanced multimodal capabilities including superior image understanding (up to 20MP), audio processing, and improved reasoning. Optimized for 2x lower latency than GPT-4 Turbo while maintaining high performance. Includes knowledge up to October 2023. Ideal for production applications requiring reliable multimodal capabilities.',
|
|
29197
29197
|
pricing: {
|
|
29198
|
-
prompt: pricing(`$
|
|
29199
|
-
output: pricing(`$
|
|
29198
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
29199
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
29200
29200
|
},
|
|
29201
29201
|
},
|
|
29202
29202
|
/**/
|
|
@@ -29207,8 +29207,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
29207
29207
|
modelName: 'gpt-4o',
|
|
29208
29208
|
modelDescription: "OpenAI's most advanced general-purpose multimodal model with 128K context window. Optimized for balanced performance, speed, and cost with 2x faster responses than GPT-4 Turbo. Features excellent vision processing, audio understanding, reasoning, and text generation quality. Represents optimal balance of capability and efficiency for most advanced applications.",
|
|
29209
29209
|
pricing: {
|
|
29210
|
-
prompt: pricing(`$
|
|
29211
|
-
output: pricing(`$
|
|
29210
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
29211
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
29212
29212
|
},
|
|
29213
29213
|
},
|
|
29214
29214
|
/**/
|
|
@@ -29279,8 +29279,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
29279
29279
|
modelName: 'o3-mini',
|
|
29280
29280
|
modelDescription: 'Cost-effective reasoning model with 128K context window optimized for academic and scientific problem-solving. Features efficient performance on STEM tasks with specialized capabilities in mathematics, physics, chemistry, and computer science. Offers 80% of O1 performance on technical domains at significantly lower cost. Ideal for educational applications and research support.',
|
|
29281
29281
|
pricing: {
|
|
29282
|
-
prompt: pricing(`$
|
|
29283
|
-
output: pricing(`$
|
|
29282
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
29283
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
29284
29284
|
},
|
|
29285
29285
|
},
|
|
29286
29286
|
/**/
|
|
@@ -29380,53 +29380,6 @@ resultContent, rawResponse, duration = ZERO_VALUE) {
|
|
|
29380
29380
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
29381
29381
|
*/
|
|
29382
29382
|
|
|
29383
|
-
/**
|
|
29384
|
-
* Maps Promptbook tools to OpenAI tools.
|
|
29385
|
-
*
|
|
29386
|
-
* @private
|
|
29387
|
-
*/
|
|
29388
|
-
function mapToolsToOpenAi(tools) {
|
|
29389
|
-
return tools.map((tool) => ({
|
|
29390
|
-
type: 'function',
|
|
29391
|
-
function: {
|
|
29392
|
-
name: tool.name,
|
|
29393
|
-
description: tool.description,
|
|
29394
|
-
parameters: tool.parameters,
|
|
29395
|
-
},
|
|
29396
|
-
}));
|
|
29397
|
-
}
|
|
29398
|
-
|
|
29399
|
-
/**
|
|
29400
|
-
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
29401
|
-
*
|
|
29402
|
-
* @private utility of OpenAI tool execution wrappers
|
|
29403
|
-
*/
|
|
29404
|
-
function buildToolInvocationScript(options) {
|
|
29405
|
-
const { functionName, functionArgsExpression } = options;
|
|
29406
|
-
return `
|
|
29407
|
-
const args = ${functionArgsExpression};
|
|
29408
|
-
const runtimeContextRaw =
|
|
29409
|
-
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
29410
|
-
? undefined
|
|
29411
|
-
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
29412
|
-
|
|
29413
|
-
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29414
|
-
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
29415
|
-
}
|
|
29416
|
-
|
|
29417
|
-
const toolProgressTokenRaw =
|
|
29418
|
-
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
29419
|
-
? undefined
|
|
29420
|
-
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
29421
|
-
|
|
29422
|
-
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29423
|
-
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
29424
|
-
}
|
|
29425
|
-
|
|
29426
|
-
return await ${functionName}(args);
|
|
29427
|
-
`;
|
|
29428
|
-
}
|
|
29429
|
-
|
|
29430
29383
|
/**
|
|
29431
29384
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
29432
29385
|
*
|
|
@@ -29483,6 +29436,53 @@ function isUnsupportedParameterError(error) {
|
|
|
29483
29436
|
errorMessage.includes('does not support'));
|
|
29484
29437
|
}
|
|
29485
29438
|
|
|
29439
|
+
/**
|
|
29440
|
+
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
29441
|
+
*
|
|
29442
|
+
* @private utility of OpenAI tool execution wrappers
|
|
29443
|
+
*/
|
|
29444
|
+
function buildToolInvocationScript(options) {
|
|
29445
|
+
const { functionName, functionArgsExpression } = options;
|
|
29446
|
+
return `
|
|
29447
|
+
const args = ${functionArgsExpression};
|
|
29448
|
+
const runtimeContextRaw =
|
|
29449
|
+
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
29450
|
+
? undefined
|
|
29451
|
+
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
29452
|
+
|
|
29453
|
+
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29454
|
+
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
29455
|
+
}
|
|
29456
|
+
|
|
29457
|
+
const toolProgressTokenRaw =
|
|
29458
|
+
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
29459
|
+
? undefined
|
|
29460
|
+
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
29461
|
+
|
|
29462
|
+
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29463
|
+
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
29464
|
+
}
|
|
29465
|
+
|
|
29466
|
+
return await ${functionName}(args);
|
|
29467
|
+
`;
|
|
29468
|
+
}
|
|
29469
|
+
|
|
29470
|
+
/**
|
|
29471
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
29472
|
+
*
|
|
29473
|
+
* @private
|
|
29474
|
+
*/
|
|
29475
|
+
function mapToolsToOpenAi(tools) {
|
|
29476
|
+
return tools.map((tool) => ({
|
|
29477
|
+
type: 'function',
|
|
29478
|
+
function: {
|
|
29479
|
+
name: tool.name,
|
|
29480
|
+
description: tool.description,
|
|
29481
|
+
parameters: tool.parameters,
|
|
29482
|
+
},
|
|
29483
|
+
}));
|
|
29484
|
+
}
|
|
29485
|
+
|
|
29486
29486
|
/**
|
|
29487
29487
|
* Provides access to the structured clone implementation when available.
|
|
29488
29488
|
*/
|
|
@@ -30449,7 +30449,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
30449
30449
|
// Note: Match exact or prefix for model families
|
|
30450
30450
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
30451
30451
|
if (model === undefined) {
|
|
30452
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
30452
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
30453
30453
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
30454
30454
|
|
|
30455
30455
|
Available models:
|
|
@@ -31375,7 +31375,7 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
|
|
|
31375
31375
|
}
|
|
31376
31376
|
}
|
|
31377
31377
|
|
|
31378
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5-
|
|
31378
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
|
|
31379
31379
|
/**
|
|
31380
31380
|
* Creates one structured log entry for streamed tool-call updates.
|
|
31381
31381
|
*
|
|
@@ -31870,7 +31870,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
31870
31870
|
}),
|
|
31871
31871
|
],
|
|
31872
31872
|
};
|
|
31873
|
-
const errorMessage = spaceTrim$
|
|
31873
|
+
const errorMessage = spaceTrim$1((block) => `
|
|
31874
31874
|
|
|
31875
31875
|
The invoked tool \`${functionName}\` failed with error:
|
|
31876
31876
|
|
|
@@ -32588,7 +32588,7 @@ class OpenAiAssistantExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
32588
32588
|
assertsError(error);
|
|
32589
32589
|
const serializedError = serializeError(error);
|
|
32590
32590
|
errors = [serializedError];
|
|
32591
|
-
functionResponse = spaceTrim$
|
|
32591
|
+
functionResponse = spaceTrim$1((block) => `
|
|
32592
32592
|
|
|
32593
32593
|
The invoked tool \`${functionName}\` failed with error:
|
|
32594
32594
|
|
|
@@ -33596,7 +33596,7 @@ class SelfLearningManager {
|
|
|
33596
33596
|
if (isJsonSchemaResponseFormat(responseFormat)) {
|
|
33597
33597
|
const jsonSchema = responseFormat.json_schema;
|
|
33598
33598
|
const schemaJson = JSON.stringify(jsonSchema, null, 4);
|
|
33599
|
-
userMessageContent = spaceTrim$
|
|
33599
|
+
userMessageContent = spaceTrim$1((block) => `
|
|
33600
33600
|
${block(prompt.content)}
|
|
33601
33601
|
|
|
33602
33602
|
NOTE Request was made through OpenAI Compatible API with \`response_format\` of type \`json_schema\` with the following schema:
|
|
@@ -33627,12 +33627,12 @@ class SelfLearningManager {
|
|
|
33627
33627
|
const formattedAgentMessage = formatAgentMessageForJsonMode(result.content, usesJsonSchemaMode);
|
|
33628
33628
|
const teacherInstructions = extractOpenTeacherInstructions(agentSource);
|
|
33629
33629
|
const teacherInstructionsSection = teacherInstructions
|
|
33630
|
-
? spaceTrim$
|
|
33630
|
+
? spaceTrim$1((block) => `
|
|
33631
33631
|
**Teacher instructions:**
|
|
33632
33632
|
${block(teacherInstructions)}
|
|
33633
33633
|
`)
|
|
33634
33634
|
: '';
|
|
33635
|
-
const teacherPromptContent = spaceTrim$
|
|
33635
|
+
const teacherPromptContent = spaceTrim$1((block) => `
|
|
33636
33636
|
|
|
33637
33637
|
You are a teacher agent helping another agent to learn from its interactions.
|
|
33638
33638
|
|
|
@@ -33665,7 +33665,7 @@ class SelfLearningManager {
|
|
|
33665
33665
|
? '- This interaction used JSON mode, so the agent answer should stay as a formatted JSON code block.'
|
|
33666
33666
|
: ''}
|
|
33667
33667
|
${block(isInitialMessageMissing
|
|
33668
|
-
? spaceTrim$
|
|
33668
|
+
? spaceTrim$1(`
|
|
33669
33669
|
- The agent source does not have an INITIAL MESSAGE defined, generate one.
|
|
33670
33670
|
- The INITIAL MESSAGE should be welcoming, informative about the agent capabilities and also should give some quick options to start the conversation with the agent.
|
|
33671
33671
|
- The quick option looks like \`[👋 Hello](?message=Hello, how are you?)\`
|
|
@@ -33708,7 +33708,7 @@ class SelfLearningManager {
|
|
|
33708
33708
|
*/
|
|
33709
33709
|
appendToAgentSource(section) {
|
|
33710
33710
|
const currentSource = this.options.getAgentSource();
|
|
33711
|
-
const newSource = padBook(validateBook(spaceTrim$
|
|
33711
|
+
const newSource = padBook(validateBook(spaceTrim$1(currentSource) + section));
|
|
33712
33712
|
this.options.updateAgentSource(newSource);
|
|
33713
33713
|
}
|
|
33714
33714
|
}
|
|
@@ -33736,13 +33736,13 @@ function formatAgentMessageForJsonMode(content, isJsonMode) {
|
|
|
33736
33736
|
}
|
|
33737
33737
|
const parsedJson = tryParseJson(content);
|
|
33738
33738
|
if (parsedJson === null) {
|
|
33739
|
-
return spaceTrim$
|
|
33739
|
+
return spaceTrim$1((block) => `
|
|
33740
33740
|
\`\`\`json
|
|
33741
33741
|
${block(content)}
|
|
33742
33742
|
\`\`\`
|
|
33743
33743
|
`);
|
|
33744
33744
|
}
|
|
33745
|
-
return spaceTrim$
|
|
33745
|
+
return spaceTrim$1((block) => `
|
|
33746
33746
|
\`\`\`json
|
|
33747
33747
|
${block(JSON.stringify(parsedJson, null, 4))}
|
|
33748
33748
|
\`\`\`
|
|
@@ -33774,7 +33774,7 @@ function formatSelfLearningSample(options) {
|
|
|
33774
33774
|
const internalMessagesSection = options.internalMessages
|
|
33775
33775
|
.map((internalMessage) => formatInternalLearningMessage(internalMessage))
|
|
33776
33776
|
.join('\n\n');
|
|
33777
|
-
return spaceTrim$
|
|
33777
|
+
return spaceTrim$1((block) => `
|
|
33778
33778
|
|
|
33779
33779
|
USER MESSAGE
|
|
33780
33780
|
${block(options.userMessageContent)}
|
|
@@ -33792,7 +33792,7 @@ function formatSelfLearningSample(options) {
|
|
|
33792
33792
|
* @private function of Agent
|
|
33793
33793
|
*/
|
|
33794
33794
|
function formatInternalLearningMessage(internalMessage) {
|
|
33795
|
-
return spaceTrim$
|
|
33795
|
+
return spaceTrim$1((block) => `
|
|
33796
33796
|
INTERNAL MESSAGE
|
|
33797
33797
|
${block(stringifyInternalLearningPayload(internalMessage))}
|
|
33798
33798
|
`);
|
|
@@ -34258,7 +34258,7 @@ function buildRemoteAgentSource(profile, meta) {
|
|
|
34258
34258
|
.filter((line) => Boolean(line))
|
|
34259
34259
|
.join('\n');
|
|
34260
34260
|
const personaBlock = profile.personaDescription
|
|
34261
|
-
? spaceTrim$
|
|
34261
|
+
? spaceTrim$1((block) => `
|
|
34262
34262
|
PERSONA
|
|
34263
34263
|
${block(profile.personaDescription || '')}
|
|
34264
34264
|
`)
|
|
@@ -34294,7 +34294,7 @@ class RemoteAgent extends Agent {
|
|
|
34294
34294
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
34295
34295
|
// <- TODO: [🐱🚀] Maybe use promptbookFetch
|
|
34296
34296
|
if (!profileResponse.ok) {
|
|
34297
|
-
throw new Error(spaceTrim$
|
|
34297
|
+
throw new Error(spaceTrim$1((block) => `
|
|
34298
34298
|
Failed to fetch remote agent profile:
|
|
34299
34299
|
|
|
34300
34300
|
Agent URL:
|