@promptbook/core 0.84.0-9 → 0.84.0
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 +21 -9
- package/esm/index.es.js +394 -192
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +12 -2
- package/esm/typings/src/_packages/deepseek.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/_packages/wizzard.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/about.d.ts +4 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +13 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +3 -1
- package/esm/typings/src/config.d.ts +27 -1
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +9 -0
- package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +9 -0
- package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +14 -0
- package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +14 -0
- package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +15 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +3 -2
- package/esm/typings/src/pipeline/prompt-notation.d.ts +18 -5
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +5 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +1 -0
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +1 -0
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +3 -0
- package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +10 -0
- package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +1 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +7 -1
- package/package.json +8 -15
- package/umd/index.umd.js +400 -193
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -3,13 +3,13 @@ import { format } from 'prettier';
|
|
|
3
3
|
import parserHtml from 'prettier/parser-html';
|
|
4
4
|
import { forTime } from 'waitasecond';
|
|
5
5
|
import { unparse, parse } from 'papaparse';
|
|
6
|
-
import { join, basename } from 'path';
|
|
7
|
-
import { SHA256 } from 'crypto-js';
|
|
8
6
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
9
|
-
import
|
|
7
|
+
import sha256 from 'crypto-js/sha256';
|
|
8
|
+
import { basename, join, dirname } from 'path';
|
|
9
|
+
import { SHA256 } from 'crypto-js';
|
|
10
|
+
import { lookup, extension } from 'mime-types';
|
|
10
11
|
import moment from 'moment';
|
|
11
12
|
import colors from 'colors';
|
|
12
|
-
import sha256 from 'crypto-js/sha256';
|
|
13
13
|
|
|
14
14
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
15
15
|
/**
|
|
@@ -25,7 +25,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-21';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -178,22 +178,94 @@ function collectionToJson(collection) {
|
|
|
178
178
|
*/
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
181
|
+
* Checks if value is valid email
|
|
182
182
|
*
|
|
183
183
|
* @public exported from `@promptbook/utils`
|
|
184
184
|
*/
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
function isValidEmail(email) {
|
|
186
|
+
if (typeof email !== 'string') {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
if (email.split('\n').length > 1) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return /^.+@.+\..+$/.test(email);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Tests if given string is valid URL.
|
|
197
|
+
*
|
|
198
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
199
|
+
* @public exported from `@promptbook/utils`
|
|
200
|
+
*/
|
|
201
|
+
function isValidFilePath(filename) {
|
|
202
|
+
if (typeof filename !== 'string') {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (filename.split('\n').length > 1) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (filename.split(' ').length >
|
|
209
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
213
|
+
// Absolute Unix path: /hello.txt
|
|
214
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
215
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
188
216
|
return true;
|
|
189
217
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
218
|
+
// Absolute Windows path: /hello.txt
|
|
219
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
220
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
// Relative path: ./hello.txt
|
|
224
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
225
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
// Allow paths like foo/hello
|
|
229
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
230
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
// Allow paths like hello.book
|
|
234
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
235
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* TODO: [🍏] Implement for MacOs
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Tests if given string is valid URL.
|
|
246
|
+
*
|
|
247
|
+
* Note: Dataurl are considered perfectly valid.
|
|
248
|
+
* Note: There are two simmilar functions:
|
|
249
|
+
* - `isValidUrl` which tests any URL
|
|
250
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
251
|
+
*
|
|
252
|
+
* @public exported from `@promptbook/utils`
|
|
253
|
+
*/
|
|
254
|
+
function isValidUrl(url) {
|
|
255
|
+
if (typeof url !== 'string') {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
if (url.startsWith('blob:')) {
|
|
260
|
+
url = url.replace(/^blob:/, '');
|
|
193
261
|
}
|
|
194
|
-
|
|
262
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
263
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
195
264
|
return false;
|
|
196
265
|
}
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
197
269
|
return false;
|
|
198
270
|
}
|
|
199
271
|
}
|
|
@@ -217,6 +289,27 @@ var ParseError = /** @class */ (function (_super) {
|
|
|
217
289
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
218
290
|
*/
|
|
219
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
294
|
+
*
|
|
295
|
+
* @public exported from `@promptbook/utils`
|
|
296
|
+
*/
|
|
297
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
298
|
+
try {
|
|
299
|
+
JSON.parse(value);
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
if (!(error instanceof Error)) {
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
if (error.message.includes('Unexpected token')) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
220
313
|
/**
|
|
221
314
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
222
315
|
* It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
|
|
@@ -230,6 +323,15 @@ function validatePipelineString(pipelineString) {
|
|
|
230
323
|
if (isValidJsonString(pipelineString)) {
|
|
231
324
|
throw new ParseError('Expected a book, but got a JSON string');
|
|
232
325
|
}
|
|
326
|
+
else if (isValidUrl(pipelineString)) {
|
|
327
|
+
throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
|
|
328
|
+
}
|
|
329
|
+
else if (isValidFilePath(pipelineString)) {
|
|
330
|
+
throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
|
|
331
|
+
}
|
|
332
|
+
else if (isValidEmail(pipelineString)) {
|
|
333
|
+
throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
|
|
334
|
+
}
|
|
233
335
|
// <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
|
|
234
336
|
return pipelineString;
|
|
235
337
|
}
|
|
@@ -570,6 +672,24 @@ var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
|
|
|
570
672
|
* @public exported from `@promptbook/core`
|
|
571
673
|
*/
|
|
572
674
|
var DEFAULT_TASK_TITLE = "Task";
|
|
675
|
+
/**
|
|
676
|
+
* When the title of the prompt task is not provided, the default title is used
|
|
677
|
+
*
|
|
678
|
+
* @public exported from `@promptbook/core`
|
|
679
|
+
*/
|
|
680
|
+
var DEFAULT_PROMPT_TASK_TITLE = "Prompt";
|
|
681
|
+
/**
|
|
682
|
+
* When the pipeline is flat and no name of return parameter is provided, this name is used
|
|
683
|
+
*
|
|
684
|
+
* @public exported from `@promptbook/core`
|
|
685
|
+
*/
|
|
686
|
+
var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
|
|
687
|
+
/**
|
|
688
|
+
* Maximum file size limit
|
|
689
|
+
*
|
|
690
|
+
* @public exported from `@promptbook/core`
|
|
691
|
+
*/
|
|
692
|
+
var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
573
693
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
574
694
|
/**
|
|
575
695
|
* The maximum number of iterations for a loops
|
|
@@ -650,6 +770,14 @@ var DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
|
|
|
650
770
|
*/
|
|
651
771
|
var DEFAULT_BOOKS_DIRNAME = './books';
|
|
652
772
|
// <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
773
|
+
/**
|
|
774
|
+
* Where to store the temporary downloads
|
|
775
|
+
*
|
|
776
|
+
* Note: When the folder does not exist, it is created recursively
|
|
777
|
+
*
|
|
778
|
+
* @public exported from `@promptbook/core`
|
|
779
|
+
*/
|
|
780
|
+
var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
653
781
|
/**
|
|
654
782
|
* Where to store the cache of executions for promptbook CLI
|
|
655
783
|
*
|
|
@@ -657,7 +785,7 @@ var DEFAULT_BOOKS_DIRNAME = './books';
|
|
|
657
785
|
*
|
|
658
786
|
* @public exported from `@promptbook/core`
|
|
659
787
|
*/
|
|
660
|
-
var
|
|
788
|
+
var DEFAULT_EXECUTION_CACHE_DIRNAME = './.promptbook/execution-cache';
|
|
661
789
|
/**
|
|
662
790
|
* Where to store the scrape cache
|
|
663
791
|
*
|
|
@@ -1183,35 +1311,6 @@ function isUrlOnPrivateNetwork(url) {
|
|
|
1183
1311
|
return isHostnameOnPrivateNetwork(url.hostname);
|
|
1184
1312
|
}
|
|
1185
1313
|
|
|
1186
|
-
/**
|
|
1187
|
-
* Tests if given string is valid URL.
|
|
1188
|
-
*
|
|
1189
|
-
* Note: Dataurl are considered perfectly valid.
|
|
1190
|
-
* Note: There are two simmilar functions:
|
|
1191
|
-
* - `isValidUrl` which tests any URL
|
|
1192
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1193
|
-
*
|
|
1194
|
-
* @public exported from `@promptbook/utils`
|
|
1195
|
-
*/
|
|
1196
|
-
function isValidUrl(url) {
|
|
1197
|
-
if (typeof url !== 'string') {
|
|
1198
|
-
return false;
|
|
1199
|
-
}
|
|
1200
|
-
try {
|
|
1201
|
-
if (url.startsWith('blob:')) {
|
|
1202
|
-
url = url.replace(/^blob:/, '');
|
|
1203
|
-
}
|
|
1204
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
1205
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1206
|
-
return false;
|
|
1207
|
-
}
|
|
1208
|
-
return true;
|
|
1209
|
-
}
|
|
1210
|
-
catch (error) {
|
|
1211
|
-
return false;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1314
|
/**
|
|
1216
1315
|
* Tests if given string is valid pipeline URL URL.
|
|
1217
1316
|
*
|
|
@@ -2170,12 +2269,28 @@ function deserializeError(error) {
|
|
|
2170
2269
|
/**
|
|
2171
2270
|
* Asserts that the execution of a Promptbook is successful
|
|
2172
2271
|
*
|
|
2272
|
+
* Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
|
|
2273
|
+
*
|
|
2173
2274
|
* @param executionResult - The partial result of the Promptbook execution
|
|
2174
2275
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2175
2276
|
* @public exported from `@promptbook/core`
|
|
2176
2277
|
*/
|
|
2177
2278
|
function assertsExecutionSuccessful(executionResult) {
|
|
2178
|
-
var
|
|
2279
|
+
var e_1, _a;
|
|
2280
|
+
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
|
|
2281
|
+
try {
|
|
2282
|
+
for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
|
|
2283
|
+
var warning = warnings_1_1.value;
|
|
2284
|
+
console.warn(warning.message);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2288
|
+
finally {
|
|
2289
|
+
try {
|
|
2290
|
+
if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
|
|
2291
|
+
}
|
|
2292
|
+
finally { if (e_1) throw e_1.error; }
|
|
2293
|
+
}
|
|
2179
2294
|
if (isSuccessful === true) {
|
|
2180
2295
|
return;
|
|
2181
2296
|
}
|
|
@@ -3185,7 +3300,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
3185
3300
|
if (!(error_1 instanceof Error) || error_1 instanceof UnexpectedError) {
|
|
3186
3301
|
throw error_1;
|
|
3187
3302
|
}
|
|
3188
|
-
errors.push(error_1);
|
|
3303
|
+
errors.push({ llmExecutionTools: llmExecutionTools, error: error_1 });
|
|
3189
3304
|
return [3 /*break*/, 13];
|
|
3190
3305
|
case 13:
|
|
3191
3306
|
_b = _a.next();
|
|
@@ -3212,7 +3327,10 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
3212
3327
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3213
3328
|
// 3) ...
|
|
3214
3329
|
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
3215
|
-
.map(function (
|
|
3330
|
+
.map(function (_a, i) {
|
|
3331
|
+
var error = _a.error, llmExecutionTools = _a.llmExecutionTools;
|
|
3332
|
+
return "".concat(i + 1, ") **").concat(llmExecutionTools.title, "** thrown **").concat(error.name || 'Error', ":** ").concat(error.message);
|
|
3333
|
+
})
|
|
3216
3334
|
.join('\n')), "\n\n "); }));
|
|
3217
3335
|
}
|
|
3218
3336
|
else if (this.llmExecutionTools.length === 0) {
|
|
@@ -5660,6 +5778,15 @@ function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
|
5660
5778
|
* TODO: [🐱🐉][🧠] Make some smart crop NOT source-i-m-pavol-a-develop-... BUT source-i-m-pavol-a-developer-...
|
|
5661
5779
|
*/
|
|
5662
5780
|
|
|
5781
|
+
/**
|
|
5782
|
+
* @@@
|
|
5783
|
+
*
|
|
5784
|
+
* @private for `FileCacheStorage`
|
|
5785
|
+
*/
|
|
5786
|
+
function nameToSubfolderPath(name) {
|
|
5787
|
+
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
5788
|
+
}
|
|
5789
|
+
|
|
5663
5790
|
/**
|
|
5664
5791
|
* Convert file extension to mime type
|
|
5665
5792
|
*
|
|
@@ -5716,53 +5843,55 @@ function isFileExisting(filename, fs) {
|
|
|
5716
5843
|
*/
|
|
5717
5844
|
|
|
5718
5845
|
/**
|
|
5719
|
-
*
|
|
5846
|
+
* Convert mime type to file extension
|
|
5720
5847
|
*
|
|
5721
|
-
* Note:
|
|
5848
|
+
* Note: If the mime type is invalid, `null` is returned
|
|
5849
|
+
*
|
|
5850
|
+
* @private within the repository
|
|
5851
|
+
*/
|
|
5852
|
+
function mimeTypeToExtension(value) {
|
|
5853
|
+
return extension(value) || null;
|
|
5854
|
+
}
|
|
5855
|
+
|
|
5856
|
+
/**
|
|
5857
|
+
* Removes emojis from a string and fix whitespaces
|
|
5858
|
+
*
|
|
5859
|
+
* @param text with emojis
|
|
5860
|
+
* @returns text without emojis
|
|
5722
5861
|
* @public exported from `@promptbook/utils`
|
|
5723
5862
|
*/
|
|
5724
|
-
function
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
}
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
if (filename.split(' ').length >
|
|
5732
|
-
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
5733
|
-
return false;
|
|
5734
|
-
}
|
|
5735
|
-
var filenameSlashes = filename.split('\\').join('/');
|
|
5736
|
-
// Absolute Unix path: /hello.txt
|
|
5737
|
-
if (/^(\/)/i.test(filenameSlashes)) {
|
|
5738
|
-
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
5739
|
-
return true;
|
|
5740
|
-
}
|
|
5741
|
-
// Absolute Windows path: /hello.txt
|
|
5742
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
5743
|
-
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
5744
|
-
return true;
|
|
5745
|
-
}
|
|
5746
|
-
// Relative path: ./hello.txt
|
|
5747
|
-
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
5748
|
-
// console.log(filename, 'Relative path: ./hello.txt');
|
|
5749
|
-
return true;
|
|
5750
|
-
}
|
|
5751
|
-
// Allow paths like foo/hello
|
|
5752
|
-
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
5753
|
-
// console.log(filename, 'Allow paths like foo/hello');
|
|
5754
|
-
return true;
|
|
5755
|
-
}
|
|
5756
|
-
// Allow paths like hello.book
|
|
5757
|
-
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
5758
|
-
// console.log(filename, 'Allow paths like hello.book');
|
|
5759
|
-
return true;
|
|
5760
|
-
}
|
|
5761
|
-
return false;
|
|
5863
|
+
function removeEmojis(text) {
|
|
5864
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
5865
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
5866
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
5867
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
5868
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
5869
|
+
return text;
|
|
5762
5870
|
}
|
|
5871
|
+
|
|
5763
5872
|
/**
|
|
5764
|
-
*
|
|
5873
|
+
* @@@
|
|
5874
|
+
*
|
|
5875
|
+
* @param value @@@
|
|
5876
|
+
* @returns @@@
|
|
5877
|
+
* @example @@@
|
|
5878
|
+
* @public exported from `@promptbook/utils`
|
|
5765
5879
|
*/
|
|
5880
|
+
function titleToName(value) {
|
|
5881
|
+
if (isValidUrl(value)) {
|
|
5882
|
+
value = value.replace(/^https?:\/\//, '');
|
|
5883
|
+
value = value.replace(/\.html$/, '');
|
|
5884
|
+
}
|
|
5885
|
+
else if (isValidFilePath(value)) {
|
|
5886
|
+
value = basename(value);
|
|
5887
|
+
// Note: Keeping extension in the name
|
|
5888
|
+
}
|
|
5889
|
+
value = value.split('/').join('-');
|
|
5890
|
+
value = removeEmojis(value);
|
|
5891
|
+
value = normalizeToKebabCase(value);
|
|
5892
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
5893
|
+
return value;
|
|
5894
|
+
}
|
|
5766
5895
|
|
|
5767
5896
|
/**
|
|
5768
5897
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -5799,9 +5928,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
5799
5928
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5800
5929
|
var _a;
|
|
5801
5930
|
return __awaiter(this, void 0, void 0, function () {
|
|
5802
|
-
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5803
|
-
return __generator(this, function (
|
|
5804
|
-
switch (
|
|
5931
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
|
|
5932
|
+
return __generator(this, function (_h) {
|
|
5933
|
+
switch (_h.label) {
|
|
5805
5934
|
case 0:
|
|
5806
5935
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
5807
5936
|
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
@@ -5810,54 +5939,76 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5810
5939
|
if (!name) {
|
|
5811
5940
|
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
5812
5941
|
}
|
|
5813
|
-
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/,
|
|
5942
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 5];
|
|
5814
5943
|
url = knowledgeSourceContent;
|
|
5815
5944
|
return [4 /*yield*/, fetch(url)];
|
|
5816
5945
|
case 1:
|
|
5817
|
-
response_1 =
|
|
5946
|
+
response_1 = _h.sent();
|
|
5818
5947
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5948
|
+
if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
|
|
5949
|
+
return [2 /*return*/, {
|
|
5950
|
+
source: name,
|
|
5951
|
+
filename: null,
|
|
5952
|
+
url: url,
|
|
5953
|
+
mimeType: mimeType,
|
|
5954
|
+
/*
|
|
5955
|
+
TODO: [🥽]
|
|
5956
|
+
> async asBlob() {
|
|
5957
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5958
|
+
> const content = await response.blob();
|
|
5959
|
+
> return content;
|
|
5960
|
+
> },
|
|
5961
|
+
*/
|
|
5962
|
+
asJson: function () {
|
|
5963
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5964
|
+
var content;
|
|
5965
|
+
return __generator(this, function (_a) {
|
|
5966
|
+
switch (_a.label) {
|
|
5967
|
+
case 0: return [4 /*yield*/, response_1.json()];
|
|
5968
|
+
case 1:
|
|
5969
|
+
content = _a.sent();
|
|
5970
|
+
return [2 /*return*/, content];
|
|
5971
|
+
}
|
|
5972
|
+
});
|
|
5842
5973
|
});
|
|
5843
|
-
}
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
}
|
|
5974
|
+
},
|
|
5975
|
+
asText: function () {
|
|
5976
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5977
|
+
var content;
|
|
5978
|
+
return __generator(this, function (_a) {
|
|
5979
|
+
switch (_a.label) {
|
|
5980
|
+
case 0: return [4 /*yield*/, response_1.text()];
|
|
5981
|
+
case 1:
|
|
5982
|
+
content = _a.sent();
|
|
5983
|
+
return [2 /*return*/, content];
|
|
5984
|
+
}
|
|
5985
|
+
});
|
|
5855
5986
|
});
|
|
5856
|
-
}
|
|
5857
|
-
}
|
|
5858
|
-
|
|
5987
|
+
},
|
|
5988
|
+
}];
|
|
5989
|
+
}
|
|
5990
|
+
basename = url.split('/').pop() || titleToName(url);
|
|
5991
|
+
hash = sha256(hexEncoder.parse(url)).toString( /* hex */);
|
|
5992
|
+
rootDirname_1 = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
5993
|
+
filepath = join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
|
|
5994
|
+
return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
|
|
5859
5995
|
case 2:
|
|
5860
|
-
|
|
5996
|
+
_h.sent();
|
|
5997
|
+
_g = (_f = Buffer).from;
|
|
5998
|
+
return [4 /*yield*/, response_1.arrayBuffer()];
|
|
5999
|
+
case 3:
|
|
6000
|
+
fileContent = _g.apply(_f, [_h.sent()]);
|
|
6001
|
+
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
6002
|
+
throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
|
|
6003
|
+
}
|
|
6004
|
+
return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
|
|
6005
|
+
case 4:
|
|
6006
|
+
_h.sent();
|
|
6007
|
+
// TODO: [💵] Check the file security
|
|
6008
|
+
// TODO: [🧹][🧠] Delete the file after the scraping is done
|
|
6009
|
+
return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
|
|
6010
|
+
case 5:
|
|
6011
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
|
|
5861
6012
|
if (tools.fs === undefined) {
|
|
5862
6013
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
5863
6014
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -5870,8 +6021,8 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5870
6021
|
fileExtension = getFileExtension(filename_1);
|
|
5871
6022
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
5872
6023
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5873
|
-
case
|
|
5874
|
-
if (!(
|
|
6024
|
+
case 6:
|
|
6025
|
+
if (!(_h.sent())) {
|
|
5875
6026
|
throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
5876
6027
|
}
|
|
5877
6028
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -5917,7 +6068,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5917
6068
|
});
|
|
5918
6069
|
},
|
|
5919
6070
|
}];
|
|
5920
|
-
case
|
|
6071
|
+
case 7: return [2 /*return*/, {
|
|
5921
6072
|
source: name,
|
|
5922
6073
|
filename: null,
|
|
5923
6074
|
url: null,
|
|
@@ -7028,22 +7179,6 @@ function normalizeTo_camelCase(text, _isFirstLetterCapital) {
|
|
|
7028
7179
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
7029
7180
|
*/
|
|
7030
7181
|
|
|
7031
|
-
/**
|
|
7032
|
-
* Removes emojis from a string and fix whitespaces
|
|
7033
|
-
*
|
|
7034
|
-
* @param text with emojis
|
|
7035
|
-
* @returns text without emojis
|
|
7036
|
-
* @public exported from `@promptbook/utils`
|
|
7037
|
-
*/
|
|
7038
|
-
function removeEmojis(text) {
|
|
7039
|
-
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
7040
|
-
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
7041
|
-
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
7042
|
-
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
7043
|
-
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
7044
|
-
return text;
|
|
7045
|
-
}
|
|
7046
|
-
|
|
7047
7182
|
/**
|
|
7048
7183
|
* Removes quotes from a string
|
|
7049
7184
|
*
|
|
@@ -8903,7 +9038,10 @@ var QuickChatbotHla = {
|
|
|
8903
9038
|
description: 'Chatbot response',
|
|
8904
9039
|
isInput: false,
|
|
8905
9040
|
isOutput: true,
|
|
8906
|
-
exampleValues: [
|
|
9041
|
+
exampleValues: [
|
|
9042
|
+
'Hello, how can I help you?',
|
|
9043
|
+
// <- TODO: [🧠] Make this dynamic, async, prepare-phase HLAs
|
|
9044
|
+
],
|
|
8907
9045
|
});
|
|
8908
9046
|
// TODO: Use spaceTrim in multiline strings
|
|
8909
9047
|
$pipelineJson.tasks.push({
|
|
@@ -8991,12 +9129,15 @@ function isFlatPipeline(pipelineString) {
|
|
|
8991
9129
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
8992
9130
|
pipelineString = spaceTrim(pipelineString);
|
|
8993
9131
|
var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
8994
|
-
|
|
8995
|
-
|
|
9132
|
+
//const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
|
|
9133
|
+
var isBacktickBlockUsed = pipelineString.includes('```');
|
|
9134
|
+
var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
|
|
9135
|
+
var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
|
|
9136
|
+
// TODO: [🧉] Also (double)check
|
|
8996
9137
|
// > const usedCommands
|
|
8997
9138
|
// > const isBlocksUsed
|
|
8998
9139
|
// > const returnStatementCount
|
|
8999
|
-
var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement
|
|
9140
|
+
var isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
|
|
9000
9141
|
return isFlat;
|
|
9001
9142
|
}
|
|
9002
9143
|
|
|
@@ -9010,9 +9151,26 @@ function deflatePipeline(pipelineString) {
|
|
|
9010
9151
|
return pipelineString;
|
|
9011
9152
|
}
|
|
9012
9153
|
var pipelineStringLines = pipelineString.split('\n');
|
|
9013
|
-
var
|
|
9154
|
+
var potentialReturnStatement = pipelineStringLines.pop();
|
|
9155
|
+
var returnStatement;
|
|
9156
|
+
if (/(-|=)>\s*\{.*\}/.test(potentialReturnStatement)) {
|
|
9157
|
+
// Note: Last line is return statement
|
|
9158
|
+
returnStatement = potentialReturnStatement;
|
|
9159
|
+
}
|
|
9160
|
+
else {
|
|
9161
|
+
// Note: Last line is not a return statement
|
|
9162
|
+
returnStatement = "-> {".concat(DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, "}");
|
|
9163
|
+
pipelineStringLines.push(potentialReturnStatement);
|
|
9164
|
+
}
|
|
9014
9165
|
var prompt = spaceTrim(pipelineStringLines.join('\n'));
|
|
9015
|
-
|
|
9166
|
+
var quotedPrompt;
|
|
9167
|
+
if (prompt.split('\n').length <= 1) {
|
|
9168
|
+
quotedPrompt = "> ".concat(prompt);
|
|
9169
|
+
}
|
|
9170
|
+
else {
|
|
9171
|
+
quotedPrompt = spaceTrim(function (block) { return "\n ```\n ".concat(block(prompt.split('`').join('\\`')), "\n ```\n "); });
|
|
9172
|
+
}
|
|
9173
|
+
pipelineString = validatePipelineString(spaceTrim(function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ").concat(block(quotedPrompt), "\n\n ").concat(returnStatement, "\n "); }));
|
|
9016
9174
|
// <- TODO: Maybe use book` notation
|
|
9017
9175
|
return pipelineString;
|
|
9018
9176
|
}
|
|
@@ -9235,30 +9393,6 @@ function flattenMarkdown(markdown) {
|
|
|
9235
9393
|
* NOW we are working just with markdown string and its good enough
|
|
9236
9394
|
*/
|
|
9237
9395
|
|
|
9238
|
-
/**
|
|
9239
|
-
* @@@
|
|
9240
|
-
*
|
|
9241
|
-
* @param value @@@
|
|
9242
|
-
* @returns @@@
|
|
9243
|
-
* @example @@@
|
|
9244
|
-
* @public exported from `@promptbook/utils`
|
|
9245
|
-
*/
|
|
9246
|
-
function titleToName(value) {
|
|
9247
|
-
if (isValidUrl(value)) {
|
|
9248
|
-
value = value.replace(/^https?:\/\//, '');
|
|
9249
|
-
value = value.replace(/\.html$/, '');
|
|
9250
|
-
}
|
|
9251
|
-
else if (isValidFilePath(value)) {
|
|
9252
|
-
value = basename(value);
|
|
9253
|
-
// Note: Keeping extension in the name
|
|
9254
|
-
}
|
|
9255
|
-
value = value.split('/').join('-');
|
|
9256
|
-
value = removeEmojis(value);
|
|
9257
|
-
value = normalizeToKebabCase(value);
|
|
9258
|
-
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
9259
|
-
return value;
|
|
9260
|
-
}
|
|
9261
|
-
|
|
9262
9396
|
/**
|
|
9263
9397
|
* Compile pipeline from string (markdown) format to JSON format synchronously
|
|
9264
9398
|
*
|
|
@@ -10380,6 +10514,9 @@ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
|
|
|
10380
10514
|
* @public exported from `@promptbook/utils`
|
|
10381
10515
|
*/
|
|
10382
10516
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
10517
|
+
/**
|
|
10518
|
+
* TODO: [☑]
|
|
10519
|
+
*/
|
|
10383
10520
|
|
|
10384
10521
|
/**
|
|
10385
10522
|
* Creates a message with all registered LLM tools
|
|
@@ -10459,10 +10596,11 @@ function $registeredLlmToolsMessage() {
|
|
|
10459
10596
|
// <- Note: [🗨]
|
|
10460
10597
|
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isFullyConfigured: isFullyConfigured, isPartiallyConfigured: isPartiallyConfigured });
|
|
10461
10598
|
});
|
|
10599
|
+
var usedEnvMessage = "Unknown `.env` file" ;
|
|
10462
10600
|
if (metadata.length === 0) {
|
|
10463
|
-
return "No LLM providers are available.";
|
|
10601
|
+
return spaceTrim(function (block) { return "\n No LLM providers are available.\n\n ".concat(block(usedEnvMessage), "\n "); });
|
|
10464
10602
|
}
|
|
10465
|
-
return spaceTrim(function (block) { return "\n Relevant environment variables:\n ".concat(block(Object.keys(env)
|
|
10603
|
+
return spaceTrim(function (block) { return "\n\n ".concat(block(usedEnvMessage), "\n\n Relevant environment variables:\n ").concat(block(Object.keys(env)
|
|
10466
10604
|
.filter(function (envVariableName) {
|
|
10467
10605
|
return metadata.some(function (_a) {
|
|
10468
10606
|
var envVariables = _a.envVariables;
|
|
@@ -10910,6 +11048,58 @@ var _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
10910
11048
|
* @public exported from `@promptbook/utils`
|
|
10911
11049
|
*/
|
|
10912
11050
|
var $isRunningInJest = new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefined;\n } catch (e) {\n return false;\n }\n");
|
|
11051
|
+
/**
|
|
11052
|
+
* TODO: [☑]
|
|
11053
|
+
*/
|
|
11054
|
+
|
|
11055
|
+
/**
|
|
11056
|
+
* Registration of LLM provider metadata
|
|
11057
|
+
*
|
|
11058
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
11059
|
+
*
|
|
11060
|
+
* @public exported from `@promptbook/core`
|
|
11061
|
+
* @public exported from `@promptbook/wizzard`
|
|
11062
|
+
* @public exported from `@promptbook/cli`
|
|
11063
|
+
*/
|
|
11064
|
+
var _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
11065
|
+
title: 'Deepseek',
|
|
11066
|
+
packageName: '@promptbook/deepseek',
|
|
11067
|
+
className: 'DeepseekExecutionTools',
|
|
11068
|
+
envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
|
|
11069
|
+
getBoilerplateConfiguration: function () {
|
|
11070
|
+
return {
|
|
11071
|
+
title: 'Deepseek (boilerplate)',
|
|
11072
|
+
packageName: '@promptbook/deepseek',
|
|
11073
|
+
className: 'DeepseekExecutionTools',
|
|
11074
|
+
options: {
|
|
11075
|
+
apiKey: 'AI',
|
|
11076
|
+
},
|
|
11077
|
+
};
|
|
11078
|
+
},
|
|
11079
|
+
createConfigurationFromEnv: function (env) {
|
|
11080
|
+
if ($isRunningInJest()
|
|
11081
|
+
// <- TODO: Maybe check `env.JEST_WORKER_ID` directly here or pass `env` into `$isRunningInJest`
|
|
11082
|
+
) {
|
|
11083
|
+
// Note: [🔘] Maybe same problem as Gemini
|
|
11084
|
+
return null;
|
|
11085
|
+
}
|
|
11086
|
+
// Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
|
|
11087
|
+
if (typeof env.DEEPSEEK_GENERATIVE_AI_API_KEY === 'string') {
|
|
11088
|
+
return {
|
|
11089
|
+
title: 'Deepseek (from env)',
|
|
11090
|
+
packageName: '@promptbook/deepseek',
|
|
11091
|
+
className: 'DeepseekExecutionTools',
|
|
11092
|
+
options: {
|
|
11093
|
+
apiKey: env.DEEPSEEK_GENERATIVE_AI_API_KEY,
|
|
11094
|
+
},
|
|
11095
|
+
};
|
|
11096
|
+
}
|
|
11097
|
+
return null;
|
|
11098
|
+
},
|
|
11099
|
+
});
|
|
11100
|
+
/**
|
|
11101
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11102
|
+
*/
|
|
10913
11103
|
|
|
10914
11104
|
/**
|
|
10915
11105
|
* Registration of LLM provider metadata
|
|
@@ -11075,13 +11265,14 @@ function isValidPipelineString(pipelineString) {
|
|
|
11075
11265
|
/**
|
|
11076
11266
|
* Tag function for notating a prompt as template literal
|
|
11077
11267
|
*
|
|
11078
|
-
* Note: There are
|
|
11268
|
+
* Note: There are 3 similar functions:
|
|
11079
11269
|
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
|
|
11080
|
-
*
|
|
11270
|
+
* 2) `promptTemplate` alias for `prompt`
|
|
11271
|
+
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11081
11272
|
*
|
|
11082
|
-
* @param strings
|
|
11083
|
-
* @param values
|
|
11084
|
-
* @returns the
|
|
11273
|
+
* @param strings
|
|
11274
|
+
* @param values
|
|
11275
|
+
* @returns the prompt string
|
|
11085
11276
|
* @public exported from `@promptbook/utils`
|
|
11086
11277
|
*/
|
|
11087
11278
|
function prompt(strings) {
|
|
@@ -11092,10 +11283,14 @@ function prompt(strings) {
|
|
|
11092
11283
|
if (values.length === 0) {
|
|
11093
11284
|
return spaceTrim(strings.join(''));
|
|
11094
11285
|
}
|
|
11286
|
+
var stringsWithHiddenParameters = strings.map(function (stringsItem) {
|
|
11287
|
+
// TODO: [0] DRY
|
|
11288
|
+
return stringsItem.split('{').join("".concat(REPLACING_NONCE, "beginbracket")).split('}').join("".concat(REPLACING_NONCE, "endbracket"));
|
|
11289
|
+
});
|
|
11095
11290
|
var placeholderParameterNames = values.map(function (value, i) { return "".concat(REPLACING_NONCE).concat(i); });
|
|
11096
11291
|
var parameters = Object.fromEntries(values.map(function (value, i) { return [placeholderParameterNames[i], value]; }));
|
|
11097
11292
|
// Combine strings and values
|
|
11098
|
-
var pipelineString =
|
|
11293
|
+
var pipelineString = stringsWithHiddenParameters.reduce(function (result, stringsItem, i) {
|
|
11099
11294
|
return placeholderParameterNames[i] === undefined
|
|
11100
11295
|
? "".concat(result).concat(stringsItem)
|
|
11101
11296
|
: "".concat(result).concat(stringsItem, "{").concat(placeholderParameterNames[i], "}");
|
|
@@ -11111,6 +11306,12 @@ function prompt(strings) {
|
|
|
11111
11306
|
console.error({ pipelineString: pipelineString, parameters: parameters, placeholderParameterNames: placeholderParameterNames, error: error });
|
|
11112
11307
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Internal error in prompt template literal\n \n ".concat(block(JSON.stringify({ strings: strings, values: values }, null, 4)), "}\n \n "); }));
|
|
11113
11308
|
}
|
|
11309
|
+
// TODO: [0] DRY
|
|
11310
|
+
pipelineString = pipelineString
|
|
11311
|
+
.split("".concat(REPLACING_NONCE, "beginbracket"))
|
|
11312
|
+
.join('{')
|
|
11313
|
+
.split("".concat(REPLACING_NONCE, "endbracket"))
|
|
11314
|
+
.join('}');
|
|
11114
11315
|
return pipelineString;
|
|
11115
11316
|
}
|
|
11116
11317
|
/**
|
|
@@ -11121,9 +11322,10 @@ function prompt(strings) {
|
|
|
11121
11322
|
/**
|
|
11122
11323
|
* Tag function for notating a pipeline with a book\`...\ notation as template literal
|
|
11123
11324
|
*
|
|
11124
|
-
* Note: There are
|
|
11325
|
+
* Note: There are 3 similar functions:
|
|
11125
11326
|
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
|
|
11126
|
-
*
|
|
11327
|
+
* 2) `promptTemplate` alias for `prompt`
|
|
11328
|
+
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11127
11329
|
*
|
|
11128
11330
|
* @param strings @@@
|
|
11129
11331
|
* @param values @@@
|
|
@@ -11283,7 +11485,7 @@ var markitdownScraperMetadata = $deepFreeze({
|
|
|
11283
11485
|
className: 'MarkitdownScraper',
|
|
11284
11486
|
mimeTypes: [
|
|
11285
11487
|
'application/pdf',
|
|
11286
|
-
// TODO: Make priority for scrapers and than allow all mime types here:
|
|
11488
|
+
// TODO: [💵] Make priority for scrapers and than analyze which mime-types can Markitdown scrape and allow all mime types here:
|
|
11287
11489
|
// 'text/html',
|
|
11288
11490
|
// 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
11289
11491
|
],
|
|
@@ -11445,5 +11647,5 @@ var PrefixStorage = /** @class */ (function () {
|
|
|
11445
11647
|
return PrefixStorage;
|
|
11446
11648
|
}());
|
|
11447
11649
|
|
|
11448
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS,
|
|
11650
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, book, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
|
|
11449
11651
|
//# sourceMappingURL=index.es.js.map
|