@promptbook/core 0.61.0-12 → 0.61.0-13
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 +111 -35
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/execute-javascript.index.d.ts +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/esm/typings/src/execution/utils/addUsage.d.ts +57 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
- package/esm/typings/src/utils/deepClone.d.ts +9 -0
- package/esm/typings/src/utils/deepFreeze.d.ts +13 -0
- package/esm/typings/src/utils/organization/just.d.ts +4 -1
- package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
- package/esm/typings/src/version.d.ts +0 -3
- package/package.json +1 -1
- package/umd/index.umd.js +111 -35
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
- package/umd/typings/src/_packages/utils.index.d.ts +1 -1
- package/umd/typings/src/config.d.ts +1 -1
- package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/umd/typings/src/execution/utils/addUsage.d.ts +57 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
- package/umd/typings/src/utils/deepClone.d.ts +9 -0
- package/umd/typings/src/utils/deepFreeze.d.ts +13 -0
- package/umd/typings/src/utils/organization/just.d.ts +4 -1
- package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
- package/umd/typings/src/version.d.ts +0 -3
- package/esm/typings/src/execution/addPromptResultUsage.test.d.ts +0 -1
- package/esm/typings/src/utils/organization/keepImported.d.ts +0 -12
- package/esm/typings/src/utils/organization/notUsing.d.ts +0 -12
- package/umd/typings/src/execution/addPromptResultUsage.test.d.ts +0 -1
- package/umd/typings/src/utils/organization/keepImported.d.ts +0 -12
- package/umd/typings/src/utils/organization/notUsing.d.ts +0 -12
- /package/esm/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
- /package/umd/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import spaceTrim from 'spacetrim';
|
|
2
|
+
import { extractBlock } from '../postprocessing/utils/extractBlock';
|
|
2
3
|
import { JavascriptEvalExecutionTools } from '../scripting/javascript/JavascriptEvalExecutionTools';
|
|
3
4
|
import { JavascriptExecutionTools } from '../scripting/javascript/JavascriptExecutionTools';
|
|
4
5
|
import { prettifyMarkdown } from '../utils/markdown/prettifyMarkdown';
|
|
@@ -13,7 +14,6 @@ import { normalizeTo_camelCase } from '../utils/normalization/normalizeTo_camelC
|
|
|
13
14
|
import { normalizeTo_snake_case } from '../utils/normalization/normalizeTo_snake_case';
|
|
14
15
|
import { normalizeWhitespaces } from '../utils/normalization/normalizeWhitespaces';
|
|
15
16
|
import { removeDiacritics } from '../utils/normalization/removeDiacritics';
|
|
16
|
-
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
17
17
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
18
18
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
19
19
|
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
@@ -7,6 +7,7 @@ import { titleToName } from '../conversion/utils/titleToName';
|
|
|
7
7
|
import { forEachAsync } from '../execution/utils/forEachAsync';
|
|
8
8
|
import { replaceParameters } from '../execution/utils/replaceParameters';
|
|
9
9
|
import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
|
|
10
|
+
import { extractBlock } from '../postprocessing/utils/extractBlock';
|
|
10
11
|
import { $currentDate } from '../utils/currentDate';
|
|
11
12
|
import { countCharacters } from '../utils/expectation-counters/countCharacters';
|
|
12
13
|
import { countLines } from '../utils/expectation-counters/countLines';
|
|
@@ -34,7 +35,6 @@ import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFro
|
|
|
34
35
|
import { removeDiacritics } from '../utils/normalization/removeDiacritics';
|
|
35
36
|
import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
36
37
|
import { parseNumber } from '../utils/parseNumber';
|
|
37
|
-
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
38
38
|
import { $randomSeed } from '../utils/random/randomSeed';
|
|
39
39
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
40
40
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
@@ -21,4 +21,4 @@ export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
|
|
|
21
21
|
/**
|
|
22
22
|
* The names of the parameters that are reserved for special purposes
|
|
23
23
|
*/
|
|
24
|
-
export declare const RESERVED_PARAMETER_NAMES: string[];
|
|
24
|
+
export declare const RESERVED_PARAMETER_NAMES: readonly string[];
|
|
@@ -1,7 +1,63 @@
|
|
|
1
1
|
import type { PromptResultUsage } from '../PromptResult';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* TODO: [🔼] Export with addUsage
|
|
6
|
+
*/
|
|
7
|
+
export declare const ZERO_USAGE: import("type-fest/source/readonly-deep").ReadonlyObjectDeep<{
|
|
8
|
+
readonly price: {
|
|
9
|
+
readonly value: 0;
|
|
10
|
+
};
|
|
11
|
+
readonly input: {
|
|
12
|
+
readonly tokensCount: {
|
|
13
|
+
readonly value: 0;
|
|
14
|
+
};
|
|
15
|
+
readonly charactersCount: {
|
|
16
|
+
readonly value: 0;
|
|
17
|
+
};
|
|
18
|
+
readonly wordsCount: {
|
|
19
|
+
readonly value: 0;
|
|
20
|
+
};
|
|
21
|
+
readonly sentencesCount: {
|
|
22
|
+
readonly value: 0;
|
|
23
|
+
};
|
|
24
|
+
readonly linesCount: {
|
|
25
|
+
readonly value: 0;
|
|
26
|
+
};
|
|
27
|
+
readonly paragraphsCount: {
|
|
28
|
+
readonly value: 0;
|
|
29
|
+
};
|
|
30
|
+
readonly pagesCount: {
|
|
31
|
+
readonly value: 0;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly output: {
|
|
35
|
+
readonly tokensCount: {
|
|
36
|
+
readonly value: 0;
|
|
37
|
+
};
|
|
38
|
+
readonly charactersCount: {
|
|
39
|
+
readonly value: 0;
|
|
40
|
+
};
|
|
41
|
+
readonly wordsCount: {
|
|
42
|
+
readonly value: 0;
|
|
43
|
+
};
|
|
44
|
+
readonly sentencesCount: {
|
|
45
|
+
readonly value: 0;
|
|
46
|
+
};
|
|
47
|
+
readonly linesCount: {
|
|
48
|
+
readonly value: 0;
|
|
49
|
+
};
|
|
50
|
+
readonly paragraphsCount: {
|
|
51
|
+
readonly value: 0;
|
|
52
|
+
};
|
|
53
|
+
readonly pagesCount: {
|
|
54
|
+
readonly value: 0;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}>;
|
|
2
58
|
/**
|
|
3
59
|
* Function `addUsage` will add multiple usages into one
|
|
4
60
|
*
|
|
5
|
-
* Note: If you provide 0 values, it returns
|
|
61
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
6
62
|
*/
|
|
7
63
|
export declare function addUsage(...usageItems: Array<PromptResultUsage>): PromptResultUsage;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
|
|
2
|
+
import type { PromptResultUsage } from '../../../../execution/PromptResult';
|
|
3
|
+
import type { PromptbookStorage } from '../../../../storage/_common/PromptbookStorage';
|
|
4
|
+
import type { TODO } from '../../../../utils/organization/TODO';
|
|
5
|
+
import type { LlmExecutionToolsWithTotalCost } from './LlmExecutionToolsWithTotalCost';
|
|
6
|
+
/**
|
|
7
|
+
* Options for `limitTotalCost`
|
|
8
|
+
*/
|
|
9
|
+
type LimitTotalCostOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* @@@
|
|
12
|
+
*
|
|
13
|
+
* @default ZERO_USAGE
|
|
14
|
+
*/
|
|
15
|
+
maxTotalCost: PromptResultUsage;
|
|
16
|
+
/**
|
|
17
|
+
* @@@
|
|
18
|
+
*
|
|
19
|
+
* @default MemoryStorage
|
|
20
|
+
*/
|
|
21
|
+
storage: PromptbookStorage<TODO>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @@@
|
|
25
|
+
*/
|
|
26
|
+
export declare function limitTotalCost(llmTools: LlmExecutionTools, options?: Partial<LimitTotalCostOptions>): LlmExecutionToolsWithTotalCost;
|
|
27
|
+
export {};
|
|
28
|
+
/**
|
|
29
|
+
* TODO: [🔼] !!! Export via `@promptbookcore/`
|
|
30
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
31
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
32
|
+
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WritableDeep } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*/
|
|
5
|
+
export declare function deepClone<TObject>(objectValue: TObject): WritableDeep<TObject>;
|
|
6
|
+
/**
|
|
7
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
8
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
9
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* @returns The same object as the input, but deeply frozen
|
|
6
|
+
*
|
|
7
|
+
* Note: This function mutates the object
|
|
8
|
+
*/
|
|
9
|
+
export declare function deepFreeze<TObject>(objectValue: TObject): ReadonlyDeep<TObject>;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
12
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
13
|
+
*/
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Returns the same value that is passed as argument.
|
|
3
3
|
* No side effects.
|
|
4
4
|
*
|
|
5
|
-
* Note: It can be usefull for
|
|
5
|
+
* Note: It can be usefull for:
|
|
6
|
+
*
|
|
7
|
+
* 1) Leveling indentation
|
|
8
|
+
* 2) Putting always-true or always-false conditions without getting eslint errors
|
|
6
9
|
*
|
|
7
10
|
* @param value any values
|
|
8
11
|
* @returns the same values
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { really_any } from './really_any';
|
|
2
|
+
/**
|
|
3
|
+
* Just says that the variable is not used but should be kept
|
|
4
|
+
* No side effects.
|
|
5
|
+
*
|
|
6
|
+
* Note: It can be usefull for:
|
|
7
|
+
*
|
|
8
|
+
* 1) Suppressing eager optimization of unused imports
|
|
9
|
+
* 2) Suppressing eslint errors of unused variables in the tests
|
|
10
|
+
* 3) Keeping the type of the variable for type testing
|
|
11
|
+
*
|
|
12
|
+
* @param value any values
|
|
13
|
+
* @returns void
|
|
14
|
+
* @private within the repository
|
|
15
|
+
*/
|
|
16
|
+
export declare function keepUnused<TTypeToKeep1 = really_any, TTypeToKeep2 = really_any, TTypeToKeep3 = really_any>(...valuesToKeep: Array<really_any>): void;
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -397,6 +397,39 @@
|
|
|
397
397
|
* TODO: Escape all
|
|
398
398
|
*/
|
|
399
399
|
|
|
400
|
+
/**
|
|
401
|
+
* @@@
|
|
402
|
+
*
|
|
403
|
+
* @returns The same object as the input, but deeply frozen
|
|
404
|
+
*
|
|
405
|
+
* Note: This function mutates the object
|
|
406
|
+
*/
|
|
407
|
+
function deepFreeze(objectValue) {
|
|
408
|
+
var e_1, _a;
|
|
409
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
410
|
+
try {
|
|
411
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
412
|
+
var propertyName = propertyNames_1_1.value;
|
|
413
|
+
var value = objectValue[propertyName];
|
|
414
|
+
if (value && typeof value === 'object') {
|
|
415
|
+
deepFreeze(value);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
420
|
+
finally {
|
|
421
|
+
try {
|
|
422
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
423
|
+
}
|
|
424
|
+
finally { if (e_1) throw e_1.error; }
|
|
425
|
+
}
|
|
426
|
+
return Object.freeze(objectValue);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
430
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
431
|
+
*/
|
|
432
|
+
|
|
400
433
|
/**
|
|
401
434
|
* The maximum number of iterations for a loops
|
|
402
435
|
*/
|
|
@@ -408,11 +441,11 @@
|
|
|
408
441
|
/**
|
|
409
442
|
* The names of the parameters that are reserved for special purposes
|
|
410
443
|
*/
|
|
411
|
-
var RESERVED_PARAMETER_NAMES = [
|
|
444
|
+
var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
412
445
|
'context',
|
|
413
446
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
414
447
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
415
|
-
];
|
|
448
|
+
]);
|
|
416
449
|
/*
|
|
417
450
|
TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
418
451
|
*/
|
|
@@ -753,6 +786,7 @@
|
|
|
753
786
|
var loopLimit = LOOP_LIMIT;
|
|
754
787
|
var _loop_2 = function () {
|
|
755
788
|
if (loopLimit-- < 0) {
|
|
789
|
+
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
756
790
|
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
|
|
757
791
|
}
|
|
758
792
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
@@ -1140,37 +1174,64 @@
|
|
|
1140
1174
|
// <- [🩻]
|
|
1141
1175
|
];
|
|
1142
1176
|
|
|
1177
|
+
/**
|
|
1178
|
+
* @@@
|
|
1179
|
+
*/
|
|
1180
|
+
function deepClone(objectValue) {
|
|
1181
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
1182
|
+
/*
|
|
1183
|
+
TODO: [🧠] Is there a better implementation?
|
|
1184
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1185
|
+
> for (const propertyName of propertyNames) {
|
|
1186
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
1187
|
+
> if (value && typeof value === 'object') {
|
|
1188
|
+
> deepClone(value);
|
|
1189
|
+
> }
|
|
1190
|
+
> }
|
|
1191
|
+
> return Object.assign({}, objectValue);
|
|
1192
|
+
*/
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
1196
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1197
|
+
*/
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* @@@
|
|
1201
|
+
*
|
|
1202
|
+
* TODO: [🔼] Export with addUsage
|
|
1203
|
+
*/
|
|
1204
|
+
var ZERO_USAGE = deepFreeze({
|
|
1205
|
+
price: { value: 0 },
|
|
1206
|
+
input: {
|
|
1207
|
+
tokensCount: { value: 0 },
|
|
1208
|
+
charactersCount: { value: 0 },
|
|
1209
|
+
wordsCount: { value: 0 },
|
|
1210
|
+
sentencesCount: { value: 0 },
|
|
1211
|
+
linesCount: { value: 0 },
|
|
1212
|
+
paragraphsCount: { value: 0 },
|
|
1213
|
+
pagesCount: { value: 0 },
|
|
1214
|
+
},
|
|
1215
|
+
output: {
|
|
1216
|
+
tokensCount: { value: 0 },
|
|
1217
|
+
charactersCount: { value: 0 },
|
|
1218
|
+
wordsCount: { value: 0 },
|
|
1219
|
+
sentencesCount: { value: 0 },
|
|
1220
|
+
linesCount: { value: 0 },
|
|
1221
|
+
paragraphsCount: { value: 0 },
|
|
1222
|
+
pagesCount: { value: 0 },
|
|
1223
|
+
},
|
|
1224
|
+
});
|
|
1143
1225
|
/**
|
|
1144
1226
|
* Function `addUsage` will add multiple usages into one
|
|
1145
1227
|
*
|
|
1146
|
-
* Note: If you provide 0 values, it returns
|
|
1228
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1147
1229
|
*/
|
|
1148
1230
|
function addUsage() {
|
|
1149
1231
|
var usageItems = [];
|
|
1150
1232
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1151
1233
|
usageItems[_i] = arguments[_i];
|
|
1152
1234
|
}
|
|
1153
|
-
var initialStructure = {
|
|
1154
|
-
price: { value: 0 },
|
|
1155
|
-
input: {
|
|
1156
|
-
tokensCount: { value: 0 },
|
|
1157
|
-
charactersCount: { value: 0 },
|
|
1158
|
-
wordsCount: { value: 0 },
|
|
1159
|
-
sentencesCount: { value: 0 },
|
|
1160
|
-
linesCount: { value: 0 },
|
|
1161
|
-
paragraphsCount: { value: 0 },
|
|
1162
|
-
pagesCount: { value: 0 },
|
|
1163
|
-
},
|
|
1164
|
-
output: {
|
|
1165
|
-
tokensCount: { value: 0 },
|
|
1166
|
-
charactersCount: { value: 0 },
|
|
1167
|
-
wordsCount: { value: 0 },
|
|
1168
|
-
sentencesCount: { value: 0 },
|
|
1169
|
-
linesCount: { value: 0 },
|
|
1170
|
-
paragraphsCount: { value: 0 },
|
|
1171
|
-
pagesCount: { value: 0 },
|
|
1172
|
-
},
|
|
1173
|
-
};
|
|
1174
1235
|
return usageItems.reduce(function (acc, item) {
|
|
1175
1236
|
var e_1, _a, e_2, _b;
|
|
1176
1237
|
var _c;
|
|
@@ -1228,7 +1289,7 @@
|
|
|
1228
1289
|
finally { if (e_2) throw e_2.error; }
|
|
1229
1290
|
}
|
|
1230
1291
|
return acc;
|
|
1231
|
-
},
|
|
1292
|
+
}, deepClone(ZERO_USAGE));
|
|
1232
1293
|
}
|
|
1233
1294
|
|
|
1234
1295
|
/**
|
|
@@ -1305,7 +1366,7 @@
|
|
|
1305
1366
|
});
|
|
1306
1367
|
}
|
|
1307
1368
|
|
|
1308
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1369
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-12",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-12",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-12",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-12",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-12",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",expectations:{words:{min:1,max:8}},personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {content}",resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-12",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-12",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{name:"make-model-requirements",title:"Make modelRequirements",dependentParameterNames:["availableModelNames","personaDescription"],blockType:"PROMPT_TEMPLATE",expectFormat:"JSON",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-12",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1309
1370
|
|
|
1310
1371
|
var defaultDiacriticsRemovalMap = [
|
|
1311
1372
|
{
|
|
@@ -1979,11 +2040,8 @@
|
|
|
1979
2040
|
/**
|
|
1980
2041
|
* The version of the Promptbook library
|
|
1981
2042
|
*/
|
|
1982
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2043
|
+
var PROMPTBOOK_VERSION = '0.61.0-12';
|
|
1983
2044
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1984
|
-
/**
|
|
1985
|
-
* TODO: [🔼] !!! Export via `@promptbook/code`
|
|
1986
|
-
*/
|
|
1987
2045
|
|
|
1988
2046
|
/**
|
|
1989
2047
|
* Counts number of characters in the text
|
|
@@ -2116,6 +2174,20 @@
|
|
|
2116
2174
|
* TODO: [💝] Unite object for expecting amount and format
|
|
2117
2175
|
*/
|
|
2118
2176
|
|
|
2177
|
+
/**
|
|
2178
|
+
* This error type indicates that some limit was reached
|
|
2179
|
+
*/
|
|
2180
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
2181
|
+
__extends(LimitReachedError, _super);
|
|
2182
|
+
function LimitReachedError(message) {
|
|
2183
|
+
var _this = _super.call(this, message) || this;
|
|
2184
|
+
_this.name = 'LimitReachedError';
|
|
2185
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
2186
|
+
return _this;
|
|
2187
|
+
}
|
|
2188
|
+
return LimitReachedError;
|
|
2189
|
+
}(Error));
|
|
2190
|
+
|
|
2119
2191
|
/**
|
|
2120
2192
|
* Replaces parameters in template with values from parameters object
|
|
2121
2193
|
*
|
|
@@ -2132,7 +2204,7 @@
|
|
|
2132
2204
|
var loopLimit = LOOP_LIMIT;
|
|
2133
2205
|
var _loop_1 = function () {
|
|
2134
2206
|
if (loopLimit-- < 0) {
|
|
2135
|
-
throw new
|
|
2207
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
2136
2208
|
}
|
|
2137
2209
|
var precol = match.groups.precol;
|
|
2138
2210
|
var parameterName = match.groups.parameterName;
|
|
@@ -2620,6 +2692,7 @@
|
|
|
2620
2692
|
switch (_e.label) {
|
|
2621
2693
|
case 0:
|
|
2622
2694
|
if (loopLimit-- < 0) {
|
|
2695
|
+
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
2623
2696
|
throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
|
|
2624
2697
|
}
|
|
2625
2698
|
currentTemplate = unresovedTemplates.find(function (template) {
|
|
@@ -2666,7 +2739,7 @@
|
|
|
2666
2739
|
}
|
|
2667
2740
|
usage_1 = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
2668
2741
|
var result = _a.result;
|
|
2669
|
-
return (result === null || result === void 0 ? void 0 : result.usage) ||
|
|
2742
|
+
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
2670
2743
|
})), false));
|
|
2671
2744
|
return [2 /*return*/, {
|
|
2672
2745
|
isSuccessful: false,
|
|
@@ -2695,7 +2768,7 @@
|
|
|
2695
2768
|
}
|
|
2696
2769
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
2697
2770
|
var result = _a.result;
|
|
2698
|
-
return (result === null || result === void 0 ? void 0 : result.usage) ||
|
|
2771
|
+
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
2699
2772
|
})), false));
|
|
2700
2773
|
return [2 /*return*/, {
|
|
2701
2774
|
isSuccessful: true,
|
|
@@ -3021,7 +3094,7 @@
|
|
|
3021
3094
|
id: 1,
|
|
3022
3095
|
// TODO: [🍥]> date: $currentDate(),
|
|
3023
3096
|
promptbookVersion: PROMPTBOOK_VERSION,
|
|
3024
|
-
modelUsage:
|
|
3097
|
+
modelUsage: ZERO_USAGE,
|
|
3025
3098
|
};
|
|
3026
3099
|
preparations = [
|
|
3027
3100
|
// ...preparations
|
|
@@ -5609,7 +5682,10 @@
|
|
|
5609
5682
|
* Returns the same value that is passed as argument.
|
|
5610
5683
|
* No side effects.
|
|
5611
5684
|
*
|
|
5612
|
-
* Note: It can be usefull for
|
|
5685
|
+
* Note: It can be usefull for:
|
|
5686
|
+
*
|
|
5687
|
+
* 1) Leveling indentation
|
|
5688
|
+
* 2) Putting always-true or always-false conditions without getting eslint errors
|
|
5613
5689
|
*
|
|
5614
5690
|
* @param value any values
|
|
5615
5691
|
* @returns the same values
|