@promptbook/core 0.59.0-25 → 0.59.0-26
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/esm/index.es.js
CHANGED
|
@@ -199,7 +199,7 @@ var PromptbookSyntaxError = /** @class */ (function (_super) {
|
|
|
199
199
|
return PromptbookSyntaxError;
|
|
200
200
|
}(Error));
|
|
201
201
|
|
|
202
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
202
|
+
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-25",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:[]}];
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -312,7 +312,7 @@ function isValidUrl(url) {
|
|
|
312
312
|
* @returns the same promptbook if it is logically valid
|
|
313
313
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
314
314
|
*/
|
|
315
|
-
function
|
|
315
|
+
function validatePromptbook(promptbook) {
|
|
316
316
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
317
317
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
318
318
|
if (promptbook.promptbookUrl !== undefined) {
|
|
@@ -376,8 +376,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
376
376
|
throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
|
|
377
377
|
}
|
|
378
378
|
definedParameters.add(template.resultingParameterName);
|
|
379
|
-
if (template.executionType === 'PROMPT_TEMPLATE' &&
|
|
380
|
-
(template.modelRequirements.modelVariant === undefined)) {
|
|
379
|
+
if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
381
380
|
throw new PromptbookLogicError(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 ")));
|
|
382
381
|
}
|
|
383
382
|
if (template.jokers && template.jokers.length > 0) {
|
|
@@ -447,7 +446,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
447
446
|
var loopLimit = LOOP_LIMIT;
|
|
448
447
|
var _loop_2 = function () {
|
|
449
448
|
if (loopLimit-- < 0) {
|
|
450
|
-
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `
|
|
449
|
+
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
|
|
451
450
|
}
|
|
452
451
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
453
452
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -482,7 +481,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
482
481
|
* > * It checks:
|
|
483
482
|
* > * - it has a valid structure
|
|
484
483
|
* > * - ...
|
|
485
|
-
* > ex port function
|
|
484
|
+
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
486
485
|
*/
|
|
487
486
|
|
|
488
487
|
/**
|
|
@@ -524,7 +523,7 @@ function isValidJsonString(value /* <-[👨⚖️] */) {
|
|
|
524
523
|
/**
|
|
525
524
|
* The version of the Promptbook library
|
|
526
525
|
*/
|
|
527
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
526
|
+
var PROMPTBOOK_VERSION = '0.59.0-25';
|
|
528
527
|
|
|
529
528
|
/**
|
|
530
529
|
* Function `addUsage` will add multiple usages into one
|
|
@@ -1086,7 +1085,7 @@ function createPromptbookExecutor(options) {
|
|
|
1086
1085
|
var _this = this;
|
|
1087
1086
|
var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
1088
1087
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
1089
|
-
|
|
1088
|
+
validatePromptbook(promptbook);
|
|
1090
1089
|
var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1091
1090
|
function executeSingleTemplate(currentTemplate) {
|
|
1092
1091
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1517,7 +1516,7 @@ function createPromptbookExecutor(options) {
|
|
|
1517
1516
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
1518
1517
|
});
|
|
1519
1518
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
1520
|
-
throw new UnexpectedError(spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during
|
|
1519
|
+
throw new UnexpectedError(spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
|
|
1521
1520
|
case 1:
|
|
1522
1521
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
1523
1522
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -1872,7 +1871,7 @@ var SimplePromptbookLibrary = /** @class */ (function () {
|
|
|
1872
1871
|
if (promptbook.promptbookUrl === undefined) {
|
|
1873
1872
|
throw new PromptbookReferenceError(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 ")));
|
|
1874
1873
|
}
|
|
1875
|
-
|
|
1874
|
+
validatePromptbook(promptbook);
|
|
1876
1875
|
// Note: [🦄]
|
|
1877
1876
|
if (this.library.has(promptbook.promptbookUrl) &&
|
|
1878
1877
|
promptbookJsonToString(promptbook) !==
|
|
@@ -1937,11 +1936,7 @@ function createLibraryFromJson() {
|
|
|
1937
1936
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1938
1937
|
promptbooks[_i] = arguments[_i];
|
|
1939
1938
|
}
|
|
1940
|
-
return
|
|
1941
|
-
return __generator(this, function (_a) {
|
|
1942
|
-
return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1943
|
-
});
|
|
1944
|
-
});
|
|
1939
|
+
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1945
1940
|
}
|
|
1946
1941
|
|
|
1947
1942
|
/* tslint:disable */
|
|
@@ -2007,9 +2002,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2007
2002
|
switch (_b.label) {
|
|
2008
2003
|
case 0:
|
|
2009
2004
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2010
|
-
|
|
2011
|
-
case 1:
|
|
2012
|
-
library = _b.sent();
|
|
2005
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2013
2006
|
promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
|
|
2014
2007
|
executor = createPromptbookExecutor({
|
|
2015
2008
|
promptbook: promptbook,
|
|
@@ -2021,7 +2014,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2021
2014
|
},
|
|
2022
2015
|
});
|
|
2023
2016
|
return [4 /*yield*/, executor({ content: content })];
|
|
2024
|
-
case
|
|
2017
|
+
case 1:
|
|
2025
2018
|
result = _b.sent();
|
|
2026
2019
|
assertsExecutionSuccessful(result);
|
|
2027
2020
|
outputParameters = result.outputParameters;
|
|
@@ -2060,7 +2053,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2060
2053
|
}];
|
|
2061
2054
|
});
|
|
2062
2055
|
}); }))];
|
|
2063
|
-
case
|
|
2056
|
+
case 2:
|
|
2064
2057
|
knowledge = _b.sent();
|
|
2065
2058
|
return [2 /*return*/, knowledge];
|
|
2066
2059
|
}
|
|
@@ -3469,9 +3462,7 @@ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
|
3469
3462
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3470
3463
|
case 1:
|
|
3471
3464
|
promptbookSources = _a.sent();
|
|
3472
|
-
|
|
3473
|
-
case 2:
|
|
3474
|
-
library = _a.sent();
|
|
3465
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
|
|
3475
3466
|
return [2 /*return*/];
|
|
3476
3467
|
}
|
|
3477
3468
|
});
|
|
@@ -4090,5 +4081,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
4090
4081
|
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
4091
4082
|
*/
|
|
4092
4083
|
|
|
4093
|
-
export { CallbackInterfaceTools, ExecutionReportStringOptionsDefaults, ExecutionTypes, ExpectError, MultipleLlmExecutionTools, PROMPTBOOK_VERSION, PromptbookExecutionError, PromptbookLibraryError, PromptbookLogicError, PromptbookNotFoundError, PromptbookReferenceError, PromptbookSyntaxError, SimplePromptInterfaceTools, TemplateError, UnexpectedError, addUsage, assertsExecutionSuccessful, checkExpectations, createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createPromptbookExecutor, createSublibrary, executionReportJsonToString, isPassingExpectations, libraryToJson, prepareKnowledgeFromMarkdown, prettifyPromptbookString, promptbookJsonToString, promptbookStringToJson, usageToWorktime,
|
|
4084
|
+
export { CallbackInterfaceTools, ExecutionReportStringOptionsDefaults, ExecutionTypes, ExpectError, MultipleLlmExecutionTools, PROMPTBOOK_VERSION, PromptbookExecutionError, PromptbookLibraryError, PromptbookLogicError, PromptbookNotFoundError, PromptbookReferenceError, PromptbookSyntaxError, SimplePromptInterfaceTools, TemplateError, UnexpectedError, addUsage, assertsExecutionSuccessful, checkExpectations, createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createPromptbookExecutor, createSublibrary, executionReportJsonToString, isPassingExpectations, libraryToJson, prepareKnowledgeFromMarkdown, prettifyPromptbookString, promptbookJsonToString, promptbookStringToJson, usageToWorktime, validatePromptbook };
|
|
4094
4085
|
//# sourceMappingURL=index.es.js.map
|