@promptbook/core 0.59.0-25 → 0.59.0-27
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 +15 -24
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/{umd/typings/src/conversion/validation/validatePromptbookJson.d.ts → esm/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
- package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +15 -24
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/core.index.d.ts +2 -2
- package/{esm/typings/src/conversion/validation/validatePromptbookJson.d.ts → umd/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
- package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +1 -1
- /package/esm/typings/src/conversion/validation/{validatePromptbookJson-logicErrors.test.d.ts → validatePromptbook-logicErrors.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/validation/{validatePromptbookJson.test.d.ts → validatePromptbook.test.d.ts} +0 -0
- /package/umd/typings/src/conversion/validation/{validatePromptbookJson-logicErrors.test.d.ts → validatePromptbook-logicErrors.test.d.ts} +0 -0
- /package/umd/typings/src/conversion/validation/{validatePromptbookJson.test.d.ts → validatePromptbook.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
return PromptbookSyntaxError;
|
|
207
207
|
}(Error));
|
|
208
208
|
|
|
209
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
209
|
+
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-26",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"],executionType:"PROMPT_TEMPLATE",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"}],knowledge:[]}];
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
212
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
* @returns the same promptbook if it is logically valid
|
|
320
320
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
321
321
|
*/
|
|
322
|
-
function
|
|
322
|
+
function validatePromptbook(promptbook) {
|
|
323
323
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
324
324
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
325
325
|
if (promptbook.promptbookUrl !== undefined) {
|
|
@@ -383,8 +383,7 @@
|
|
|
383
383
|
throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
|
|
384
384
|
}
|
|
385
385
|
definedParameters.add(template.resultingParameterName);
|
|
386
|
-
if (template.executionType === 'PROMPT_TEMPLATE' &&
|
|
387
|
-
(template.modelRequirements.modelVariant === undefined)) {
|
|
386
|
+
if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
388
387
|
throw new PromptbookLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
|
|
389
388
|
}
|
|
390
389
|
if (template.jokers && template.jokers.length > 0) {
|
|
@@ -454,7 +453,7 @@
|
|
|
454
453
|
var loopLimit = LOOP_LIMIT;
|
|
455
454
|
var _loop_2 = function () {
|
|
456
455
|
if (loopLimit-- < 0) {
|
|
457
|
-
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `
|
|
456
|
+
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
|
|
458
457
|
}
|
|
459
458
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
460
459
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -489,7 +488,7 @@
|
|
|
489
488
|
* > * It checks:
|
|
490
489
|
* > * - it has a valid structure
|
|
491
490
|
* > * - ...
|
|
492
|
-
* > ex port function
|
|
491
|
+
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
493
492
|
*/
|
|
494
493
|
|
|
495
494
|
/**
|
|
@@ -531,7 +530,7 @@
|
|
|
531
530
|
/**
|
|
532
531
|
* The version of the Promptbook library
|
|
533
532
|
*/
|
|
534
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
533
|
+
var PROMPTBOOK_VERSION = '0.59.0-26';
|
|
535
534
|
|
|
536
535
|
/**
|
|
537
536
|
* Function `addUsage` will add multiple usages into one
|
|
@@ -1093,7 +1092,7 @@
|
|
|
1093
1092
|
var _this = this;
|
|
1094
1093
|
var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
1095
1094
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
1096
|
-
|
|
1095
|
+
validatePromptbook(promptbook);
|
|
1097
1096
|
var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1098
1097
|
function executeSingleTemplate(currentTemplate) {
|
|
1099
1098
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1524,7 +1523,7 @@
|
|
|
1524
1523
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
1525
1524
|
});
|
|
1526
1525
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
1527
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during
|
|
1526
|
+
throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
|
|
1528
1527
|
case 1:
|
|
1529
1528
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
1530
1529
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -1879,7 +1878,7 @@
|
|
|
1879
1878
|
if (promptbook.promptbookUrl === undefined) {
|
|
1880
1879
|
throw new PromptbookReferenceError(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
|
|
1881
1880
|
}
|
|
1882
|
-
|
|
1881
|
+
validatePromptbook(promptbook);
|
|
1883
1882
|
// Note: [🦄]
|
|
1884
1883
|
if (this.library.has(promptbook.promptbookUrl) &&
|
|
1885
1884
|
promptbookJsonToString(promptbook) !==
|
|
@@ -1944,11 +1943,7 @@
|
|
|
1944
1943
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1945
1944
|
promptbooks[_i] = arguments[_i];
|
|
1946
1945
|
}
|
|
1947
|
-
return
|
|
1948
|
-
return __generator(this, function (_a) {
|
|
1949
|
-
return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1950
|
-
});
|
|
1951
|
-
});
|
|
1946
|
+
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1952
1947
|
}
|
|
1953
1948
|
|
|
1954
1949
|
/* tslint:disable */
|
|
@@ -2014,9 +2009,7 @@
|
|
|
2014
2009
|
switch (_b.label) {
|
|
2015
2010
|
case 0:
|
|
2016
2011
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2017
|
-
|
|
2018
|
-
case 1:
|
|
2019
|
-
library = _b.sent();
|
|
2012
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2020
2013
|
promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
|
|
2021
2014
|
executor = createPromptbookExecutor({
|
|
2022
2015
|
promptbook: promptbook,
|
|
@@ -2028,7 +2021,7 @@
|
|
|
2028
2021
|
},
|
|
2029
2022
|
});
|
|
2030
2023
|
return [4 /*yield*/, executor({ content: content })];
|
|
2031
|
-
case
|
|
2024
|
+
case 1:
|
|
2032
2025
|
result = _b.sent();
|
|
2033
2026
|
assertsExecutionSuccessful(result);
|
|
2034
2027
|
outputParameters = result.outputParameters;
|
|
@@ -2067,7 +2060,7 @@
|
|
|
2067
2060
|
}];
|
|
2068
2061
|
});
|
|
2069
2062
|
}); }))];
|
|
2070
|
-
case
|
|
2063
|
+
case 2:
|
|
2071
2064
|
knowledge = _b.sent();
|
|
2072
2065
|
return [2 /*return*/, knowledge];
|
|
2073
2066
|
}
|
|
@@ -3476,9 +3469,7 @@
|
|
|
3476
3469
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3477
3470
|
case 1:
|
|
3478
3471
|
promptbookSources = _a.sent();
|
|
3479
|
-
|
|
3480
|
-
case 2:
|
|
3481
|
-
library = _a.sent();
|
|
3472
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
|
|
3482
3473
|
return [2 /*return*/];
|
|
3483
3474
|
}
|
|
3484
3475
|
});
|
|
@@ -4128,7 +4119,7 @@
|
|
|
4128
4119
|
exports.promptbookJsonToString = promptbookJsonToString;
|
|
4129
4120
|
exports.promptbookStringToJson = promptbookStringToJson;
|
|
4130
4121
|
exports.usageToWorktime = usageToWorktime;
|
|
4131
|
-
exports.
|
|
4122
|
+
exports.validatePromptbook = validatePromptbook;
|
|
4132
4123
|
|
|
4133
4124
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4134
4125
|
|