@promptbook/cli 0.86.5 โ 0.86.8
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/README.md +13 -8
- package/esm/index.es.js +48 -34
- package/esm/index.es.js.map +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +48 -34
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -146,17 +146,22 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
146
146
|
<tr>
|
|
147
147
|
<td><a href="https://github.com/webgptorg/book">Book language</a></td>
|
|
148
148
|
<td>
|
|
149
|
-
Book is a
|
|
149
|
+
Book is a human-understandable markup language for writing AI applications such as chatbots, knowledge bases, agents, avarars, translators, automations and more.
|
|
150
|
+
<hr>
|
|
150
151
|
There is also <a href="https://github.com/webgptorg/book-extension">a plugin for VSCode</a> to support <code>.book</code> file extension
|
|
151
152
|
</td>
|
|
152
153
|
</tr>
|
|
153
154
|
<tr>
|
|
154
155
|
<td><a href="https://github.com/webgptorg/promptbook">Promptbook Engine</a></td>
|
|
155
|
-
<td>
|
|
156
|
+
<td>
|
|
157
|
+
Promptbook engine can run applications written in Book language. It is released as <a href="https://www.npmjs.com/package/@promptbook/core#-packages-for-developers">multiple NPM packages</a> and <a href="https://hub.docker.com/r/hejny/promptbook">Docker HUB</a>
|
|
158
|
+
</td>
|
|
156
159
|
</tr>
|
|
157
160
|
<tr>
|
|
158
161
|
<td><a href="https://promptbook.studio">Promptbook Studio</a></td>
|
|
159
|
-
<td>
|
|
162
|
+
<td>
|
|
163
|
+
Promptbook.studio is a web-based editor and runner for book applications. It is still in the experimental MVP stage.
|
|
164
|
+
</td>
|
|
160
165
|
</tr>
|
|
161
166
|
</tbody>
|
|
162
167
|
</table>
|
|
@@ -175,25 +180,25 @@ And **Promptbook.studio** branded socials:
|
|
|
175
180
|
|
|
176
181
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
177
182
|
|
|
178
|
-
|
|
179
|
-
|
|
180
183
|
And **Promptujeme** sub-brand:
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
_/Subbrand for Czech clients/_
|
|
186
|
+
|
|
183
187
|
|
|
184
188
|
|
|
185
189
|
|
|
186
190
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
187
191
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
188
192
|
|
|
189
|
-
|
|
190
193
|
And **Promptbook.city** branded socials:
|
|
191
194
|
|
|
192
|
-
|
|
195
|
+
_/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
193
196
|
|
|
194
197
|
- [Instagram `@promptbook.city`](https://www.instagram.com/promptbook.city/)
|
|
195
198
|
- [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
|
|
196
199
|
|
|
200
|
+
##
|
|
201
|
+
|
|
197
202
|
|
|
198
203
|
|
|
199
204
|
|
package/esm/index.es.js
CHANGED
|
@@ -44,7 +44,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
44
44
|
* @generated
|
|
45
45
|
* @see https://github.com/webgptorg/promptbook
|
|
46
46
|
*/
|
|
47
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.86.
|
|
47
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.86.8';
|
|
48
48
|
/**
|
|
49
49
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
50
50
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -1506,9 +1506,11 @@ var FileCacheStorage = /** @class */ (function () {
|
|
|
1506
1506
|
FileCacheStorage.prototype.getFilenameForKey = function (key) {
|
|
1507
1507
|
// TODO: [๐ฌ] DRY
|
|
1508
1508
|
var name = titleToName(key);
|
|
1509
|
+
var nameStart = name.split('-', 2)[0] || 'unnamed';
|
|
1509
1510
|
var hash = sha256(hexEncoder.parse(name)).toString( /* hex */);
|
|
1510
1511
|
// <- TODO: [๐ฅฌ] Encapsulate sha256 to some private utility function
|
|
1511
|
-
return join.apply(void 0, __spreadArray(__spreadArray([this.options.rootFolderPath
|
|
1512
|
+
return join.apply(void 0, __spreadArray(__spreadArray([this.options.rootFolderPath,
|
|
1513
|
+
nameStart], __read(nameToSubfolderPath(hash /* <- TODO: [๐] Maybe add some SHA256 prefix */)), false), ["".concat(name.substring(0, MAX_FILENAME_LENGTH), ".json")], false));
|
|
1512
1514
|
};
|
|
1513
1515
|
/**
|
|
1514
1516
|
* @@@ Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
@@ -1694,13 +1696,14 @@ function cacheLlmTools(llmTools, options) {
|
|
|
1694
1696
|
return /* not await */ llmTools.listModels();
|
|
1695
1697
|
} });
|
|
1696
1698
|
var callCommonModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1697
|
-
var key, cacheItem, _a, promptResult, _b;
|
|
1699
|
+
var parameters, content, modelRequirements, key, cacheItem, _a, promptResult, _b;
|
|
1698
1700
|
return __generator(this, function (_c) {
|
|
1699
1701
|
switch (_c.label) {
|
|
1700
1702
|
case 0:
|
|
1703
|
+
parameters = prompt.parameters, content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1701
1704
|
key = titleToName(prompt.title.substring(0, MAX_FILENAME_LENGTH - 10) +
|
|
1702
1705
|
'-' +
|
|
1703
|
-
sha256(hexEncoder.parse(JSON.stringify(
|
|
1706
|
+
sha256(hexEncoder.parse(JSON.stringify({ parameters: parameters, content: content, modelRequirements: modelRequirements }))).toString( /* hex */));
|
|
1704
1707
|
if (!!isCacheReloaded) return [3 /*break*/, 2];
|
|
1705
1708
|
return [4 /*yield*/, storage.getItem(key)];
|
|
1706
1709
|
case 1:
|
|
@@ -7587,7 +7590,9 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
7587
7590
|
return __generator(this, function (_a) {
|
|
7588
7591
|
dependentParameterNames = task.dependentParameterNames;
|
|
7589
7592
|
preparedContent = undefined;
|
|
7590
|
-
if (
|
|
7593
|
+
if (task.taskType === 'PROMPT_TASK' &&
|
|
7594
|
+
knowledgePiecesCount > 0 &&
|
|
7595
|
+
!dependentParameterNames.includes('knowledge')) {
|
|
7591
7596
|
preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
7592
7597
|
// <- TODO: [๐ง ][๐งป] Cutomize shape/language/formatting of the addition to the prompt
|
|
7593
7598
|
dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
|
|
@@ -13017,31 +13022,31 @@ function isValidPipelineString(pipelineString) {
|
|
|
13017
13022
|
*/
|
|
13018
13023
|
function $getCompiledBook(tools, pipelineSource, options) {
|
|
13019
13024
|
return __awaiter(this, void 0, void 0, function () {
|
|
13020
|
-
var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, _a, pipelineJson, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson, pipelineJson;
|
|
13025
|
+
var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, _a, pipelineJson, compiledFilePath, bookcBundle, data, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson, pipelineJson;
|
|
13021
13026
|
var e_1, _b;
|
|
13022
13027
|
var _this = this;
|
|
13023
13028
|
return __generator(this, function (_c) {
|
|
13024
13029
|
switch (_c.label) {
|
|
13025
13030
|
case 0:
|
|
13026
13031
|
fs = tools.fs, fetch = tools.fetch;
|
|
13027
|
-
if (!isValidFilePath(pipelineSource)) return [3 /*break*/,
|
|
13032
|
+
if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 12];
|
|
13028
13033
|
filePathRaw = pipelineSource;
|
|
13029
13034
|
filePath = null;
|
|
13030
13035
|
filePathCandidates = [filePathRaw, "".concat(filePathRaw, ".md"), "".concat(filePathRaw, ".book"), "".concat(filePathRaw, ".book")];
|
|
13031
13036
|
filePathCandidates = __spreadArray(__spreadArray([], __read(filePathCandidates), false), __read(filePathCandidates.map(function (path) { return path.split('\\').join('/'); })), false);
|
|
13032
13037
|
_c.label = 1;
|
|
13033
13038
|
case 1:
|
|
13034
|
-
_c.trys.push([1,
|
|
13039
|
+
_c.trys.push([1, 10, 11, 12]);
|
|
13035
13040
|
filePathCandidates_1 = __values(filePathCandidates), filePathCandidates_1_1 = filePathCandidates_1.next();
|
|
13036
13041
|
_c.label = 2;
|
|
13037
13042
|
case 2:
|
|
13038
|
-
if (!!filePathCandidates_1_1.done) return [3 /*break*/,
|
|
13043
|
+
if (!!filePathCandidates_1_1.done) return [3 /*break*/, 9];
|
|
13039
13044
|
filePathCandidate = filePathCandidates_1_1.value;
|
|
13040
13045
|
return [4 /*yield*/, isFileExisting(filePathCandidate, fs)
|
|
13041
13046
|
// <- TODO: Also test that among the candidates the file is book not just any file
|
|
13042
13047
|
];
|
|
13043
13048
|
case 3:
|
|
13044
|
-
if (!_c.sent()) return [3 /*break*/,
|
|
13049
|
+
if (!_c.sent()) return [3 /*break*/, 8];
|
|
13045
13050
|
filePath = filePathCandidate;
|
|
13046
13051
|
_a = validatePipelineString;
|
|
13047
13052
|
return [4 /*yield*/, fs.readFile(filePath, 'utf-8')];
|
|
@@ -13050,23 +13055,32 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
13050
13055
|
return [4 /*yield*/, compilePipeline(pipelineString, tools, __assign({ rootDirname: process.cwd() }, options))];
|
|
13051
13056
|
case 5:
|
|
13052
13057
|
pipelineJson = _c.sent();
|
|
13053
|
-
|
|
13058
|
+
compiledFilePath = filePath.replace('.book.md', '.book').replace('.book', '.bookc');
|
|
13059
|
+
bookcBundle = new JSZip();
|
|
13060
|
+
bookcBundle.file('index.book.json', JSON.stringify([pipelineJson]));
|
|
13061
|
+
return [4 /*yield*/, bookcBundle.generateAsync({ type: 'nodebuffer', streamFiles: true })];
|
|
13054
13062
|
case 6:
|
|
13063
|
+
data = _c.sent();
|
|
13064
|
+
return [4 /*yield*/, fs.writeFile(compiledFilePath, data)];
|
|
13065
|
+
case 7:
|
|
13066
|
+
_c.sent();
|
|
13067
|
+
return [2 /*return*/, pipelineJson];
|
|
13068
|
+
case 8:
|
|
13055
13069
|
filePathCandidates_1_1 = filePathCandidates_1.next();
|
|
13056
13070
|
return [3 /*break*/, 2];
|
|
13057
|
-
case
|
|
13058
|
-
case
|
|
13071
|
+
case 9: return [3 /*break*/, 12];
|
|
13072
|
+
case 10:
|
|
13059
13073
|
e_1_1 = _c.sent();
|
|
13060
13074
|
e_1 = { error: e_1_1 };
|
|
13061
|
-
return [3 /*break*/,
|
|
13062
|
-
case
|
|
13075
|
+
return [3 /*break*/, 12];
|
|
13076
|
+
case 11:
|
|
13063
13077
|
try {
|
|
13064
13078
|
if (filePathCandidates_1_1 && !filePathCandidates_1_1.done && (_b = filePathCandidates_1.return)) _b.call(filePathCandidates_1);
|
|
13065
13079
|
}
|
|
13066
13080
|
finally { if (e_1) throw e_1.error; }
|
|
13067
13081
|
return [7 /*endfinally*/];
|
|
13068
|
-
case
|
|
13069
|
-
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/,
|
|
13082
|
+
case 12:
|
|
13083
|
+
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 16];
|
|
13070
13084
|
rootDirname = process.cwd();
|
|
13071
13085
|
_loop_1 = function (i) {
|
|
13072
13086
|
var booksDirname, collection_1, pipeline;
|
|
@@ -13117,47 +13131,47 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
13117
13131
|
});
|
|
13118
13132
|
};
|
|
13119
13133
|
i = 0;
|
|
13120
|
-
_c.label =
|
|
13121
|
-
case
|
|
13122
|
-
if (!(i < LOOP_LIMIT)) return [3 /*break*/,
|
|
13134
|
+
_c.label = 13;
|
|
13135
|
+
case 13:
|
|
13136
|
+
if (!(i < LOOP_LIMIT)) return [3 /*break*/, 16];
|
|
13123
13137
|
return [5 /*yield**/, _loop_1(i)];
|
|
13124
|
-
case
|
|
13138
|
+
case 14:
|
|
13125
13139
|
state_1 = _c.sent();
|
|
13126
13140
|
if (typeof state_1 === "object")
|
|
13127
13141
|
return [2 /*return*/, state_1.value];
|
|
13128
13142
|
switch (state_1) {
|
|
13129
|
-
case "break-up_to_root": return [3 /*break*/,
|
|
13143
|
+
case "break-up_to_root": return [3 /*break*/, 16];
|
|
13130
13144
|
}
|
|
13131
|
-
_c.label =
|
|
13132
|
-
case
|
|
13145
|
+
_c.label = 15;
|
|
13146
|
+
case 15:
|
|
13133
13147
|
i++;
|
|
13134
|
-
return [3 /*break*/,
|
|
13135
|
-
case
|
|
13136
|
-
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/,
|
|
13148
|
+
return [3 /*break*/, 13];
|
|
13149
|
+
case 16:
|
|
13150
|
+
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 20];
|
|
13137
13151
|
return [4 /*yield*/, fetch(pipelineSource)];
|
|
13138
|
-
case
|
|
13152
|
+
case 17:
|
|
13139
13153
|
response_1 = _c.sent();
|
|
13140
13154
|
if (response_1.status >= 300) {
|
|
13141
13155
|
throw new NotFoundError(spaceTrim(function (block) { return "\n Book not found on URL:\n ".concat(block(pipelineSource), "\n\n Request failed with status ").concat(block(response_1.status.toString()), " ").concat(block(response_1.statusText), "\n "); }));
|
|
13142
13156
|
}
|
|
13143
13157
|
return [4 /*yield*/, response_1.text()];
|
|
13144
|
-
case
|
|
13158
|
+
case 18:
|
|
13145
13159
|
pipelineString = _c.sent();
|
|
13146
13160
|
// console.log({ pipelineString });
|
|
13147
13161
|
if (!isValidPipelineString(pipelineString)) {
|
|
13148
13162
|
throw new NotFoundError(spaceTrim(function (block) { return "\n Book not found on URL:\n ".concat(block(pipelineSource), "\n\n Requested URL does not seem to contain a valid book\n "); }));
|
|
13149
13163
|
}
|
|
13150
13164
|
return [4 /*yield*/, compilePipeline(pipelineString, tools, __assign({ rootDirname: null }, options))];
|
|
13151
|
-
case
|
|
13165
|
+
case 19:
|
|
13152
13166
|
pipelineJson = _c.sent();
|
|
13153
13167
|
return [2 /*return*/, pipelineJson];
|
|
13154
|
-
case
|
|
13155
|
-
if (!isValidPipelineString(pipelineSource)) return [3 /*break*/,
|
|
13168
|
+
case 20:
|
|
13169
|
+
if (!isValidPipelineString(pipelineSource)) return [3 /*break*/, 22];
|
|
13156
13170
|
return [4 /*yield*/, compilePipeline(pipelineSource, tools, __assign({ rootDirname: null }, options))];
|
|
13157
|
-
case
|
|
13171
|
+
case 21:
|
|
13158
13172
|
pipelineJson = _c.sent();
|
|
13159
13173
|
return [2 /*return*/, pipelineJson];
|
|
13160
|
-
case
|
|
13174
|
+
case 22: /* not else */ throw new NotFoundError(spaceTrim(function (block) { return "\n Book not found:\n ".concat(block(pipelineSource), "\n\n Pipelines can be loaded from:\n 1) As a file ./books/write-cv.book\n 2) As a URL https://promptbook.studio/hejny/write-cv.book found in ./books folder recursively\n 2) As a URL https://promptbook.studio/hejny/write-cv.book fetched from the internet\n 3) As a string\n\n\n "); }));
|
|
13161
13175
|
}
|
|
13162
13176
|
});
|
|
13163
13177
|
});
|