@promptbook/website-crawler 0.92.0-20 β 0.92.0-22
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 +60 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/config.d.ts +8 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +8 -1
- package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +11 -1
- package/esm/typings/src/formats/json/utils/jsonParse.d.ts +0 -3
- package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +29 -0
- package/esm/typings/src/formfactors/index.d.ts +28 -3
- package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
- package/esm/typings/src/migrations/migratePipeline.d.ts +2 -0
- package/package.json +2 -2
- package/umd/index.umd.js +60 -45
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -2499,15 +2499,12 @@ function jsonParse(value) {
|
|
|
2499
2499
|
}
|
|
2500
2500
|
throw new Error(spaceTrim$1((block) => `
|
|
2501
2501
|
${block(error.message)}
|
|
2502
|
-
|
|
2502
|
+
|
|
2503
2503
|
The JSON text:
|
|
2504
2504
|
${block(value)}
|
|
2505
2505
|
`));
|
|
2506
2506
|
}
|
|
2507
2507
|
}
|
|
2508
|
-
/**
|
|
2509
|
-
* TODO: !!!! Use in Promptbook.studio
|
|
2510
|
-
*/
|
|
2511
2508
|
|
|
2512
2509
|
/**
|
|
2513
2510
|
* Recursively converts JSON strings to JSON objects
|
|
@@ -4155,7 +4152,8 @@ const CsvFormatParser = {
|
|
|
4155
4152
|
subvalueParsers: [
|
|
4156
4153
|
{
|
|
4157
4154
|
subvalueName: 'ROW',
|
|
4158
|
-
async mapValues(
|
|
4155
|
+
async mapValues(options) {
|
|
4156
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4159
4157
|
const csv = csvParse(value, settings);
|
|
4160
4158
|
if (csv.errors.length !== 0) {
|
|
4161
4159
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
@@ -4171,21 +4169,29 @@ const CsvFormatParser = {
|
|
|
4171
4169
|
${block(value)}
|
|
4172
4170
|
`));
|
|
4173
4171
|
}
|
|
4174
|
-
const mappedData =
|
|
4172
|
+
const mappedData = [];
|
|
4173
|
+
for (let index = 0; index < csv.data.length; index++) {
|
|
4174
|
+
const row = csv.data[index];
|
|
4175
4175
|
if (row[outputParameterName]) {
|
|
4176
4176
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4177
4177
|
}
|
|
4178
|
-
|
|
4178
|
+
const mappedRow = {
|
|
4179
4179
|
...row,
|
|
4180
4180
|
[outputParameterName]: await mapCallback(row, index),
|
|
4181
4181
|
};
|
|
4182
|
-
|
|
4182
|
+
mappedData.push(mappedRow);
|
|
4183
|
+
if (onProgress) {
|
|
4184
|
+
// Note: Report the CSV with all rows mapped so far
|
|
4185
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4183
4188
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
4184
4189
|
},
|
|
4185
4190
|
},
|
|
4186
4191
|
{
|
|
4187
4192
|
subvalueName: 'CELL',
|
|
4188
|
-
async mapValues(
|
|
4193
|
+
async mapValues(options) {
|
|
4194
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
4189
4195
|
const csv = csvParse(value, settings);
|
|
4190
4196
|
if (csv.errors.length !== 0) {
|
|
4191
4197
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
@@ -4272,7 +4278,8 @@ const TextFormatParser = {
|
|
|
4272
4278
|
subvalueParsers: [
|
|
4273
4279
|
{
|
|
4274
4280
|
subvalueName: 'LINE',
|
|
4275
|
-
async mapValues(
|
|
4281
|
+
async mapValues(options) {
|
|
4282
|
+
const { value, mapCallback, onProgress } = options;
|
|
4276
4283
|
const lines = value.split('\n');
|
|
4277
4284
|
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4278
4285
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
@@ -5093,7 +5100,7 @@ async function executeAttempts(options) {
|
|
|
5093
5100
|
* @private internal utility of `createPipelineExecutor`
|
|
5094
5101
|
*/
|
|
5095
5102
|
async function executeFormatSubvalues(options) {
|
|
5096
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
5103
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
5097
5104
|
if (task.foreach === undefined) {
|
|
5098
5105
|
return /* not await */ executeAttempts(options);
|
|
5099
5106
|
}
|
|
@@ -5147,21 +5154,32 @@ async function executeFormatSubvalues(options) {
|
|
|
5147
5154
|
formatSettings = csvSettings;
|
|
5148
5155
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
5149
5156
|
}
|
|
5150
|
-
const resultString = await subvalueParser.mapValues(
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5157
|
+
const resultString = await subvalueParser.mapValues({
|
|
5158
|
+
value: parameterValue,
|
|
5159
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
5160
|
+
settings: formatSettings,
|
|
5161
|
+
onProgress(partialResultString) {
|
|
5162
|
+
return onProgress(Object.freeze({
|
|
5163
|
+
[task.resultingParameterName]:
|
|
5164
|
+
// <- Note: [π©βπ©βπ§] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5165
|
+
partialResultString,
|
|
5166
|
+
}));
|
|
5167
|
+
},
|
|
5168
|
+
async mapCallback(subparameters, index) {
|
|
5169
|
+
let mappedParameters;
|
|
5170
|
+
// TODO: [π€ΉββοΈ][πͺ] Limit to N concurrent executions
|
|
5171
|
+
// TODO: When done [π] Report progress also for each subvalue here
|
|
5172
|
+
try {
|
|
5173
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
5174
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
5175
|
+
availableParameters: subparameters,
|
|
5176
|
+
});
|
|
5163
5177
|
}
|
|
5164
|
-
|
|
5178
|
+
catch (error) {
|
|
5179
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
5180
|
+
throw error;
|
|
5181
|
+
}
|
|
5182
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5165
5183
|
${error.message}
|
|
5166
5184
|
|
|
5167
5185
|
This is error in FOREACH command
|
|
@@ -5170,23 +5188,24 @@ async function executeFormatSubvalues(options) {
|
|
|
5170
5188
|
${block(pipelineIdentification)}
|
|
5171
5189
|
Subparameter index: ${index}
|
|
5172
5190
|
`));
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5191
|
+
}
|
|
5192
|
+
const allSubparameters = {
|
|
5193
|
+
...parameters,
|
|
5194
|
+
...mappedParameters,
|
|
5195
|
+
};
|
|
5196
|
+
// Note: [π¨βπ¨βπ§] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
|
|
5197
|
+
Object.freeze(allSubparameters);
|
|
5198
|
+
const subresultString = await executeAttempts({
|
|
5199
|
+
...options,
|
|
5200
|
+
priority: priority + index,
|
|
5201
|
+
parameters: allSubparameters,
|
|
5202
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
5185
5203
|
${block(pipelineIdentification)}
|
|
5186
5204
|
Subparameter index: ${index}
|
|
5187
5205
|
`),
|
|
5188
|
-
|
|
5189
|
-
|
|
5206
|
+
});
|
|
5207
|
+
return subresultString;
|
|
5208
|
+
},
|
|
5190
5209
|
});
|
|
5191
5210
|
return resultString;
|
|
5192
5211
|
}
|
|
@@ -5360,11 +5379,6 @@ async function getReservedParametersForTask(options) {
|
|
|
5360
5379
|
async function executeTask(options) {
|
|
5361
5380
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5362
5381
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5363
|
-
await onProgress({
|
|
5364
|
-
outputParameters: {
|
|
5365
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
5366
|
-
},
|
|
5367
|
-
});
|
|
5368
5382
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
5369
5383
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5370
5384
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -5439,6 +5453,7 @@ async function executeTask(options) {
|
|
|
5439
5453
|
preparedPipeline,
|
|
5440
5454
|
tools,
|
|
5441
5455
|
$executionReport,
|
|
5456
|
+
onProgress,
|
|
5442
5457
|
pipelineIdentification,
|
|
5443
5458
|
maxExecutionAttempts,
|
|
5444
5459
|
maxParallelCount,
|