@promptbook/pdf 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 +35 -35
- 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 +93 -94
- 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 { SHA256 } from 'crypto-js';
|
|
4
4
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
5
5
|
import { basename, join, dirname, isAbsolute } from 'path';
|
|
@@ -24,7 +24,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1216,7 +1216,7 @@ class KnowledgeScrapeError extends Error {
|
|
|
1216
1216
|
function getErrorReportUrl(error) {
|
|
1217
1217
|
const report = {
|
|
1218
1218
|
title: `🐜 Error report from ${NAME}`,
|
|
1219
|
-
body: spaceTrim$
|
|
1219
|
+
body: spaceTrim$1((block) => `
|
|
1220
1220
|
|
|
1221
1221
|
|
|
1222
1222
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -2115,7 +2115,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2115
2115
|
pipelineString += '\n\n';
|
|
2116
2116
|
pipelineString += '```' + contentLanguage;
|
|
2117
2117
|
pipelineString += '\n';
|
|
2118
|
-
pipelineString += spaceTrim$
|
|
2118
|
+
pipelineString += spaceTrim$1(content);
|
|
2119
2119
|
// <- TODO: [main] !!3 Escape
|
|
2120
2120
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2121
2121
|
pipelineString += '\n';
|
|
@@ -2236,7 +2236,7 @@ function checkSerializableAsJson(options) {
|
|
|
2236
2236
|
}
|
|
2237
2237
|
else if (typeof value === 'object') {
|
|
2238
2238
|
if (value instanceof Date) {
|
|
2239
|
-
throw new UnexpectedError(spaceTrim$
|
|
2239
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2240
2240
|
\`${name}\` is Date
|
|
2241
2241
|
|
|
2242
2242
|
Use \`string_date_iso8601\` instead
|
|
@@ -2255,7 +2255,7 @@ function checkSerializableAsJson(options) {
|
|
|
2255
2255
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2256
2256
|
}
|
|
2257
2257
|
else if (value instanceof Error) {
|
|
2258
|
-
throw new UnexpectedError(spaceTrim$
|
|
2258
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2259
2259
|
\`${name}\` is unserialized Error
|
|
2260
2260
|
|
|
2261
2261
|
Use function \`serializeError\`
|
|
@@ -2278,7 +2278,7 @@ function checkSerializableAsJson(options) {
|
|
|
2278
2278
|
}
|
|
2279
2279
|
catch (error) {
|
|
2280
2280
|
assertsError(error);
|
|
2281
|
-
throw new UnexpectedError(spaceTrim$
|
|
2281
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2282
2282
|
\`${name}\` is not serializable
|
|
2283
2283
|
|
|
2284
2284
|
${block(error.stack || error.message)}
|
|
@@ -2310,7 +2310,7 @@ function checkSerializableAsJson(options) {
|
|
|
2310
2310
|
}
|
|
2311
2311
|
}
|
|
2312
2312
|
else {
|
|
2313
|
-
throw new UnexpectedError(spaceTrim$
|
|
2313
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2314
2314
|
\`${name}\` is unknown type
|
|
2315
2315
|
|
|
2316
2316
|
Additional message for \`${name}\`:
|
|
@@ -3356,7 +3356,7 @@ function serializeError(error) {
|
|
|
3356
3356
|
const { name, message, stack } = error;
|
|
3357
3357
|
const { id } = error;
|
|
3358
3358
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3359
|
-
console.error(spaceTrim$
|
|
3359
|
+
console.error(spaceTrim$1((block) => `
|
|
3360
3360
|
|
|
3361
3361
|
Cannot serialize error with name "${name}"
|
|
3362
3362
|
|
|
@@ -3389,7 +3389,7 @@ function jsonParse(value) {
|
|
|
3389
3389
|
}
|
|
3390
3390
|
else if (typeof value !== 'string') {
|
|
3391
3391
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3392
|
-
throw new Error(spaceTrim$
|
|
3392
|
+
throw new Error(spaceTrim$1(`
|
|
3393
3393
|
Can not parse JSON from non-string value.
|
|
3394
3394
|
|
|
3395
3395
|
The value type: ${typeof value}
|
|
@@ -3403,7 +3403,7 @@ function jsonParse(value) {
|
|
|
3403
3403
|
if (!(error instanceof Error)) {
|
|
3404
3404
|
throw error;
|
|
3405
3405
|
}
|
|
3406
|
-
throw new Error(spaceTrim$
|
|
3406
|
+
throw new Error(spaceTrim$1((block) => `
|
|
3407
3407
|
${block(error.message)}
|
|
3408
3408
|
|
|
3409
3409
|
The expected JSON text:
|
|
@@ -3456,7 +3456,7 @@ function deserializeError(error, isStackAddedToMessage = true) {
|
|
|
3456
3456
|
message = `${name}: ${message}`;
|
|
3457
3457
|
}
|
|
3458
3458
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
3459
|
-
message = spaceTrim$
|
|
3459
|
+
message = spaceTrim$1((block) => `
|
|
3460
3460
|
${block(message)}
|
|
3461
3461
|
|
|
3462
3462
|
Original stack trace:
|
|
@@ -4006,14 +4006,14 @@ class MultipleLlmExecutionTools {
|
|
|
4006
4006
|
if (description === undefined) {
|
|
4007
4007
|
return headLine;
|
|
4008
4008
|
}
|
|
4009
|
-
return spaceTrim$
|
|
4009
|
+
return spaceTrim$1((block) => `
|
|
4010
4010
|
${headLine}
|
|
4011
4011
|
|
|
4012
4012
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4013
4013
|
`);
|
|
4014
4014
|
})
|
|
4015
4015
|
.join('\n\n');
|
|
4016
|
-
return spaceTrim$
|
|
4016
|
+
return spaceTrim$1((block) => `
|
|
4017
4017
|
Multiple LLM Providers:
|
|
4018
4018
|
|
|
4019
4019
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4115,7 +4115,7 @@ class MultipleLlmExecutionTools {
|
|
|
4115
4115
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4116
4116
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4117
4117
|
// 3) ...
|
|
4118
|
-
spaceTrim$
|
|
4118
|
+
spaceTrim$1((block) => `
|
|
4119
4119
|
All execution tools of ${this.title} failed:
|
|
4120
4120
|
|
|
4121
4121
|
${block(errors
|
|
@@ -4128,7 +4128,7 @@ class MultipleLlmExecutionTools {
|
|
|
4128
4128
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4129
4129
|
}
|
|
4130
4130
|
else {
|
|
4131
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4131
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
4132
4132
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4133
4133
|
|
|
4134
4134
|
Available \`LlmExecutionTools\`:
|
|
@@ -4165,7 +4165,7 @@ class MultipleLlmExecutionTools {
|
|
|
4165
4165
|
*/
|
|
4166
4166
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4167
4167
|
if (llmExecutionTools.length === 0) {
|
|
4168
|
-
const warningMessage = spaceTrim$
|
|
4168
|
+
const warningMessage = spaceTrim$1(`
|
|
4169
4169
|
You have not provided any \`LlmExecutionTools\`
|
|
4170
4170
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4171
4171
|
|
|
@@ -4482,14 +4482,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4482
4482
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4483
4483
|
});
|
|
4484
4484
|
if (metadata.length === 0) {
|
|
4485
|
-
return spaceTrim$
|
|
4485
|
+
return spaceTrim$1(`
|
|
4486
4486
|
**No scrapers are available**
|
|
4487
4487
|
|
|
4488
4488
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4489
4489
|
At least there should be available the metadata of the scrapers
|
|
4490
4490
|
`);
|
|
4491
4491
|
}
|
|
4492
|
-
return spaceTrim$
|
|
4492
|
+
return spaceTrim$1((block) => `
|
|
4493
4493
|
Available scrapers are:
|
|
4494
4494
|
${block(metadata
|
|
4495
4495
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4600,7 +4600,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4600
4600
|
else if (urlOrRequest instanceof Request) {
|
|
4601
4601
|
url = urlOrRequest.url;
|
|
4602
4602
|
}
|
|
4603
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
4603
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
4604
4604
|
Can not fetch "${url}"
|
|
4605
4605
|
|
|
4606
4606
|
Fetch error:
|
|
@@ -4760,7 +4760,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4760
4760
|
const fileExtension = getFileExtension(filename);
|
|
4761
4761
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4762
4762
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4763
|
-
throw new NotFoundError(spaceTrim$
|
|
4763
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
4764
4764
|
Can not make source handler for file which does not exist:
|
|
4765
4765
|
|
|
4766
4766
|
File:
|
|
@@ -4853,7 +4853,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4853
4853
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4854
4854
|
break;
|
|
4855
4855
|
}
|
|
4856
|
-
console.warn(spaceTrim$
|
|
4856
|
+
console.warn(spaceTrim$1((block) => `
|
|
4857
4857
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4858
4858
|
|
|
4859
4859
|
The source:
|
|
@@ -4869,7 +4869,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4869
4869
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4870
4870
|
}
|
|
4871
4871
|
if (partialPieces === null) {
|
|
4872
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
4872
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
4873
4873
|
Cannot scrape knowledge
|
|
4874
4874
|
|
|
4875
4875
|
The source:
|
|
@@ -5444,7 +5444,7 @@ const CsvFormatParser = {
|
|
|
5444
5444
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5445
5445
|
const csv = csvParse(value, settings);
|
|
5446
5446
|
if (csv.errors.length !== 0) {
|
|
5447
|
-
throw new CsvFormatError(spaceTrim$
|
|
5447
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5448
5448
|
CSV parsing error
|
|
5449
5449
|
|
|
5450
5450
|
Error(s) from CSV parsing:
|
|
@@ -5489,7 +5489,7 @@ const CsvFormatParser = {
|
|
|
5489
5489
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5490
5490
|
const csv = csvParse(value, settings);
|
|
5491
5491
|
if (csv.errors.length !== 0) {
|
|
5492
|
-
throw new CsvFormatError(spaceTrim$
|
|
5492
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5493
5493
|
CSV parsing error
|
|
5494
5494
|
|
|
5495
5495
|
Error(s) from CSV parsing:
|
|
@@ -5699,7 +5699,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5699
5699
|
}
|
|
5700
5700
|
// Phase 2️⃣: Non-matching mapping
|
|
5701
5701
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5702
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
5702
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5703
5703
|
Can not map available parameters to expected parameters
|
|
5704
5704
|
|
|
5705
5705
|
Mapped parameters:
|
|
@@ -6485,7 +6485,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6485
6485
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6486
6486
|
}
|
|
6487
6487
|
if (jokerParameterNames.length !== 0) {
|
|
6488
|
-
throw new UnexpectedError(spaceTrim$
|
|
6488
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6489
6489
|
JOKER parameters are not supported together with FOREACH command
|
|
6490
6490
|
|
|
6491
6491
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6498,7 +6498,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6498
6498
|
if (formatDefinition === undefined) {
|
|
6499
6499
|
throw new UnexpectedError(
|
|
6500
6500
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6501
|
-
spaceTrim$
|
|
6501
|
+
spaceTrim$1((block) => `
|
|
6502
6502
|
Unsupported format "${task.foreach.formatName}"
|
|
6503
6503
|
|
|
6504
6504
|
Available formats:
|
|
@@ -6515,7 +6515,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6515
6515
|
if (subvalueParser === undefined) {
|
|
6516
6516
|
throw new UnexpectedError(
|
|
6517
6517
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6518
|
-
spaceTrim$
|
|
6518
|
+
spaceTrim$1((block) => `
|
|
6519
6519
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6520
6520
|
|
|
6521
6521
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6555,7 +6555,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6555
6555
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6556
6556
|
throw error;
|
|
6557
6557
|
}
|
|
6558
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
6558
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6559
6559
|
${error.message}
|
|
6560
6560
|
|
|
6561
6561
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6579,7 +6579,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6579
6579
|
...options,
|
|
6580
6580
|
priority: priority + index,
|
|
6581
6581
|
parameters: allSubparameters,
|
|
6582
|
-
pipelineIdentification: spaceTrim$
|
|
6582
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
6583
6583
|
${block(pipelineIdentification)}
|
|
6584
6584
|
Subparameter index: ${index}
|
|
6585
6585
|
`),
|
|
@@ -6588,7 +6588,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6588
6588
|
}
|
|
6589
6589
|
catch (error) {
|
|
6590
6590
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6591
|
-
console.error(spaceTrim$
|
|
6591
|
+
console.error(spaceTrim$1((block) => `
|
|
6592
6592
|
${error.message}
|
|
6593
6593
|
|
|
6594
6594
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -7460,8 +7460,8 @@ class MarkdownScraper {
|
|
|
7460
7460
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7461
7461
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7462
7462
|
let name = `piece-${i}`;
|
|
7463
|
-
let title = spaceTrim$
|
|
7464
|
-
const knowledgePieceContent = spaceTrim$
|
|
7463
|
+
let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
7464
|
+
const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
|
|
7465
7465
|
let keywords = [];
|
|
7466
7466
|
const index = [];
|
|
7467
7467
|
/*
|
|
@@ -7474,7 +7474,7 @@ class MarkdownScraper {
|
|
|
7474
7474
|
isCrashedOnError: true,
|
|
7475
7475
|
});
|
|
7476
7476
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7477
|
-
title = spaceTrim$
|
|
7477
|
+
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7478
7478
|
name = titleToName(title);
|
|
7479
7479
|
// --- Keywords
|
|
7480
7480
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|