@promptbook/node 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 +2 -2
- 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
|
@@ -13,7 +13,7 @@ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
|
13
13
|
* @returns the same promptbook if it is logically valid
|
|
14
14
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function validatePromptbook(promptbook: PromptbookJson): PromptbookJson;
|
|
17
17
|
/**
|
|
18
18
|
* TODO: [🧠] Work with promptbookVersion
|
|
19
19
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
@@ -23,5 +23,5 @@ export declare function validatePromptbookJson(promptbook: PromptbookJson): Prom
|
|
|
23
23
|
* > * It checks:
|
|
24
24
|
* > * - it has a valid structure
|
|
25
25
|
* > * - ...
|
|
26
|
-
* > ex port function
|
|
26
|
+
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
27
27
|
*/
|
|
@@ -9,4 +9,4 @@ import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
|
|
|
9
9
|
* @param promptbookSources
|
|
10
10
|
* @returns PromptbookLibrary
|
|
11
11
|
*/
|
|
12
|
-
export declare function createLibraryFromJson(...promptbooks: Array<PromptbookJson>):
|
|
12
|
+
export declare function createLibraryFromJson(...promptbooks: Array<PromptbookJson>): SimplePromptbookLibrary;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.59.0-
|
|
3
|
+
"version": "0.59.0-27",
|
|
4
4
|
"description": "Library to supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@promptbook/core": "0.59.0-
|
|
52
|
+
"@promptbook/core": "0.59.0-27"
|
|
53
53
|
},
|
|
54
54
|
"main": "./umd/index.umd.js",
|
|
55
55
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
return PromptbookSyntaxError;
|
|
153
153
|
}(Error));
|
|
154
154
|
|
|
155
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
155
|
+
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:[]}];
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
* @returns the same promptbook if it is logically valid
|
|
261
261
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
262
262
|
*/
|
|
263
|
-
function
|
|
263
|
+
function validatePromptbook(promptbook) {
|
|
264
264
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
265
265
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
266
266
|
if (promptbook.promptbookUrl !== undefined) {
|
|
@@ -324,8 +324,7 @@
|
|
|
324
324
|
throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
|
|
325
325
|
}
|
|
326
326
|
definedParameters.add(template.resultingParameterName);
|
|
327
|
-
if (template.executionType === 'PROMPT_TEMPLATE' &&
|
|
328
|
-
(template.modelRequirements.modelVariant === undefined)) {
|
|
327
|
+
if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
329
328
|
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 ")));
|
|
330
329
|
}
|
|
331
330
|
if (template.jokers && template.jokers.length > 0) {
|
|
@@ -395,7 +394,7 @@
|
|
|
395
394
|
var loopLimit = LOOP_LIMIT;
|
|
396
395
|
var _loop_2 = function () {
|
|
397
396
|
if (loopLimit-- < 0) {
|
|
398
|
-
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `
|
|
397
|
+
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
|
|
399
398
|
}
|
|
400
399
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
401
400
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -430,7 +429,7 @@
|
|
|
430
429
|
* > * It checks:
|
|
431
430
|
* > * - it has a valid structure
|
|
432
431
|
* > * - ...
|
|
433
|
-
* > ex port function
|
|
432
|
+
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
434
433
|
*/
|
|
435
434
|
|
|
436
435
|
/**
|
|
@@ -472,7 +471,7 @@
|
|
|
472
471
|
/**
|
|
473
472
|
* The version of the Promptbook library
|
|
474
473
|
*/
|
|
475
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
474
|
+
var PROMPTBOOK_VERSION = '0.59.0-26';
|
|
476
475
|
|
|
477
476
|
/**
|
|
478
477
|
* Function `addUsage` will add multiple usages into one
|
|
@@ -1013,7 +1012,7 @@
|
|
|
1013
1012
|
var _this = this;
|
|
1014
1013
|
var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
1015
1014
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
1016
|
-
|
|
1015
|
+
validatePromptbook(promptbook);
|
|
1017
1016
|
var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1018
1017
|
function executeSingleTemplate(currentTemplate) {
|
|
1019
1018
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1444,7 +1443,7 @@
|
|
|
1444
1443
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
1445
1444
|
});
|
|
1446
1445
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
1447
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during
|
|
1446
|
+
throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
|
|
1448
1447
|
case 1:
|
|
1449
1448
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
1450
1449
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -1831,7 +1830,7 @@
|
|
|
1831
1830
|
if (promptbook.promptbookUrl === undefined) {
|
|
1832
1831
|
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 ")));
|
|
1833
1832
|
}
|
|
1834
|
-
|
|
1833
|
+
validatePromptbook(promptbook);
|
|
1835
1834
|
// Note: [🦄]
|
|
1836
1835
|
if (this.library.has(promptbook.promptbookUrl) &&
|
|
1837
1836
|
promptbookJsonToString(promptbook) !==
|
|
@@ -1896,11 +1895,7 @@
|
|
|
1896
1895
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1897
1896
|
promptbooks[_i] = arguments[_i];
|
|
1898
1897
|
}
|
|
1899
|
-
return
|
|
1900
|
-
return __generator(this, function (_a) {
|
|
1901
|
-
return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1902
|
-
});
|
|
1903
|
-
});
|
|
1898
|
+
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1904
1899
|
}
|
|
1905
1900
|
|
|
1906
1901
|
/* tslint:disable */
|
|
@@ -1966,9 +1961,7 @@
|
|
|
1966
1961
|
switch (_b.label) {
|
|
1967
1962
|
case 0:
|
|
1968
1963
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
1969
|
-
|
|
1970
|
-
case 1:
|
|
1971
|
-
library = _b.sent();
|
|
1964
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
1972
1965
|
promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
|
|
1973
1966
|
executor = createPromptbookExecutor({
|
|
1974
1967
|
promptbook: promptbook,
|
|
@@ -1980,7 +1973,7 @@
|
|
|
1980
1973
|
},
|
|
1981
1974
|
});
|
|
1982
1975
|
return [4 /*yield*/, executor({ content: content })];
|
|
1983
|
-
case
|
|
1976
|
+
case 1:
|
|
1984
1977
|
result = _b.sent();
|
|
1985
1978
|
assertsExecutionSuccessful(result);
|
|
1986
1979
|
outputParameters = result.outputParameters;
|
|
@@ -2019,7 +2012,7 @@
|
|
|
2019
2012
|
}];
|
|
2020
2013
|
});
|
|
2021
2014
|
}); }))];
|
|
2022
|
-
case
|
|
2015
|
+
case 2:
|
|
2023
2016
|
knowledge = _b.sent();
|
|
2024
2017
|
return [2 /*return*/, knowledge];
|
|
2025
2018
|
}
|
|
@@ -3202,9 +3195,7 @@
|
|
|
3202
3195
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3203
3196
|
case 1:
|
|
3204
3197
|
promptbookSources = _a.sent();
|
|
3205
|
-
|
|
3206
|
-
case 2:
|
|
3207
|
-
library = _a.sent();
|
|
3198
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
|
|
3208
3199
|
return [2 /*return*/];
|
|
3209
3200
|
}
|
|
3210
3201
|
});
|
|
@@ -3348,7 +3339,7 @@
|
|
|
3348
3339
|
if (!isCrashOnError) {
|
|
3349
3340
|
// Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
|
|
3350
3341
|
// But be handled in current try-catch block
|
|
3351
|
-
|
|
3342
|
+
validatePromptbook(promptbook);
|
|
3352
3343
|
}
|
|
3353
3344
|
// Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
|
|
3354
3345
|
promptbooks.push(promptbook);
|