@promptbook/core 0.61.0-12 → 0.61.0-14
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 +116 -44
- 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/types.index.d.ts +6 -3
- package/esm/typings/src/_packages/utils.index.d.ts +1 -1
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/esm/typings/src/config.d.ts +5 -1
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +10 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
- package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +7 -7
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -1
- package/esm/typings/src/execution/PromptResult.d.ts +14 -56
- package/esm/typings/src/execution/PromptResultUsage.d.ts +26 -0
- package/esm/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/esm/typings/src/execution/utils/addUsage.d.ts +58 -2
- package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/esm/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +10 -2
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -7
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
- package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +53 -14
- package/esm/typings/src/types/ModelVariant.d.ts +14 -0
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +2 -4
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +45 -1
- package/esm/typings/src/types/typeAliases.d.ts +11 -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/normalization/parseKeywords.d.ts +2 -1
- package/{umd/typings/src/utils/organization/TODO.d.ts → esm/typings/src/utils/organization/TODO_any.d.ts} +1 -1
- package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -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/utils/organization/really_any.d.ts +1 -1
- package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- package/esm/typings/src/version.d.ts +0 -3
- package/package.json +1 -1
- package/umd/index.umd.js +116 -44
- 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/types.index.d.ts +6 -3
- package/umd/typings/src/_packages/utils.index.d.ts +1 -1
- package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/umd/typings/src/config.d.ts +5 -1
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
- package/umd/typings/src/conversion/validation/_importPipeline.d.ts +10 -1
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
- package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +7 -7
- package/umd/typings/src/execution/PipelineExecutor.d.ts +1 -1
- package/umd/typings/src/execution/PromptResult.d.ts +14 -56
- package/umd/typings/src/execution/PromptResultUsage.d.ts +26 -0
- package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
- package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +10 -2
- package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +1 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -4
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -7
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -6
- package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
- package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/umd/typings/src/types/ModelRequirements.d.ts +53 -14
- package/umd/typings/src/types/ModelVariant.d.ts +14 -0
- package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +2 -4
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/umd/typings/src/types/Prompt.d.ts +45 -1
- package/umd/typings/src/types/typeAliases.d.ts +11 -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/normalization/parseKeywords.d.ts +2 -1
- package/{esm/typings/src/utils/organization/TODO.d.ts → umd/typings/src/utils/organization/TODO_any.d.ts} +1 -1
- package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -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/utils/organization/really_any.d.ts +1 -1
- package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- package/umd/typings/src/version.d.ts +0 -3
- 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/utils/organization/keepImported.d.ts +0 -12
- package/umd/typings/src/utils/organization/notUsing.d.ts +0 -12
- /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts → conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
- /package/umd/typings/src/{execution/addPromptResultUsage.test.d.ts → conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
- /package/umd/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -390,6 +390,39 @@ function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
|
|
|
390
390
|
* TODO: Escape all
|
|
391
391
|
*/
|
|
392
392
|
|
|
393
|
+
/**
|
|
394
|
+
* @@@
|
|
395
|
+
*
|
|
396
|
+
* @returns The same object as the input, but deeply frozen
|
|
397
|
+
*
|
|
398
|
+
* Note: This function mutates the object
|
|
399
|
+
*/
|
|
400
|
+
function deepFreeze(objectValue) {
|
|
401
|
+
var e_1, _a;
|
|
402
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
403
|
+
try {
|
|
404
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
405
|
+
var propertyName = propertyNames_1_1.value;
|
|
406
|
+
var value = objectValue[propertyName];
|
|
407
|
+
if (value && typeof value === 'object') {
|
|
408
|
+
deepFreeze(value);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
413
|
+
finally {
|
|
414
|
+
try {
|
|
415
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
416
|
+
}
|
|
417
|
+
finally { if (e_1) throw e_1.error; }
|
|
418
|
+
}
|
|
419
|
+
return Object.freeze(objectValue);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
423
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
424
|
+
*/
|
|
425
|
+
|
|
393
426
|
/**
|
|
394
427
|
* The maximum number of iterations for a loops
|
|
395
428
|
*/
|
|
@@ -401,11 +434,11 @@ var MAX_PARALLEL_COUNT = 5;
|
|
|
401
434
|
/**
|
|
402
435
|
* The names of the parameters that are reserved for special purposes
|
|
403
436
|
*/
|
|
404
|
-
var RESERVED_PARAMETER_NAMES = [
|
|
437
|
+
var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
405
438
|
'context',
|
|
406
439
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
407
440
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
408
|
-
];
|
|
441
|
+
]);
|
|
409
442
|
/*
|
|
410
443
|
TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
411
444
|
*/
|
|
@@ -746,6 +779,7 @@ function validatePipeline(pipeline) {
|
|
|
746
779
|
var loopLimit = LOOP_LIMIT;
|
|
747
780
|
var _loop_2 = function () {
|
|
748
781
|
if (loopLimit-- < 0) {
|
|
782
|
+
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
749
783
|
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
|
|
750
784
|
}
|
|
751
785
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
@@ -781,7 +815,7 @@ function validatePipeline(pipeline) {
|
|
|
781
815
|
* > * It checks:
|
|
782
816
|
* > * - it has a valid structure
|
|
783
817
|
* > * - ...
|
|
784
|
-
* > ex port function validatePipeline(promptbook:
|
|
818
|
+
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
785
819
|
*/
|
|
786
820
|
/**
|
|
787
821
|
* TODO: [🧠][🐣] !!!! Validate that all samples match expectations
|
|
@@ -1133,37 +1167,64 @@ var BlockTypes = [
|
|
|
1133
1167
|
// <- [🩻]
|
|
1134
1168
|
];
|
|
1135
1169
|
|
|
1170
|
+
/**
|
|
1171
|
+
* @@@
|
|
1172
|
+
*/
|
|
1173
|
+
function deepClone(objectValue) {
|
|
1174
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
1175
|
+
/*
|
|
1176
|
+
TODO: [🧠] Is there a better implementation?
|
|
1177
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1178
|
+
> for (const propertyName of propertyNames) {
|
|
1179
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
1180
|
+
> if (value && typeof value === 'object') {
|
|
1181
|
+
> deepClone(value);
|
|
1182
|
+
> }
|
|
1183
|
+
> }
|
|
1184
|
+
> return Object.assign({}, objectValue);
|
|
1185
|
+
*/
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
1189
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1190
|
+
*/
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* @@@
|
|
1194
|
+
*
|
|
1195
|
+
* TODO: [🔼] Export with addUsage
|
|
1196
|
+
*/
|
|
1197
|
+
var ZERO_USAGE = deepFreeze({
|
|
1198
|
+
price: { value: 0 },
|
|
1199
|
+
input: {
|
|
1200
|
+
tokensCount: { value: 0 },
|
|
1201
|
+
charactersCount: { value: 0 },
|
|
1202
|
+
wordsCount: { value: 0 },
|
|
1203
|
+
sentencesCount: { value: 0 },
|
|
1204
|
+
linesCount: { value: 0 },
|
|
1205
|
+
paragraphsCount: { value: 0 },
|
|
1206
|
+
pagesCount: { value: 0 },
|
|
1207
|
+
},
|
|
1208
|
+
output: {
|
|
1209
|
+
tokensCount: { value: 0 },
|
|
1210
|
+
charactersCount: { value: 0 },
|
|
1211
|
+
wordsCount: { value: 0 },
|
|
1212
|
+
sentencesCount: { value: 0 },
|
|
1213
|
+
linesCount: { value: 0 },
|
|
1214
|
+
paragraphsCount: { value: 0 },
|
|
1215
|
+
pagesCount: { value: 0 },
|
|
1216
|
+
},
|
|
1217
|
+
});
|
|
1136
1218
|
/**
|
|
1137
1219
|
* Function `addUsage` will add multiple usages into one
|
|
1138
1220
|
*
|
|
1139
|
-
* Note: If you provide 0 values, it returns
|
|
1221
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1140
1222
|
*/
|
|
1141
1223
|
function addUsage() {
|
|
1142
1224
|
var usageItems = [];
|
|
1143
1225
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1144
1226
|
usageItems[_i] = arguments[_i];
|
|
1145
1227
|
}
|
|
1146
|
-
var initialStructure = {
|
|
1147
|
-
price: { value: 0 },
|
|
1148
|
-
input: {
|
|
1149
|
-
tokensCount: { value: 0 },
|
|
1150
|
-
charactersCount: { value: 0 },
|
|
1151
|
-
wordsCount: { value: 0 },
|
|
1152
|
-
sentencesCount: { value: 0 },
|
|
1153
|
-
linesCount: { value: 0 },
|
|
1154
|
-
paragraphsCount: { value: 0 },
|
|
1155
|
-
pagesCount: { value: 0 },
|
|
1156
|
-
},
|
|
1157
|
-
output: {
|
|
1158
|
-
tokensCount: { value: 0 },
|
|
1159
|
-
charactersCount: { value: 0 },
|
|
1160
|
-
wordsCount: { value: 0 },
|
|
1161
|
-
sentencesCount: { value: 0 },
|
|
1162
|
-
linesCount: { value: 0 },
|
|
1163
|
-
paragraphsCount: { value: 0 },
|
|
1164
|
-
pagesCount: { value: 0 },
|
|
1165
|
-
},
|
|
1166
|
-
};
|
|
1167
1228
|
return usageItems.reduce(function (acc, item) {
|
|
1168
1229
|
var e_1, _a, e_2, _b;
|
|
1169
1230
|
var _c;
|
|
@@ -1221,7 +1282,7 @@ function addUsage() {
|
|
|
1221
1282
|
finally { if (e_2) throw e_2.error; }
|
|
1222
1283
|
}
|
|
1223
1284
|
return acc;
|
|
1224
|
-
},
|
|
1285
|
+
}, deepClone(ZERO_USAGE));
|
|
1225
1286
|
}
|
|
1226
1287
|
|
|
1227
1288
|
/**
|
|
@@ -1298,7 +1359,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1298
1359
|
});
|
|
1299
1360
|
}
|
|
1300
1361
|
|
|
1301
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1362
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-13",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-13",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-13",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-13",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-13",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-13",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-13",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-13",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"}];
|
|
1302
1363
|
|
|
1303
1364
|
var defaultDiacriticsRemovalMap = [
|
|
1304
1365
|
{
|
|
@@ -1972,11 +2033,8 @@ function arrayableToArray(input) {
|
|
|
1972
2033
|
/**
|
|
1973
2034
|
* The version of the Promptbook library
|
|
1974
2035
|
*/
|
|
1975
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2036
|
+
var PROMPTBOOK_VERSION = '0.61.0-13';
|
|
1976
2037
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1977
|
-
/**
|
|
1978
|
-
* TODO: [🔼] !!! Export via `@promptbook/code`
|
|
1979
|
-
*/
|
|
1980
2038
|
|
|
1981
2039
|
/**
|
|
1982
2040
|
* Counts number of characters in the text
|
|
@@ -2109,6 +2167,20 @@ function isPassingExpectations(expectations, value) {
|
|
|
2109
2167
|
* TODO: [💝] Unite object for expecting amount and format
|
|
2110
2168
|
*/
|
|
2111
2169
|
|
|
2170
|
+
/**
|
|
2171
|
+
* This error type indicates that some limit was reached
|
|
2172
|
+
*/
|
|
2173
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
2174
|
+
__extends(LimitReachedError, _super);
|
|
2175
|
+
function LimitReachedError(message) {
|
|
2176
|
+
var _this = _super.call(this, message) || this;
|
|
2177
|
+
_this.name = 'LimitReachedError';
|
|
2178
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
2179
|
+
return _this;
|
|
2180
|
+
}
|
|
2181
|
+
return LimitReachedError;
|
|
2182
|
+
}(Error));
|
|
2183
|
+
|
|
2112
2184
|
/**
|
|
2113
2185
|
* Replaces parameters in template with values from parameters object
|
|
2114
2186
|
*
|
|
@@ -2125,7 +2197,7 @@ function replaceParameters(template, parameters) {
|
|
|
2125
2197
|
var loopLimit = LOOP_LIMIT;
|
|
2126
2198
|
var _loop_1 = function () {
|
|
2127
2199
|
if (loopLimit-- < 0) {
|
|
2128
|
-
throw new
|
|
2200
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
2129
2201
|
}
|
|
2130
2202
|
var precol = match.groups.precol;
|
|
2131
2203
|
var parameterName = match.groups.parameterName;
|
|
@@ -2613,6 +2685,7 @@ function createPipelineExecutor(options) {
|
|
|
2613
2685
|
switch (_e.label) {
|
|
2614
2686
|
case 0:
|
|
2615
2687
|
if (loopLimit-- < 0) {
|
|
2688
|
+
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
2616
2689
|
throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
|
|
2617
2690
|
}
|
|
2618
2691
|
currentTemplate = unresovedTemplates.find(function (template) {
|
|
@@ -2659,7 +2732,7 @@ function createPipelineExecutor(options) {
|
|
|
2659
2732
|
}
|
|
2660
2733
|
usage_1 = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
2661
2734
|
var result = _a.result;
|
|
2662
|
-
return (result === null || result === void 0 ? void 0 : result.usage) ||
|
|
2735
|
+
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
2663
2736
|
})), false));
|
|
2664
2737
|
return [2 /*return*/, {
|
|
2665
2738
|
isSuccessful: false,
|
|
@@ -2688,7 +2761,7 @@ function createPipelineExecutor(options) {
|
|
|
2688
2761
|
}
|
|
2689
2762
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
2690
2763
|
var result = _a.result;
|
|
2691
|
-
return (result === null || result === void 0 ? void 0 : result.usage) ||
|
|
2764
|
+
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
2692
2765
|
})), false));
|
|
2693
2766
|
return [2 /*return*/, {
|
|
2694
2767
|
isSuccessful: true,
|
|
@@ -3014,7 +3087,7 @@ function preparePipeline(pipeline, options) {
|
|
|
3014
3087
|
id: 1,
|
|
3015
3088
|
// TODO: [🍥]> date: $currentDate(),
|
|
3016
3089
|
promptbookVersion: PROMPTBOOK_VERSION,
|
|
3017
|
-
modelUsage:
|
|
3090
|
+
modelUsage: ZERO_USAGE,
|
|
3018
3091
|
};
|
|
3019
3092
|
preparations = [
|
|
3020
3093
|
// ...preparations
|
|
@@ -3632,16 +3705,12 @@ var jokerCommandParser = {
|
|
|
3632
3705
|
},
|
|
3633
3706
|
};
|
|
3634
3707
|
|
|
3635
|
-
var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
3636
3708
|
/**
|
|
3637
|
-
*
|
|
3638
|
-
*
|
|
3639
|
-
*
|
|
3640
|
-
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3641
|
-
* TODO: Maybe figure out better word than "variant"
|
|
3642
|
-
* TODO: Add here more requirement options like max context size, max tokens, etc.
|
|
3643
|
-
* TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
|
|
3709
|
+
* @@@
|
|
3710
|
+
*
|
|
3711
|
+
* @private for `ModelVariant` and `modelCommandParser`
|
|
3644
3712
|
*/
|
|
3713
|
+
var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
3645
3714
|
|
|
3646
3715
|
/**
|
|
3647
3716
|
* Parses the model command
|
|
@@ -5602,7 +5671,10 @@ function escapeMarkdownBlock(value) {
|
|
|
5602
5671
|
* Returns the same value that is passed as argument.
|
|
5603
5672
|
* No side effects.
|
|
5604
5673
|
*
|
|
5605
|
-
* Note: It can be usefull for
|
|
5674
|
+
* Note: It can be usefull for:
|
|
5675
|
+
*
|
|
5676
|
+
* 1) Leveling indentation
|
|
5677
|
+
* 2) Putting always-true or always-false conditions without getting eslint errors
|
|
5606
5678
|
*
|
|
5607
5679
|
* @param value any values
|
|
5608
5680
|
* @returns the same values
|