@promptbook/documents 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 +36 -36
- 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 +97 -98
- 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,5 +1,5 @@
|
|
|
1
1
|
import { mkdir, rm, readFile } from 'fs/promises';
|
|
2
|
-
import
|
|
2
|
+
import { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import colors from 'colors';
|
|
5
5
|
import { forTime } from 'waitasecond';
|
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1223,7 +1223,7 @@ class MissingToolsError extends Error {
|
|
|
1223
1223
|
function getErrorReportUrl(error) {
|
|
1224
1224
|
const report = {
|
|
1225
1225
|
title: `🐜 Error report from ${NAME}`,
|
|
1226
|
-
body: spaceTrim$
|
|
1226
|
+
body: spaceTrim$1((block) => `
|
|
1227
1227
|
|
|
1228
1228
|
|
|
1229
1229
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -2301,7 +2301,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2301
2301
|
pipelineString += '\n\n';
|
|
2302
2302
|
pipelineString += '```' + contentLanguage;
|
|
2303
2303
|
pipelineString += '\n';
|
|
2304
|
-
pipelineString += spaceTrim$
|
|
2304
|
+
pipelineString += spaceTrim$1(content);
|
|
2305
2305
|
// <- TODO: [main] !!3 Escape
|
|
2306
2306
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2307
2307
|
pipelineString += '\n';
|
|
@@ -2422,7 +2422,7 @@ function checkSerializableAsJson(options) {
|
|
|
2422
2422
|
}
|
|
2423
2423
|
else if (typeof value === 'object') {
|
|
2424
2424
|
if (value instanceof Date) {
|
|
2425
|
-
throw new UnexpectedError(spaceTrim$
|
|
2425
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2426
2426
|
\`${name}\` is Date
|
|
2427
2427
|
|
|
2428
2428
|
Use \`string_date_iso8601\` instead
|
|
@@ -2441,7 +2441,7 @@ function checkSerializableAsJson(options) {
|
|
|
2441
2441
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2442
2442
|
}
|
|
2443
2443
|
else if (value instanceof Error) {
|
|
2444
|
-
throw new UnexpectedError(spaceTrim$
|
|
2444
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2445
2445
|
\`${name}\` is unserialized Error
|
|
2446
2446
|
|
|
2447
2447
|
Use function \`serializeError\`
|
|
@@ -2464,7 +2464,7 @@ function checkSerializableAsJson(options) {
|
|
|
2464
2464
|
}
|
|
2465
2465
|
catch (error) {
|
|
2466
2466
|
assertsError(error);
|
|
2467
|
-
throw new UnexpectedError(spaceTrim$
|
|
2467
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2468
2468
|
\`${name}\` is not serializable
|
|
2469
2469
|
|
|
2470
2470
|
${block(error.stack || error.message)}
|
|
@@ -2496,7 +2496,7 @@ function checkSerializableAsJson(options) {
|
|
|
2496
2496
|
}
|
|
2497
2497
|
}
|
|
2498
2498
|
else {
|
|
2499
|
-
throw new UnexpectedError(spaceTrim$
|
|
2499
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2500
2500
|
\`${name}\` is unknown type
|
|
2501
2501
|
|
|
2502
2502
|
Additional message for \`${name}\`:
|
|
@@ -3524,7 +3524,7 @@ function serializeError(error) {
|
|
|
3524
3524
|
const { name, message, stack } = error;
|
|
3525
3525
|
const { id } = error;
|
|
3526
3526
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3527
|
-
console.error(spaceTrim$
|
|
3527
|
+
console.error(spaceTrim$1((block) => `
|
|
3528
3528
|
|
|
3529
3529
|
Cannot serialize error with name "${name}"
|
|
3530
3530
|
|
|
@@ -3557,7 +3557,7 @@ function jsonParse(value) {
|
|
|
3557
3557
|
}
|
|
3558
3558
|
else if (typeof value !== 'string') {
|
|
3559
3559
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3560
|
-
throw new Error(spaceTrim$
|
|
3560
|
+
throw new Error(spaceTrim$1(`
|
|
3561
3561
|
Can not parse JSON from non-string value.
|
|
3562
3562
|
|
|
3563
3563
|
The value type: ${typeof value}
|
|
@@ -3571,7 +3571,7 @@ function jsonParse(value) {
|
|
|
3571
3571
|
if (!(error instanceof Error)) {
|
|
3572
3572
|
throw error;
|
|
3573
3573
|
}
|
|
3574
|
-
throw new Error(spaceTrim$
|
|
3574
|
+
throw new Error(spaceTrim$1((block) => `
|
|
3575
3575
|
${block(error.message)}
|
|
3576
3576
|
|
|
3577
3577
|
The expected JSON text:
|
|
@@ -3624,7 +3624,7 @@ function deserializeError(error, isStackAddedToMessage = true) {
|
|
|
3624
3624
|
message = `${name}: ${message}`;
|
|
3625
3625
|
}
|
|
3626
3626
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
3627
|
-
message = spaceTrim$
|
|
3627
|
+
message = spaceTrim$1((block) => `
|
|
3628
3628
|
${block(message)}
|
|
3629
3629
|
|
|
3630
3630
|
Original stack trace:
|
|
@@ -4174,14 +4174,14 @@ class MultipleLlmExecutionTools {
|
|
|
4174
4174
|
if (description === undefined) {
|
|
4175
4175
|
return headLine;
|
|
4176
4176
|
}
|
|
4177
|
-
return spaceTrim$
|
|
4177
|
+
return spaceTrim$1((block) => `
|
|
4178
4178
|
${headLine}
|
|
4179
4179
|
|
|
4180
4180
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4181
4181
|
`);
|
|
4182
4182
|
})
|
|
4183
4183
|
.join('\n\n');
|
|
4184
|
-
return spaceTrim$
|
|
4184
|
+
return spaceTrim$1((block) => `
|
|
4185
4185
|
Multiple LLM Providers:
|
|
4186
4186
|
|
|
4187
4187
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4283,7 +4283,7 @@ class MultipleLlmExecutionTools {
|
|
|
4283
4283
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4284
4284
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4285
4285
|
// 3) ...
|
|
4286
|
-
spaceTrim$
|
|
4286
|
+
spaceTrim$1((block) => `
|
|
4287
4287
|
All execution tools of ${this.title} failed:
|
|
4288
4288
|
|
|
4289
4289
|
${block(errors
|
|
@@ -4296,7 +4296,7 @@ class MultipleLlmExecutionTools {
|
|
|
4296
4296
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4297
4297
|
}
|
|
4298
4298
|
else {
|
|
4299
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4299
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
4300
4300
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4301
4301
|
|
|
4302
4302
|
Available \`LlmExecutionTools\`:
|
|
@@ -4333,7 +4333,7 @@ class MultipleLlmExecutionTools {
|
|
|
4333
4333
|
*/
|
|
4334
4334
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4335
4335
|
if (llmExecutionTools.length === 0) {
|
|
4336
|
-
const warningMessage = spaceTrim$
|
|
4336
|
+
const warningMessage = spaceTrim$1(`
|
|
4337
4337
|
You have not provided any \`LlmExecutionTools\`
|
|
4338
4338
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4339
4339
|
|
|
@@ -4650,14 +4650,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4650
4650
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4651
4651
|
});
|
|
4652
4652
|
if (metadata.length === 0) {
|
|
4653
|
-
return spaceTrim$
|
|
4653
|
+
return spaceTrim$1(`
|
|
4654
4654
|
**No scrapers are available**
|
|
4655
4655
|
|
|
4656
4656
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4657
4657
|
At least there should be available the metadata of the scrapers
|
|
4658
4658
|
`);
|
|
4659
4659
|
}
|
|
4660
|
-
return spaceTrim$
|
|
4660
|
+
return spaceTrim$1((block) => `
|
|
4661
4661
|
Available scrapers are:
|
|
4662
4662
|
${block(metadata
|
|
4663
4663
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4758,7 +4758,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4758
4758
|
else if (urlOrRequest instanceof Request) {
|
|
4759
4759
|
url = urlOrRequest.url;
|
|
4760
4760
|
}
|
|
4761
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
4761
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
4762
4762
|
Can not fetch "${url}"
|
|
4763
4763
|
|
|
4764
4764
|
Fetch error:
|
|
@@ -4918,7 +4918,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4918
4918
|
const fileExtension = getFileExtension(filename);
|
|
4919
4919
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4920
4920
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4921
|
-
throw new NotFoundError(spaceTrim$
|
|
4921
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
4922
4922
|
Can not make source handler for file which does not exist:
|
|
4923
4923
|
|
|
4924
4924
|
File:
|
|
@@ -5011,7 +5011,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5011
5011
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5012
5012
|
break;
|
|
5013
5013
|
}
|
|
5014
|
-
console.warn(spaceTrim$
|
|
5014
|
+
console.warn(spaceTrim$1((block) => `
|
|
5015
5015
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
5016
5016
|
|
|
5017
5017
|
The source:
|
|
@@ -5027,7 +5027,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5027
5027
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5028
5028
|
}
|
|
5029
5029
|
if (partialPieces === null) {
|
|
5030
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
5030
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
5031
5031
|
Cannot scrape knowledge
|
|
5032
5032
|
|
|
5033
5033
|
The source:
|
|
@@ -5602,7 +5602,7 @@ const CsvFormatParser = {
|
|
|
5602
5602
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5603
5603
|
const csv = csvParse(value, settings);
|
|
5604
5604
|
if (csv.errors.length !== 0) {
|
|
5605
|
-
throw new CsvFormatError(spaceTrim$
|
|
5605
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5606
5606
|
CSV parsing error
|
|
5607
5607
|
|
|
5608
5608
|
Error(s) from CSV parsing:
|
|
@@ -5647,7 +5647,7 @@ const CsvFormatParser = {
|
|
|
5647
5647
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5648
5648
|
const csv = csvParse(value, settings);
|
|
5649
5649
|
if (csv.errors.length !== 0) {
|
|
5650
|
-
throw new CsvFormatError(spaceTrim$
|
|
5650
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5651
5651
|
CSV parsing error
|
|
5652
5652
|
|
|
5653
5653
|
Error(s) from CSV parsing:
|
|
@@ -5857,7 +5857,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5857
5857
|
}
|
|
5858
5858
|
// Phase 2️⃣: Non-matching mapping
|
|
5859
5859
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5860
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
5860
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5861
5861
|
Can not map available parameters to expected parameters
|
|
5862
5862
|
|
|
5863
5863
|
Mapped parameters:
|
|
@@ -6643,7 +6643,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6643
6643
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6644
6644
|
}
|
|
6645
6645
|
if (jokerParameterNames.length !== 0) {
|
|
6646
|
-
throw new UnexpectedError(spaceTrim$
|
|
6646
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6647
6647
|
JOKER parameters are not supported together with FOREACH command
|
|
6648
6648
|
|
|
6649
6649
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6656,7 +6656,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6656
6656
|
if (formatDefinition === undefined) {
|
|
6657
6657
|
throw new UnexpectedError(
|
|
6658
6658
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6659
|
-
spaceTrim$
|
|
6659
|
+
spaceTrim$1((block) => `
|
|
6660
6660
|
Unsupported format "${task.foreach.formatName}"
|
|
6661
6661
|
|
|
6662
6662
|
Available formats:
|
|
@@ -6673,7 +6673,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6673
6673
|
if (subvalueParser === undefined) {
|
|
6674
6674
|
throw new UnexpectedError(
|
|
6675
6675
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6676
|
-
spaceTrim$
|
|
6676
|
+
spaceTrim$1((block) => `
|
|
6677
6677
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6678
6678
|
|
|
6679
6679
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6713,7 +6713,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6713
6713
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6714
6714
|
throw error;
|
|
6715
6715
|
}
|
|
6716
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
6716
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6717
6717
|
${error.message}
|
|
6718
6718
|
|
|
6719
6719
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6737,7 +6737,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6737
6737
|
...options,
|
|
6738
6738
|
priority: priority + index,
|
|
6739
6739
|
parameters: allSubparameters,
|
|
6740
|
-
pipelineIdentification: spaceTrim$
|
|
6740
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
6741
6741
|
${block(pipelineIdentification)}
|
|
6742
6742
|
Subparameter index: ${index}
|
|
6743
6743
|
`),
|
|
@@ -6746,7 +6746,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6746
6746
|
}
|
|
6747
6747
|
catch (error) {
|
|
6748
6748
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6749
|
-
console.error(spaceTrim$
|
|
6749
|
+
console.error(spaceTrim$1((block) => `
|
|
6750
6750
|
${error.message}
|
|
6751
6751
|
|
|
6752
6752
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -7618,8 +7618,8 @@ class MarkdownScraper {
|
|
|
7618
7618
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7619
7619
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7620
7620
|
let name = `piece-${i}`;
|
|
7621
|
-
let title = spaceTrim$
|
|
7622
|
-
const knowledgePieceContent = spaceTrim$
|
|
7621
|
+
let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
7622
|
+
const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
|
|
7623
7623
|
let keywords = [];
|
|
7624
7624
|
const index = [];
|
|
7625
7625
|
/*
|
|
@@ -7632,7 +7632,7 @@ class MarkdownScraper {
|
|
|
7632
7632
|
isCrashedOnError: true,
|
|
7633
7633
|
});
|
|
7634
7634
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7635
|
-
title = spaceTrim$
|
|
7635
|
+
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7636
7636
|
name = titleToName(title);
|
|
7637
7637
|
// --- Keywords
|
|
7638
7638
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -7778,7 +7778,7 @@ class DocumentScraper {
|
|
|
7778
7778
|
await $execCommand(command);
|
|
7779
7779
|
// Note: [0]
|
|
7780
7780
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
7781
|
-
throw new UnexpectedError(spaceTrim$
|
|
7781
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
7782
7782
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
7783
7783
|
|
|
7784
7784
|
Expected file:
|