@promptbook/node 0.89.0-1 → 0.89.0-3
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/README.md +3 -1
- package/esm/index.es.js +117 -86
- 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 +6 -4
- package/esm/typings/src/cli/cli-commands/login.d.ts +15 -0
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
- package/esm/typings/src/execution/PromptResult.d.ts +2 -2
- package/esm/typings/src/execution/{PromptResultUsage.d.ts → Usage.d.ts} +5 -5
- package/esm/typings/src/execution/utils/addUsage.d.ts +2 -2
- package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +3 -3
- package/esm/typings/src/execution/utils/usage-constants.d.ts +77 -60
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +5 -5
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +5 -5
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +0 -9
- package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +2 -2
- package/esm/typings/src/playground/BrjappConnector.d.ts +3 -0
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/package.json +2 -2
- package/umd/index.umd.js +117 -86
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-3';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1889,6 +1889,7 @@
|
|
|
1889
1889
|
const { isSuccessful, errors, warnings } = executionResult;
|
|
1890
1890
|
for (const warning of warnings) {
|
|
1891
1891
|
console.warn(warning.message);
|
|
1892
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1892
1893
|
}
|
|
1893
1894
|
if (isSuccessful === true) {
|
|
1894
1895
|
return;
|
|
@@ -2113,30 +2114,42 @@
|
|
|
2113
2114
|
}
|
|
2114
2115
|
}
|
|
2115
2116
|
|
|
2117
|
+
/**
|
|
2118
|
+
* Represents the uncertain value
|
|
2119
|
+
*
|
|
2120
|
+
* @public exported from `@promptbook/core`
|
|
2121
|
+
*/
|
|
2122
|
+
const ZERO_VALUE = $deepFreeze({ value: 0 });
|
|
2123
|
+
/**
|
|
2124
|
+
* Represents the uncertain value
|
|
2125
|
+
*
|
|
2126
|
+
* @public exported from `@promptbook/core`
|
|
2127
|
+
*/
|
|
2128
|
+
const UNCERTAIN_ZERO_VALUE = $deepFreeze({ value: 0, isUncertain: true });
|
|
2116
2129
|
/**
|
|
2117
2130
|
* Represents the usage with no resources consumed
|
|
2118
2131
|
*
|
|
2119
2132
|
* @public exported from `@promptbook/core`
|
|
2120
2133
|
*/
|
|
2121
2134
|
const ZERO_USAGE = $deepFreeze({
|
|
2122
|
-
price:
|
|
2135
|
+
price: ZERO_VALUE,
|
|
2123
2136
|
input: {
|
|
2124
|
-
tokensCount:
|
|
2125
|
-
charactersCount:
|
|
2126
|
-
wordsCount:
|
|
2127
|
-
sentencesCount:
|
|
2128
|
-
linesCount:
|
|
2129
|
-
paragraphsCount:
|
|
2130
|
-
pagesCount:
|
|
2137
|
+
tokensCount: ZERO_VALUE,
|
|
2138
|
+
charactersCount: ZERO_VALUE,
|
|
2139
|
+
wordsCount: ZERO_VALUE,
|
|
2140
|
+
sentencesCount: ZERO_VALUE,
|
|
2141
|
+
linesCount: ZERO_VALUE,
|
|
2142
|
+
paragraphsCount: ZERO_VALUE,
|
|
2143
|
+
pagesCount: ZERO_VALUE,
|
|
2131
2144
|
},
|
|
2132
2145
|
output: {
|
|
2133
|
-
tokensCount:
|
|
2134
|
-
charactersCount:
|
|
2135
|
-
wordsCount:
|
|
2136
|
-
sentencesCount:
|
|
2137
|
-
linesCount:
|
|
2138
|
-
paragraphsCount:
|
|
2139
|
-
pagesCount:
|
|
2146
|
+
tokensCount: ZERO_VALUE,
|
|
2147
|
+
charactersCount: ZERO_VALUE,
|
|
2148
|
+
wordsCount: ZERO_VALUE,
|
|
2149
|
+
sentencesCount: ZERO_VALUE,
|
|
2150
|
+
linesCount: ZERO_VALUE,
|
|
2151
|
+
paragraphsCount: ZERO_VALUE,
|
|
2152
|
+
pagesCount: ZERO_VALUE,
|
|
2140
2153
|
},
|
|
2141
2154
|
});
|
|
2142
2155
|
/**
|
|
@@ -2145,24 +2158,24 @@
|
|
|
2145
2158
|
* @public exported from `@promptbook/core`
|
|
2146
2159
|
*/
|
|
2147
2160
|
$deepFreeze({
|
|
2148
|
-
price:
|
|
2161
|
+
price: UNCERTAIN_ZERO_VALUE,
|
|
2149
2162
|
input: {
|
|
2150
|
-
tokensCount:
|
|
2151
|
-
charactersCount:
|
|
2152
|
-
wordsCount:
|
|
2153
|
-
sentencesCount:
|
|
2154
|
-
linesCount:
|
|
2155
|
-
paragraphsCount:
|
|
2156
|
-
pagesCount:
|
|
2163
|
+
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
2164
|
+
charactersCount: UNCERTAIN_ZERO_VALUE,
|
|
2165
|
+
wordsCount: UNCERTAIN_ZERO_VALUE,
|
|
2166
|
+
sentencesCount: UNCERTAIN_ZERO_VALUE,
|
|
2167
|
+
linesCount: UNCERTAIN_ZERO_VALUE,
|
|
2168
|
+
paragraphsCount: UNCERTAIN_ZERO_VALUE,
|
|
2169
|
+
pagesCount: UNCERTAIN_ZERO_VALUE,
|
|
2157
2170
|
},
|
|
2158
2171
|
output: {
|
|
2159
|
-
tokensCount:
|
|
2160
|
-
charactersCount:
|
|
2161
|
-
wordsCount:
|
|
2162
|
-
sentencesCount:
|
|
2163
|
-
linesCount:
|
|
2164
|
-
paragraphsCount:
|
|
2165
|
-
pagesCount:
|
|
2172
|
+
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
2173
|
+
charactersCount: UNCERTAIN_ZERO_VALUE,
|
|
2174
|
+
wordsCount: UNCERTAIN_ZERO_VALUE,
|
|
2175
|
+
sentencesCount: UNCERTAIN_ZERO_VALUE,
|
|
2176
|
+
linesCount: UNCERTAIN_ZERO_VALUE,
|
|
2177
|
+
paragraphsCount: UNCERTAIN_ZERO_VALUE,
|
|
2178
|
+
pagesCount: UNCERTAIN_ZERO_VALUE,
|
|
2166
2179
|
},
|
|
2167
2180
|
});
|
|
2168
2181
|
/**
|
|
@@ -2333,7 +2346,7 @@
|
|
|
2333
2346
|
if (parameterNames.has(subparameterName)) {
|
|
2334
2347
|
parameterNames.delete(subparameterName);
|
|
2335
2348
|
parameterNames.add(foreach.parameterName);
|
|
2336
|
-
// <- TODO: [
|
|
2349
|
+
// <- TODO: [🏮] Warn/logic error when `subparameterName` not used
|
|
2337
2350
|
}
|
|
2338
2351
|
}
|
|
2339
2352
|
}
|
|
@@ -2827,6 +2840,7 @@
|
|
|
2827
2840
|
`);
|
|
2828
2841
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
2829
2842
|
console.warn(warningMessage);
|
|
2843
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
2830
2844
|
/*
|
|
2831
2845
|
return {
|
|
2832
2846
|
async listModels() {
|
|
@@ -4416,6 +4430,7 @@
|
|
|
4416
4430
|
|
|
4417
4431
|
@see more at https://ptbk.io/prepare-pipeline
|
|
4418
4432
|
`));
|
|
4433
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4419
4434
|
}
|
|
4420
4435
|
let runCount = 0;
|
|
4421
4436
|
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|
|
@@ -5192,63 +5207,73 @@
|
|
|
5192
5207
|
const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT, rootDirname, isVerbose = DEFAULT_IS_VERBOSE } = options;
|
|
5193
5208
|
const knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
5194
5209
|
await forEachAsync(knowledgeSources, { maxParallelCount }, async (knowledgeSource, index) => {
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5210
|
+
try {
|
|
5211
|
+
let partialPieces = null;
|
|
5212
|
+
const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
|
|
5213
|
+
const scrapers = arrayableToArray(tools.scrapers);
|
|
5214
|
+
for (const scraper of scrapers) {
|
|
5215
|
+
if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
|
|
5216
|
+
// <- TODO: [🦔] Implement mime-type wildcards
|
|
5217
|
+
) {
|
|
5218
|
+
continue;
|
|
5219
|
+
}
|
|
5220
|
+
const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
|
|
5221
|
+
if (partialPiecesUnchecked !== null) {
|
|
5222
|
+
partialPieces = [...partialPiecesUnchecked];
|
|
5223
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5224
|
+
break;
|
|
5225
|
+
}
|
|
5226
|
+
console.warn(spaceTrim__default["default"]((block) => `
|
|
5227
|
+
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
5212
5228
|
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5229
|
+
The source:
|
|
5230
|
+
${block(knowledgeSource.knowledgeSourceContent
|
|
5231
|
+
.split('\n')
|
|
5232
|
+
.map((line) => `> ${line}`)
|
|
5233
|
+
.join('\n'))}
|
|
5218
5234
|
|
|
5219
|
-
|
|
5235
|
+
${block($registeredScrapersMessage(scrapers))}
|
|
5220
5236
|
|
|
5221
5237
|
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5238
|
+
`));
|
|
5239
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5240
|
+
}
|
|
5241
|
+
if (partialPieces === null) {
|
|
5242
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"]((block) => `
|
|
5243
|
+
Cannot scrape knowledge
|
|
5227
5244
|
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5245
|
+
The source:
|
|
5246
|
+
> ${block(knowledgeSource.knowledgeSourceContent
|
|
5247
|
+
.split('\n')
|
|
5248
|
+
.map((line) => `> ${line}`)
|
|
5249
|
+
.join('\n'))}
|
|
5233
5250
|
|
|
5234
|
-
|
|
5251
|
+
No scraper found for the mime type "${sourceHandler.mimeType}"
|
|
5235
5252
|
|
|
5236
|
-
|
|
5253
|
+
${block($registeredScrapersMessage(scrapers))}
|
|
5237
5254
|
|
|
5238
5255
|
|
|
5239
|
-
|
|
5256
|
+
`));
|
|
5257
|
+
}
|
|
5258
|
+
const pieces = partialPieces.map((partialPiece) => ({
|
|
5259
|
+
...partialPiece,
|
|
5260
|
+
sources: [
|
|
5261
|
+
{
|
|
5262
|
+
name: knowledgeSource.name,
|
|
5263
|
+
// line, column <- TODO: [☀]
|
|
5264
|
+
// <- TODO: [❎]
|
|
5265
|
+
},
|
|
5266
|
+
],
|
|
5267
|
+
}));
|
|
5268
|
+
knowledgePreparedUnflatten[index] = pieces;
|
|
5269
|
+
}
|
|
5270
|
+
catch (error) {
|
|
5271
|
+
if (!(error instanceof Error)) {
|
|
5272
|
+
throw error;
|
|
5273
|
+
}
|
|
5274
|
+
console.warn(error);
|
|
5275
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5240
5276
|
}
|
|
5241
|
-
const pieces = partialPieces.map((partialPiece) => ({
|
|
5242
|
-
...partialPiece,
|
|
5243
|
-
sources: [
|
|
5244
|
-
{
|
|
5245
|
-
name: knowledgeSource.name,
|
|
5246
|
-
// line, column <- TODO: [☀]
|
|
5247
|
-
// <- TODO: [❎]
|
|
5248
|
-
},
|
|
5249
|
-
],
|
|
5250
|
-
}));
|
|
5251
|
-
knowledgePreparedUnflatten[index] = pieces;
|
|
5252
5277
|
});
|
|
5253
5278
|
const knowledgePrepared = knowledgePreparedUnflatten.flat();
|
|
5254
5279
|
return knowledgePrepared;
|
|
@@ -7073,7 +7098,8 @@
|
|
|
7073
7098
|
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
7074
7099
|
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
7075
7100
|
console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the pipeline head`);
|
|
7076
|
-
// <- TODO: [
|
|
7101
|
+
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
7102
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7077
7103
|
}
|
|
7078
7104
|
else {
|
|
7079
7105
|
throw new ParseError(spaceTrim__default["default"](`
|
|
@@ -7105,6 +7131,7 @@
|
|
|
7105
7131
|
modelVariant: 'VARIANT',
|
|
7106
7132
|
maxTokens: '???',
|
|
7107
7133
|
}[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
|
|
7134
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7108
7135
|
}
|
|
7109
7136
|
else {
|
|
7110
7137
|
throw new ParseError(spaceTrim__default["default"](`
|
|
@@ -7384,15 +7411,15 @@
|
|
|
7384
7411
|
}
|
|
7385
7412
|
console.warn(spaceTrim__default["default"](`
|
|
7386
7413
|
|
|
7387
|
-
|
|
7414
|
+
Persona "${personaName}" is defined multiple times with different description:
|
|
7388
7415
|
|
|
7389
|
-
|
|
7390
|
-
|
|
7416
|
+
First definition:
|
|
7417
|
+
${persona.description}
|
|
7391
7418
|
|
|
7392
|
-
|
|
7393
|
-
|
|
7419
|
+
Second definition:
|
|
7420
|
+
${personaDescription}
|
|
7394
7421
|
|
|
7395
|
-
|
|
7422
|
+
`));
|
|
7396
7423
|
persona.description += spaceTrim__default["default"]('\n\n' + personaDescription);
|
|
7397
7424
|
}
|
|
7398
7425
|
|
|
@@ -9028,6 +9055,7 @@
|
|
|
9028
9055
|
}
|
|
9029
9056
|
else {
|
|
9030
9057
|
console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
|
|
9058
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9031
9059
|
resolve('Command exceeded time limit');
|
|
9032
9060
|
}
|
|
9033
9061
|
});
|
|
@@ -9053,6 +9081,7 @@
|
|
|
9053
9081
|
output.push(stderr.toString());
|
|
9054
9082
|
if (isVerbose && stderr.toString().trim()) {
|
|
9055
9083
|
console.warn(stderr.toString());
|
|
9084
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9056
9085
|
}
|
|
9057
9086
|
});
|
|
9058
9087
|
const finishWithCode = (code) => {
|
|
@@ -9064,6 +9093,7 @@
|
|
|
9064
9093
|
else {
|
|
9065
9094
|
if (isVerbose) {
|
|
9066
9095
|
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
9096
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9067
9097
|
}
|
|
9068
9098
|
resolve(spaceTrim.spaceTrim(output.join('\n')));
|
|
9069
9099
|
}
|
|
@@ -9085,6 +9115,7 @@
|
|
|
9085
9115
|
else {
|
|
9086
9116
|
if (isVerbose) {
|
|
9087
9117
|
console.warn(error);
|
|
9118
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9088
9119
|
}
|
|
9089
9120
|
resolve(spaceTrim.spaceTrim(output.join('\n')));
|
|
9090
9121
|
}
|