@promptbook/editable 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 +39 -39
- 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 +49 -50
- 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
|
@@ -3,7 +3,7 @@ import type { number_usd } from '../../types/typeAliases';
|
|
|
3
3
|
/**
|
|
4
4
|
* List of available Google models with descriptions
|
|
5
5
|
*
|
|
6
|
-
* Note: Synced with official API docs at
|
|
6
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
7
7
|
*
|
|
8
8
|
* @see https://ai.google.dev/models/gemini
|
|
9
9
|
* @public exported from `@promptbook/google`
|
|
@@ -2,7 +2,7 @@ import type { AvailableModel } from '../../execution/AvailableModel';
|
|
|
2
2
|
/**
|
|
3
3
|
* List of available OpenAI models with pricing
|
|
4
4
|
*
|
|
5
|
-
* Note: Synced with official API docs at
|
|
5
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
6
6
|
*
|
|
7
7
|
* @see https://platform.openai.com/docs/models/
|
|
8
8
|
* @see https://openai.com/api/pricing/
|
|
@@ -3,8 +3,7 @@ import type { KnowledgePiecePreparedJson } from '../../pipeline/PipelineJson/Kno
|
|
|
3
3
|
import type { PrepareAndScrapeOptions } from '../../prepare/PrepareAndScrapeOptions';
|
|
4
4
|
import type { Converter } from '../_common/Converter';
|
|
5
5
|
import type { ScraperAndConverterMetadata } from '../_common/register/ScraperAndConverterMetadata';
|
|
6
|
-
import type { Scraper } from '../_common/Scraper';
|
|
7
|
-
import type { ScraperSourceHandler } from '../_common/Scraper';
|
|
6
|
+
import type { Scraper, ScraperSourceHandler } from '../_common/Scraper';
|
|
8
7
|
import type { ScraperIntermediateSource } from '../_common/ScraperIntermediateSource';
|
|
9
8
|
/**
|
|
10
9
|
* Scraper of @@ files
|
|
@@ -3,8 +3,7 @@ import type { ExecutionTools } from '../../execution/ExecutionTools';
|
|
|
3
3
|
import type { PrepareAndScrapeOptions } from '../../prepare/PrepareAndScrapeOptions';
|
|
4
4
|
import type { Converter } from '../_common/Converter';
|
|
5
5
|
import type { ScraperAndConverterMetadata } from '../_common/register/ScraperAndConverterMetadata';
|
|
6
|
-
import type { Scraper } from '../_common/Scraper';
|
|
7
|
-
import type { ScraperSourceHandler } from '../_common/Scraper';
|
|
6
|
+
import type { Scraper, ScraperSourceHandler } from '../_common/Scraper';
|
|
8
7
|
import type { ScraperIntermediateSource } from '../_common/ScraperIntermediateSource';
|
|
9
8
|
/**
|
|
10
9
|
* Scraper of .docx and .odt files
|
|
@@ -3,8 +3,7 @@ import type { ExecutionTools } from '../../execution/ExecutionTools';
|
|
|
3
3
|
import type { PrepareAndScrapeOptions } from '../../prepare/PrepareAndScrapeOptions';
|
|
4
4
|
import type { Converter } from '../_common/Converter';
|
|
5
5
|
import type { ScraperAndConverterMetadata } from '../_common/register/ScraperAndConverterMetadata';
|
|
6
|
-
import type { Scraper } from '../_common/Scraper';
|
|
7
|
-
import type { ScraperSourceHandler } from '../_common/Scraper';
|
|
6
|
+
import type { Scraper, ScraperSourceHandler } from '../_common/Scraper';
|
|
8
7
|
import type { ScraperIntermediateSource } from '../_common/ScraperIntermediateSource';
|
|
9
8
|
/**
|
|
10
9
|
* Scraper for old document files (like .doc and .rtf)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim from 'spacetrim';
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
2
2
|
import { extractBlock } from '../../postprocessing/utils/extractBlock';
|
|
3
3
|
import { prettifyMarkdown } from '../../utils/markdown/prettifyMarkdown';
|
|
4
4
|
import { trimCodeBlock } from '../../utils/markdown/trimCodeBlock';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
|
-
import type { string_parameter_value } from '../../types/typeAliases';
|
|
1
|
+
import type { string_parameter_name, string_parameter_value } from '../../types/typeAliases';
|
|
3
2
|
/**
|
|
4
3
|
* Options for mapping available parameters to expected parameters in a pipeline task.
|
|
5
4
|
*/
|
package/esm/src/version.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-15`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/editable",
|
|
3
|
-
"version": "0.112.0-
|
|
3
|
+
"version": "0.112.0-16",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"module": "./esm/index.es.js",
|
|
99
99
|
"typings": "./esm/typings/src/_packages/editable.index.d.ts",
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@promptbook/core": "0.112.0-
|
|
101
|
+
"@promptbook/core": "0.112.0-16"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"crypto-js": "4.2.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('papaparse'), require('crypto-js'), require('crypto-js/enc-hex')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'papaparse', 'crypto-js', 'crypto-js/enc-hex'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-editable"] = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-editable"] = {}, global.spacetrim, global.papaparse, global.cryptoJs, global.hexEncoder));
|
|
5
|
+
})(this, (function (exports, spacetrim, papaparse, cryptoJs, hexEncoder) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
10
9
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
10
|
|
|
12
11
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
* @generated
|
|
24
23
|
* @see https://github.com/webgptorg/promptbook
|
|
25
24
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
25
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
27
26
|
/**
|
|
28
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -38,7 +37,7 @@
|
|
|
38
37
|
* @public exported from `@promptbook/utils`
|
|
39
38
|
* @see https://github.com/hejny/spacetrim#usage
|
|
40
39
|
*/
|
|
41
|
-
const spaceTrim =
|
|
40
|
+
const spaceTrim = spacetrim.spaceTrim;
|
|
42
41
|
|
|
43
42
|
/**
|
|
44
43
|
* @private util of `@promptbook/color`
|
|
@@ -1047,7 +1046,7 @@
|
|
|
1047
1046
|
function getErrorReportUrl(error) {
|
|
1048
1047
|
const report = {
|
|
1049
1048
|
title: `🐜 Error report from ${NAME}`,
|
|
1050
|
-
body:
|
|
1049
|
+
body: spacetrim.spaceTrim((block) => `
|
|
1051
1050
|
|
|
1052
1051
|
|
|
1053
1052
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1090,7 +1089,7 @@
|
|
|
1090
1089
|
*/
|
|
1091
1090
|
class UnexpectedError extends Error {
|
|
1092
1091
|
constructor(message) {
|
|
1093
|
-
super(
|
|
1092
|
+
super(spacetrim.spaceTrim((block) => `
|
|
1094
1093
|
${block(message)}
|
|
1095
1094
|
|
|
1096
1095
|
Note: This error should not happen.
|
|
@@ -1223,7 +1222,7 @@
|
|
|
1223
1222
|
*/
|
|
1224
1223
|
class NotYetImplementedError extends Error {
|
|
1225
1224
|
constructor(message) {
|
|
1226
|
-
super(
|
|
1225
|
+
super(spacetrim.spaceTrim((block) => `
|
|
1227
1226
|
${block(message)}
|
|
1228
1227
|
|
|
1229
1228
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -1366,7 +1365,7 @@
|
|
|
1366
1365
|
constructor(whatWasThrown) {
|
|
1367
1366
|
const tag = `[🤮]`;
|
|
1368
1367
|
console.error(tag, whatWasThrown);
|
|
1369
|
-
super(
|
|
1368
|
+
super(spacetrim.spaceTrim(`
|
|
1370
1369
|
Non-Error object was thrown
|
|
1371
1370
|
|
|
1372
1371
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1509,7 +1508,7 @@
|
|
|
1509
1508
|
/**
|
|
1510
1509
|
* Description of the FORMAT command
|
|
1511
1510
|
*/
|
|
1512
|
-
description:
|
|
1511
|
+
description: spacetrim.spaceTrim(`
|
|
1513
1512
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
1514
1513
|
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.
|
|
1515
1514
|
`),
|
|
@@ -1583,7 +1582,7 @@
|
|
|
1583
1582
|
}
|
|
1584
1583
|
catch (error) {
|
|
1585
1584
|
assertsError(error);
|
|
1586
|
-
throw new ParseError(
|
|
1585
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
1587
1586
|
Invalid FORMAT command
|
|
1588
1587
|
${block(error.message)}:
|
|
1589
1588
|
`));
|
|
@@ -1735,7 +1734,7 @@
|
|
|
1735
1734
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
1736
1735
|
const csv = csvParse(value, settings);
|
|
1737
1736
|
if (csv.errors.length !== 0) {
|
|
1738
|
-
throw new CsvFormatError(
|
|
1737
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
1739
1738
|
CSV parsing error
|
|
1740
1739
|
|
|
1741
1740
|
Error(s) from CSV parsing:
|
|
@@ -1780,7 +1779,7 @@
|
|
|
1780
1779
|
const { value, settings, mapCallback, onProgress } = options;
|
|
1781
1780
|
const csv = csvParse(value, settings);
|
|
1782
1781
|
if (csv.errors.length !== 0) {
|
|
1783
|
-
throw new CsvFormatError(
|
|
1782
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
1784
1783
|
CSV parsing error
|
|
1785
1784
|
|
|
1786
1785
|
Error(s) from CSV parsing:
|
|
@@ -2125,7 +2124,7 @@
|
|
|
2125
2124
|
}
|
|
2126
2125
|
else if (typeof value === 'object') {
|
|
2127
2126
|
if (value instanceof Date) {
|
|
2128
|
-
throw new UnexpectedError(
|
|
2127
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2129
2128
|
\`${name}\` is Date
|
|
2130
2129
|
|
|
2131
2130
|
Use \`string_date_iso8601\` instead
|
|
@@ -2144,7 +2143,7 @@
|
|
|
2144
2143
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2145
2144
|
}
|
|
2146
2145
|
else if (value instanceof Error) {
|
|
2147
|
-
throw new UnexpectedError(
|
|
2146
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2148
2147
|
\`${name}\` is unserialized Error
|
|
2149
2148
|
|
|
2150
2149
|
Use function \`serializeError\`
|
|
@@ -2167,7 +2166,7 @@
|
|
|
2167
2166
|
}
|
|
2168
2167
|
catch (error) {
|
|
2169
2168
|
assertsError(error);
|
|
2170
|
-
throw new UnexpectedError(
|
|
2169
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2171
2170
|
\`${name}\` is not serializable
|
|
2172
2171
|
|
|
2173
2172
|
${block(error.stack || error.message)}
|
|
@@ -2199,7 +2198,7 @@
|
|
|
2199
2198
|
}
|
|
2200
2199
|
}
|
|
2201
2200
|
else {
|
|
2202
|
-
throw new UnexpectedError(
|
|
2201
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2203
2202
|
\`${name}\` is unknown type
|
|
2204
2203
|
|
|
2205
2204
|
Additional message for \`${name}\`:
|
|
@@ -2729,7 +2728,7 @@
|
|
|
2729
2728
|
if (!(error instanceof ParseError)) {
|
|
2730
2729
|
throw error;
|
|
2731
2730
|
}
|
|
2732
|
-
throw new ParseError(
|
|
2731
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2733
2732
|
${block(error.message)}
|
|
2734
2733
|
|
|
2735
2734
|
Tried to validate parameter name:
|
|
@@ -2788,7 +2787,7 @@
|
|
|
2788
2787
|
const assignSign = args[3];
|
|
2789
2788
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
2790
2789
|
if (formatDefinition === undefined) {
|
|
2791
|
-
throw new ParseError(
|
|
2790
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2792
2791
|
Unsupported format "${formatName}"
|
|
2793
2792
|
|
|
2794
2793
|
Available formats:
|
|
@@ -2800,7 +2799,7 @@
|
|
|
2800
2799
|
}
|
|
2801
2800
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
2802
2801
|
if (subvalueParser === undefined) {
|
|
2803
|
-
throw new ParseError(
|
|
2802
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2804
2803
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
2805
2804
|
|
|
2806
2805
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -2848,7 +2847,7 @@
|
|
|
2848
2847
|
outputSubparameterName = 'newLine';
|
|
2849
2848
|
}
|
|
2850
2849
|
else {
|
|
2851
|
-
throw new ParseError(
|
|
2850
|
+
throw new ParseError(spacetrim.spaceTrim(`
|
|
2852
2851
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
2853
2852
|
|
|
2854
2853
|
Correct example:
|
|
@@ -2924,7 +2923,7 @@
|
|
|
2924
2923
|
/**
|
|
2925
2924
|
* Description of the FORMAT command
|
|
2926
2925
|
*/
|
|
2927
|
-
description:
|
|
2926
|
+
description: spacetrim.spaceTrim(`
|
|
2928
2927
|
Format command describes the desired output of the task (after post-processing)
|
|
2929
2928
|
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.
|
|
2930
2929
|
`),
|
|
@@ -3296,7 +3295,7 @@
|
|
|
3296
3295
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
3297
3296
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
3298
3297
|
if (formfactor === undefined) {
|
|
3299
|
-
throw new ParseError(
|
|
3298
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
3300
3299
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
3301
3300
|
|
|
3302
3301
|
Available formfactors:
|
|
@@ -3315,7 +3314,7 @@
|
|
|
3315
3314
|
*/
|
|
3316
3315
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
3317
3316
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
3318
|
-
throw new ParseError(
|
|
3317
|
+
throw new ParseError(spacetrim.spaceTrim(`
|
|
3319
3318
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
3320
3319
|
|
|
3321
3320
|
You have used:
|
|
@@ -3619,7 +3618,7 @@
|
|
|
3619
3618
|
*/
|
|
3620
3619
|
parse(input) {
|
|
3621
3620
|
const { args } = input;
|
|
3622
|
-
const knowledgeSourceContent =
|
|
3621
|
+
const knowledgeSourceContent = spacetrim.spaceTrim(args[0] || '');
|
|
3623
3622
|
if (knowledgeSourceContent === '') {
|
|
3624
3623
|
throw new ParseError(`Source is not defined`);
|
|
3625
3624
|
}
|
|
@@ -3718,7 +3717,7 @@
|
|
|
3718
3717
|
*/
|
|
3719
3718
|
parse(input) {
|
|
3720
3719
|
const { args, normalized } = input;
|
|
3721
|
-
const availableVariantsMessage =
|
|
3720
|
+
const availableVariantsMessage = spacetrim.spaceTrim((block) => `
|
|
3722
3721
|
Available variants are:
|
|
3723
3722
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
3724
3723
|
`);
|
|
@@ -3740,14 +3739,14 @@
|
|
|
3740
3739
|
// <- Note: [🤖]
|
|
3741
3740
|
}
|
|
3742
3741
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
3743
|
-
|
|
3742
|
+
spacetrim.spaceTrim((block) => `
|
|
3744
3743
|
Embedding model can not be used in pipeline
|
|
3745
3744
|
|
|
3746
3745
|
${block(availableVariantsMessage)}
|
|
3747
3746
|
`);
|
|
3748
3747
|
}
|
|
3749
3748
|
else {
|
|
3750
|
-
throw new ParseError(
|
|
3749
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
3751
3750
|
Unknown model variant in command:
|
|
3752
3751
|
|
|
3753
3752
|
${block(availableVariantsMessage)}
|
|
@@ -3762,7 +3761,7 @@
|
|
|
3762
3761
|
};
|
|
3763
3762
|
}
|
|
3764
3763
|
else {
|
|
3765
|
-
throw new ParseError(
|
|
3764
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
3766
3765
|
Unknown model key in command.
|
|
3767
3766
|
|
|
3768
3767
|
Supported model keys are:
|
|
@@ -3789,7 +3788,7 @@
|
|
|
3789
3788
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3790
3789
|
}
|
|
3791
3790
|
else {
|
|
3792
|
-
throw new ParseError(
|
|
3791
|
+
throw new ParseError(spacetrim.spaceTrim(`
|
|
3793
3792
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
3794
3793
|
|
|
3795
3794
|
You have used:
|
|
@@ -3817,7 +3816,7 @@
|
|
|
3817
3816
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3818
3817
|
}
|
|
3819
3818
|
else {
|
|
3820
|
-
throw new ParseError(
|
|
3819
|
+
throw new ParseError(spacetrim.spaceTrim(`
|
|
3821
3820
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
3822
3821
|
|
|
3823
3822
|
You have used:
|
|
@@ -3827,7 +3826,7 @@
|
|
|
3827
3826
|
}
|
|
3828
3827
|
}
|
|
3829
3828
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
3830
|
-
console.log(
|
|
3829
|
+
console.log(spacetrim.spaceTrim(`
|
|
3831
3830
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
3832
3831
|
|
|
3833
3832
|
In pipeline head:
|
|
@@ -3910,7 +3909,7 @@
|
|
|
3910
3909
|
// <- TODO: When [🥶] fixed, change to:
|
|
3911
3910
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
3912
3911
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
3913
|
-
throw new ParseError(
|
|
3912
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
3914
3913
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
3915
3914
|
|
|
3916
3915
|
The description:
|
|
@@ -4092,7 +4091,7 @@
|
|
|
4092
4091
|
persona.description = personaDescription;
|
|
4093
4092
|
return;
|
|
4094
4093
|
}
|
|
4095
|
-
console.warn(
|
|
4094
|
+
console.warn(spacetrim.spaceTrim(`
|
|
4096
4095
|
|
|
4097
4096
|
Persona "${personaName}" is defined multiple times with different description:
|
|
4098
4097
|
|
|
@@ -4103,7 +4102,7 @@
|
|
|
4103
4102
|
${personaDescription}
|
|
4104
4103
|
|
|
4105
4104
|
`));
|
|
4106
|
-
persona.description +=
|
|
4105
|
+
persona.description += spacetrim.spaceTrim('\n\n' + personaDescription);
|
|
4107
4106
|
}
|
|
4108
4107
|
|
|
4109
4108
|
/**
|
|
@@ -4325,7 +4324,7 @@
|
|
|
4325
4324
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
4326
4325
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
4327
4326
|
if (taskTypes.length !== 1) {
|
|
4328
|
-
throw new ParseError(
|
|
4327
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
4329
4328
|
Unknown section type "${normalized}"
|
|
4330
4329
|
|
|
4331
4330
|
Supported section types are:
|
|
@@ -4345,7 +4344,7 @@
|
|
|
4345
4344
|
*/
|
|
4346
4345
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
4347
4346
|
if ($taskJson.isSectionTypeSet === true) {
|
|
4348
|
-
throw new ParseError(
|
|
4347
|
+
throw new ParseError(spacetrim.spaceTrim(`
|
|
4349
4348
|
Section type is already defined in the section.
|
|
4350
4349
|
It can be defined only once.
|
|
4351
4350
|
`));
|
|
@@ -4727,7 +4726,7 @@
|
|
|
4727
4726
|
function getParserForCommand(command) {
|
|
4728
4727
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
4729
4728
|
if (commandParser === undefined) {
|
|
4730
|
-
throw new UnexpectedError(
|
|
4729
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
4731
4730
|
Command ${command.type} parser is not found
|
|
4732
4731
|
|
|
4733
4732
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -4803,7 +4802,7 @@
|
|
|
4803
4802
|
.map(removeMarkdownFormatting)
|
|
4804
4803
|
.map((item) => item.trim());
|
|
4805
4804
|
if (items.length === 0 || items[0] === '') {
|
|
4806
|
-
throw new ParseError(
|
|
4805
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
4807
4806
|
Malformed command:
|
|
4808
4807
|
- ${raw}
|
|
4809
4808
|
|
|
@@ -4839,7 +4838,7 @@
|
|
|
4839
4838
|
return command;
|
|
4840
4839
|
}
|
|
4841
4840
|
}
|
|
4842
|
-
throw new ParseError(
|
|
4841
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
4843
4842
|
Malformed or unknown command:
|
|
4844
4843
|
- ${raw}
|
|
4845
4844
|
|
|
@@ -4890,7 +4889,7 @@
|
|
|
4890
4889
|
if (!(error instanceof ParseError)) {
|
|
4891
4890
|
throw error;
|
|
4892
4891
|
}
|
|
4893
|
-
throw new ParseError(
|
|
4892
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
4894
4893
|
Invalid ${commandName} command:
|
|
4895
4894
|
|
|
4896
4895
|
Your command:
|
|
@@ -5008,7 +5007,7 @@
|
|
|
5008
5007
|
* @public exported from `@promptbook/markdown-utils`
|
|
5009
5008
|
*/
|
|
5010
5009
|
function removeMarkdownComments(content) {
|
|
5011
|
-
return
|
|
5010
|
+
return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
5012
5011
|
}
|
|
5013
5012
|
|
|
5014
5013
|
/**
|
|
@@ -5019,7 +5018,7 @@
|
|
|
5019
5018
|
*/
|
|
5020
5019
|
function isFlatPipeline(pipelineString) {
|
|
5021
5020
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
5022
|
-
pipelineString =
|
|
5021
|
+
pipelineString = spacetrim.spaceTrim(pipelineString);
|
|
5023
5022
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
5024
5023
|
//const isLastLineReturnStatement = pipelineString.split(/\r?\n/).pop()!.split('`').join('').startsWith('->');
|
|
5025
5024
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -5045,7 +5044,7 @@
|
|
|
5045
5044
|
if (!isFlatPipeline(pipelineString)) {
|
|
5046
5045
|
return pipelineString;
|
|
5047
5046
|
}
|
|
5048
|
-
pipelineString =
|
|
5047
|
+
pipelineString = spacetrim.spaceTrim(pipelineString);
|
|
5049
5048
|
const pipelineStringLines = pipelineString.split(/\r?\n/);
|
|
5050
5049
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
5051
5050
|
let returnStatement;
|
|
@@ -5058,19 +5057,19 @@
|
|
|
5058
5057
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
5059
5058
|
pipelineStringLines.push(potentialReturnStatement);
|
|
5060
5059
|
}
|
|
5061
|
-
const prompt =
|
|
5060
|
+
const prompt = spacetrim.spaceTrim(pipelineStringLines.join('\n'));
|
|
5062
5061
|
let quotedPrompt;
|
|
5063
5062
|
if (prompt.split(/\r?\n/).length <= 1) {
|
|
5064
5063
|
quotedPrompt = `> ${prompt}`;
|
|
5065
5064
|
}
|
|
5066
5065
|
else {
|
|
5067
|
-
quotedPrompt =
|
|
5066
|
+
quotedPrompt = spacetrim.spaceTrim((block) => `
|
|
5068
5067
|
\`\`\`
|
|
5069
5068
|
${block(prompt.split('`').join('\\`'))}
|
|
5070
5069
|
\`\`\`
|
|
5071
5070
|
`);
|
|
5072
5071
|
}
|
|
5073
|
-
pipelineString = validatePipelineString(
|
|
5072
|
+
pipelineString = validatePipelineString(spacetrim.spaceTrim((block) => `
|
|
5074
5073
|
# ${DEFAULT_BOOK_TITLE}
|
|
5075
5074
|
|
|
5076
5075
|
## Prompt
|
|
@@ -5138,7 +5137,7 @@
|
|
|
5138
5137
|
);
|
|
5139
5138
|
*/
|
|
5140
5139
|
}
|
|
5141
|
-
return
|
|
5140
|
+
return spacetrim.spaceTrim(newLines.join('\n'));
|
|
5142
5141
|
}
|
|
5143
5142
|
/**
|
|
5144
5143
|
* TODO: [🧠] What is the better solution - `- xxx`, - `- xxx` or preserve (see also next TODO)
|
|
@@ -5180,7 +5179,7 @@
|
|
|
5180
5179
|
}
|
|
5181
5180
|
newLines.push(line);
|
|
5182
5181
|
}
|
|
5183
|
-
const newPipeline =
|
|
5182
|
+
const newPipeline = spacetrim.spaceTrim(newLines.join('\n'));
|
|
5184
5183
|
return newPipeline;
|
|
5185
5184
|
}
|
|
5186
5185
|
|
|
@@ -5283,7 +5282,7 @@
|
|
|
5283
5282
|
*/
|
|
5284
5283
|
function stringifyPipelineJson(pipeline) {
|
|
5285
5284
|
if (!isSerializableAsJson(pipeline)) {
|
|
5286
|
-
throw new UnexpectedError(
|
|
5285
|
+
throw new UnexpectedError(spacetrim.spaceTrim(`
|
|
5287
5286
|
Cannot stringify the pipeline, because it is not serializable as JSON
|
|
5288
5287
|
|
|
5289
5288
|
There can be multiple reasons:
|