@promptbook/core 0.84.0-21 → 0.84.0-9
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 +5 -21
- package/esm/index.es.js +190 -385
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +0 -4
- package/esm/typings/src/_packages/core.index.d.ts +2 -12
- package/esm/typings/src/_packages/types.index.d.ts +0 -2
- package/esm/typings/src/_packages/utils.index.d.ts +0 -2
- package/esm/typings/src/_packages/wizzard.index.d.ts +0 -4
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -3
- package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -3
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -3
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -3
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -3
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -3
- package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -3
- package/esm/typings/src/config.d.ts +1 -27
- 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 +1 -3
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -3
- package/esm/typings/src/pipeline/prompt-notation.d.ts +5 -18
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +2 -5
- package/esm/typings/src/wizzard/wizzard.d.ts +1 -7
- package/package.json +15 -8
- package/umd/index.umd.js +191 -391
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/_packages/deepseek.index.d.ts +0 -8
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +0 -13
- package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +0 -9
- package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +0 -14
- package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +0 -14
- package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +0 -15
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +0 -1
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +0 -1
- package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +0 -10
- package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +0 -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
|
|
7
|
-
import sha256 from 'crypto-js/sha256';
|
|
8
|
-
import { basename, join, dirname } from 'path';
|
|
6
|
+
import { join, basename } from 'path';
|
|
9
7
|
import { SHA256 } from 'crypto-js';
|
|
10
|
-
import
|
|
8
|
+
import hexEncoder from 'crypto-js/enc-hex';
|
|
9
|
+
import { lookup } from 'mime-types';
|
|
11
10
|
import moment from 'moment';
|
|
12
11
|
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-8';
|
|
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,94 +178,22 @@ function collectionToJson(collection) {
|
|
|
178
178
|
*/
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* @public exported from `@promptbook/utils`
|
|
184
|
-
*/
|
|
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.
|
|
181
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
197
182
|
*
|
|
198
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
199
183
|
* @public exported from `@promptbook/utils`
|
|
200
184
|
*/
|
|
201
|
-
function
|
|
202
|
-
|
|
203
|
-
|
|
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');
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
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');
|
|
185
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
186
|
+
try {
|
|
187
|
+
JSON.parse(value);
|
|
236
188
|
return true;
|
|
237
189
|
}
|
|
238
|
-
|
|
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:/, '');
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (!(error instanceof Error)) {
|
|
192
|
+
throw error;
|
|
261
193
|
}
|
|
262
|
-
|
|
263
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
194
|
+
if (error.message.includes('Unexpected token')) {
|
|
264
195
|
return false;
|
|
265
196
|
}
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
catch (error) {
|
|
269
197
|
return false;
|
|
270
198
|
}
|
|
271
199
|
}
|
|
@@ -289,27 +217,6 @@ var ParseError = /** @class */ (function (_super) {
|
|
|
289
217
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
290
218
|
*/
|
|
291
219
|
|
|
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
|
-
|
|
313
220
|
/**
|
|
314
221
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
315
222
|
* 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.
|
|
@@ -323,15 +230,6 @@ function validatePipelineString(pipelineString) {
|
|
|
323
230
|
if (isValidJsonString(pipelineString)) {
|
|
324
231
|
throw new ParseError('Expected a book, but got a JSON string');
|
|
325
232
|
}
|
|
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
|
-
}
|
|
335
233
|
// <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
|
|
336
234
|
return pipelineString;
|
|
337
235
|
}
|
|
@@ -672,24 +570,6 @@ var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
|
|
|
672
570
|
* @public exported from `@promptbook/core`
|
|
673
571
|
*/
|
|
674
572
|
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
|
|
693
573
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
694
574
|
/**
|
|
695
575
|
* The maximum number of iterations for a loops
|
|
@@ -770,14 +650,6 @@ var DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
|
|
|
770
650
|
*/
|
|
771
651
|
var DEFAULT_BOOKS_DIRNAME = './books';
|
|
772
652
|
// <- 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';
|
|
781
653
|
/**
|
|
782
654
|
* Where to store the cache of executions for promptbook CLI
|
|
783
655
|
*
|
|
@@ -785,7 +657,7 @@ var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
|
785
657
|
*
|
|
786
658
|
* @public exported from `@promptbook/core`
|
|
787
659
|
*/
|
|
788
|
-
var
|
|
660
|
+
var DEFAULT_EXECUTIONS_CACHE_DIRNAME = './.promptbook/executions-cache';
|
|
789
661
|
/**
|
|
790
662
|
* Where to store the scrape cache
|
|
791
663
|
*
|
|
@@ -1311,6 +1183,35 @@ function isUrlOnPrivateNetwork(url) {
|
|
|
1311
1183
|
return isHostnameOnPrivateNetwork(url.hostname);
|
|
1312
1184
|
}
|
|
1313
1185
|
|
|
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
|
+
|
|
1314
1215
|
/**
|
|
1315
1216
|
* Tests if given string is valid pipeline URL URL.
|
|
1316
1217
|
*
|
|
@@ -2269,28 +2170,12 @@ function deserializeError(error) {
|
|
|
2269
2170
|
/**
|
|
2270
2171
|
* Asserts that the execution of a Promptbook is successful
|
|
2271
2172
|
*
|
|
2272
|
-
* Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
|
|
2273
|
-
*
|
|
2274
2173
|
* @param executionResult - The partial result of the Promptbook execution
|
|
2275
2174
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2276
2175
|
* @public exported from `@promptbook/core`
|
|
2277
2176
|
*/
|
|
2278
2177
|
function assertsExecutionSuccessful(executionResult) {
|
|
2279
|
-
var
|
|
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
|
-
}
|
|
2178
|
+
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
|
|
2294
2179
|
if (isSuccessful === true) {
|
|
2295
2180
|
return;
|
|
2296
2181
|
}
|
|
@@ -3300,7 +3185,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
3300
3185
|
if (!(error_1 instanceof Error) || error_1 instanceof UnexpectedError) {
|
|
3301
3186
|
throw error_1;
|
|
3302
3187
|
}
|
|
3303
|
-
errors.push(
|
|
3188
|
+
errors.push(error_1);
|
|
3304
3189
|
return [3 /*break*/, 13];
|
|
3305
3190
|
case 13:
|
|
3306
3191
|
_b = _a.next();
|
|
@@ -3327,10 +3212,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
3327
3212
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3328
3213
|
// 3) ...
|
|
3329
3214
|
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
3330
|
-
.map(function (
|
|
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
|
-
})
|
|
3215
|
+
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
3334
3216
|
.join('\n')), "\n\n "); }));
|
|
3335
3217
|
}
|
|
3336
3218
|
else if (this.llmExecutionTools.length === 0) {
|
|
@@ -5778,15 +5660,6 @@ function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
|
5778
5660
|
* TODO: [🐱🐉][🧠] Make some smart crop NOT source-i-m-pavol-a-develop-... BUT source-i-m-pavol-a-developer-...
|
|
5779
5661
|
*/
|
|
5780
5662
|
|
|
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
|
-
|
|
5790
5663
|
/**
|
|
5791
5664
|
* Convert file extension to mime type
|
|
5792
5665
|
*
|
|
@@ -5843,55 +5716,53 @@ function isFileExisting(filename, fs) {
|
|
|
5843
5716
|
*/
|
|
5844
5717
|
|
|
5845
5718
|
/**
|
|
5846
|
-
*
|
|
5847
|
-
*
|
|
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
|
|
5861
|
-
* @public exported from `@promptbook/utils`
|
|
5862
|
-
*/
|
|
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;
|
|
5870
|
-
}
|
|
5871
|
-
|
|
5872
|
-
/**
|
|
5873
|
-
* @@@
|
|
5719
|
+
* Tests if given string is valid URL.
|
|
5874
5720
|
*
|
|
5875
|
-
*
|
|
5876
|
-
* @returns @@@
|
|
5877
|
-
* @example @@@
|
|
5721
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
5878
5722
|
* @public exported from `@promptbook/utils`
|
|
5879
5723
|
*/
|
|
5880
|
-
function
|
|
5881
|
-
if (
|
|
5882
|
-
|
|
5883
|
-
value = value.replace(/\.html$/, '');
|
|
5724
|
+
function isValidFilePath(filename) {
|
|
5725
|
+
if (typeof filename !== 'string') {
|
|
5726
|
+
return false;
|
|
5884
5727
|
}
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
// Note: Keeping extension in the name
|
|
5728
|
+
if (filename.split('\n').length > 1) {
|
|
5729
|
+
return false;
|
|
5888
5730
|
}
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
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;
|
|
5894
5762
|
}
|
|
5763
|
+
/**
|
|
5764
|
+
* TODO: [🍏] Implement for MacOs
|
|
5765
|
+
*/
|
|
5895
5766
|
|
|
5896
5767
|
/**
|
|
5897
5768
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -5928,9 +5799,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
5928
5799
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5929
5800
|
var _a;
|
|
5930
5801
|
return __awaiter(this, void 0, void 0, function () {
|
|
5931
|
-
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType,
|
|
5932
|
-
return __generator(this, function (
|
|
5933
|
-
switch (
|
|
5802
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5803
|
+
return __generator(this, function (_f) {
|
|
5804
|
+
switch (_f.label) {
|
|
5934
5805
|
case 0:
|
|
5935
5806
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
5936
5807
|
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
@@ -5939,76 +5810,54 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5939
5810
|
if (!name) {
|
|
5940
5811
|
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
5941
5812
|
}
|
|
5942
|
-
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/,
|
|
5813
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
|
|
5943
5814
|
url = knowledgeSourceContent;
|
|
5944
5815
|
return [4 /*yield*/, fetch(url)];
|
|
5945
5816
|
case 1:
|
|
5946
|
-
response_1 =
|
|
5817
|
+
response_1 = _f.sent();
|
|
5947
5818
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
}
|
|
5972
|
-
});
|
|
5819
|
+
return [2 /*return*/, {
|
|
5820
|
+
source: name,
|
|
5821
|
+
filename: null,
|
|
5822
|
+
url: url,
|
|
5823
|
+
mimeType: mimeType,
|
|
5824
|
+
/*
|
|
5825
|
+
TODO: [🥽]
|
|
5826
|
+
> async asBlob() {
|
|
5827
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5828
|
+
> const content = await response.blob();
|
|
5829
|
+
> return content;
|
|
5830
|
+
> },
|
|
5831
|
+
*/
|
|
5832
|
+
asJson: function () {
|
|
5833
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5834
|
+
var content;
|
|
5835
|
+
return __generator(this, function (_a) {
|
|
5836
|
+
switch (_a.label) {
|
|
5837
|
+
case 0: return [4 /*yield*/, response_1.json()];
|
|
5838
|
+
case 1:
|
|
5839
|
+
content = _a.sent();
|
|
5840
|
+
return [2 /*return*/, content];
|
|
5841
|
+
}
|
|
5973
5842
|
});
|
|
5974
|
-
}
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
}
|
|
5843
|
+
});
|
|
5844
|
+
},
|
|
5845
|
+
asText: function () {
|
|
5846
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5847
|
+
var content;
|
|
5848
|
+
return __generator(this, function (_a) {
|
|
5849
|
+
switch (_a.label) {
|
|
5850
|
+
case 0: return [4 /*yield*/, response_1.text()];
|
|
5851
|
+
case 1:
|
|
5852
|
+
content = _a.sent();
|
|
5853
|
+
return [2 /*return*/, content];
|
|
5854
|
+
}
|
|
5986
5855
|
});
|
|
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 })];
|
|
5856
|
+
});
|
|
5857
|
+
},
|
|
5858
|
+
}];
|
|
5995
5859
|
case 2:
|
|
5996
|
-
|
|
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];
|
|
5860
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
|
|
6012
5861
|
if (tools.fs === undefined) {
|
|
6013
5862
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
6014
5863
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -6021,8 +5870,8 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6021
5870
|
fileExtension = getFileExtension(filename_1);
|
|
6022
5871
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
6023
5872
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
6024
|
-
case
|
|
6025
|
-
if (!(
|
|
5873
|
+
case 3:
|
|
5874
|
+
if (!(_f.sent())) {
|
|
6026
5875
|
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 "); }));
|
|
6027
5876
|
}
|
|
6028
5877
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -6068,7 +5917,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6068
5917
|
});
|
|
6069
5918
|
},
|
|
6070
5919
|
}];
|
|
6071
|
-
case
|
|
5920
|
+
case 4: return [2 /*return*/, {
|
|
6072
5921
|
source: name,
|
|
6073
5922
|
filename: null,
|
|
6074
5923
|
url: null,
|
|
@@ -7179,6 +7028,22 @@ function normalizeTo_camelCase(text, _isFirstLetterCapital) {
|
|
|
7179
7028
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
7180
7029
|
*/
|
|
7181
7030
|
|
|
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
|
+
|
|
7182
7047
|
/**
|
|
7183
7048
|
* Removes quotes from a string
|
|
7184
7049
|
*
|
|
@@ -9038,10 +8903,7 @@ var QuickChatbotHla = {
|
|
|
9038
8903
|
description: 'Chatbot response',
|
|
9039
8904
|
isInput: false,
|
|
9040
8905
|
isOutput: true,
|
|
9041
|
-
exampleValues: [
|
|
9042
|
-
'Hello, how can I help you?',
|
|
9043
|
-
// <- TODO: [🧠] Make this dynamic, async, prepare-phase HLAs
|
|
9044
|
-
],
|
|
8906
|
+
exampleValues: ['Hello, I am a Pavol`s virtual avatar. How can I help you?'],
|
|
9045
8907
|
});
|
|
9046
8908
|
// TODO: Use spaceTrim in multiline strings
|
|
9047
8909
|
$pipelineJson.tasks.push({
|
|
@@ -9129,15 +8991,12 @@ function isFlatPipeline(pipelineString) {
|
|
|
9129
8991
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
9130
8992
|
pipelineString = spaceTrim(pipelineString);
|
|
9131
8993
|
var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
|
|
9135
|
-
var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
|
|
9136
|
-
// TODO: [🧉] Also (double)check
|
|
8994
|
+
var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
|
|
8995
|
+
// TODO: Also (double)check
|
|
9137
8996
|
// > const usedCommands
|
|
9138
8997
|
// > const isBlocksUsed
|
|
9139
8998
|
// > const returnStatementCount
|
|
9140
|
-
var isFlat = !isMarkdownBeginningWithHeadline &&
|
|
8999
|
+
var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
|
|
9141
9000
|
return isFlat;
|
|
9142
9001
|
}
|
|
9143
9002
|
|
|
@@ -9151,26 +9010,9 @@ function deflatePipeline(pipelineString) {
|
|
|
9151
9010
|
return pipelineString;
|
|
9152
9011
|
}
|
|
9153
9012
|
var pipelineStringLines = pipelineString.split('\n');
|
|
9154
|
-
var
|
|
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
|
-
}
|
|
9013
|
+
var returnStatement = pipelineStringLines.pop();
|
|
9165
9014
|
var prompt = spaceTrim(pipelineStringLines.join('\n'));
|
|
9166
|
-
|
|
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 "); }));
|
|
9015
|
+
pipelineString = validatePipelineString(spaceTrim(function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
|
|
9174
9016
|
// <- TODO: Maybe use book` notation
|
|
9175
9017
|
return pipelineString;
|
|
9176
9018
|
}
|
|
@@ -9393,6 +9235,30 @@ function flattenMarkdown(markdown) {
|
|
|
9393
9235
|
* NOW we are working just with markdown string and its good enough
|
|
9394
9236
|
*/
|
|
9395
9237
|
|
|
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
|
+
|
|
9396
9262
|
/**
|
|
9397
9263
|
* Compile pipeline from string (markdown) format to JSON format synchronously
|
|
9398
9264
|
*
|
|
@@ -11045,55 +10911,6 @@ var _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
11045
10911
|
*/
|
|
11046
10912
|
var $isRunningInJest = new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefined;\n } catch (e) {\n return false;\n }\n");
|
|
11047
10913
|
|
|
11048
|
-
/**
|
|
11049
|
-
* Registration of LLM provider metadata
|
|
11050
|
-
*
|
|
11051
|
-
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
11052
|
-
*
|
|
11053
|
-
* @public exported from `@promptbook/core`
|
|
11054
|
-
* @public exported from `@promptbook/wizzard`
|
|
11055
|
-
* @public exported from `@promptbook/cli`
|
|
11056
|
-
*/
|
|
11057
|
-
var _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
11058
|
-
title: 'Deepseek',
|
|
11059
|
-
packageName: '@promptbook/deepseek',
|
|
11060
|
-
className: 'DeepseekExecutionTools',
|
|
11061
|
-
envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
|
|
11062
|
-
getBoilerplateConfiguration: function () {
|
|
11063
|
-
return {
|
|
11064
|
-
title: 'Deepseek (boilerplate)',
|
|
11065
|
-
packageName: '@promptbook/deepseek',
|
|
11066
|
-
className: 'DeepseekExecutionTools',
|
|
11067
|
-
options: {
|
|
11068
|
-
apiKey: 'AI',
|
|
11069
|
-
},
|
|
11070
|
-
};
|
|
11071
|
-
},
|
|
11072
|
-
createConfigurationFromEnv: function (env) {
|
|
11073
|
-
if ($isRunningInJest()
|
|
11074
|
-
// <- TODO: Maybe check `env.JEST_WORKER_ID` directly here or pass `env` into `$isRunningInJest`
|
|
11075
|
-
) {
|
|
11076
|
-
// Note: [🔘] Maybe same problem as Gemini
|
|
11077
|
-
return null;
|
|
11078
|
-
}
|
|
11079
|
-
// Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
|
|
11080
|
-
if (typeof env.DEEPSEEK_GENERATIVE_AI_API_KEY === 'string') {
|
|
11081
|
-
return {
|
|
11082
|
-
title: 'Deepseek (from env)',
|
|
11083
|
-
packageName: '@promptbook/deepseek',
|
|
11084
|
-
className: 'DeepseekExecutionTools',
|
|
11085
|
-
options: {
|
|
11086
|
-
apiKey: env.DEEPSEEK_GENERATIVE_AI_API_KEY,
|
|
11087
|
-
},
|
|
11088
|
-
};
|
|
11089
|
-
}
|
|
11090
|
-
return null;
|
|
11091
|
-
},
|
|
11092
|
-
});
|
|
11093
|
-
/**
|
|
11094
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11095
|
-
*/
|
|
11096
|
-
|
|
11097
10914
|
/**
|
|
11098
10915
|
* Registration of LLM provider metadata
|
|
11099
10916
|
*
|
|
@@ -11258,14 +11075,13 @@ function isValidPipelineString(pipelineString) {
|
|
|
11258
11075
|
/**
|
|
11259
11076
|
* Tag function for notating a prompt as template literal
|
|
11260
11077
|
*
|
|
11261
|
-
* Note: There are
|
|
11078
|
+
* Note: There are 2 similar functions:
|
|
11262
11079
|
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
|
|
11263
|
-
*
|
|
11264
|
-
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11080
|
+
* 1) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11265
11081
|
*
|
|
11266
|
-
* @param strings
|
|
11267
|
-
* @param values
|
|
11268
|
-
* @returns the
|
|
11082
|
+
* @param strings @@@
|
|
11083
|
+
* @param values @@@
|
|
11084
|
+
* @returns the pipeline string
|
|
11269
11085
|
* @public exported from `@promptbook/utils`
|
|
11270
11086
|
*/
|
|
11271
11087
|
function prompt(strings) {
|
|
@@ -11276,14 +11092,10 @@ function prompt(strings) {
|
|
|
11276
11092
|
if (values.length === 0) {
|
|
11277
11093
|
return spaceTrim(strings.join(''));
|
|
11278
11094
|
}
|
|
11279
|
-
var stringsWithHiddenParameters = strings.map(function (stringsItem) {
|
|
11280
|
-
// TODO: [0] DRY
|
|
11281
|
-
return stringsItem.split('{').join("".concat(REPLACING_NONCE, "beginbracket")).split('}').join("".concat(REPLACING_NONCE, "endbracket"));
|
|
11282
|
-
});
|
|
11283
11095
|
var placeholderParameterNames = values.map(function (value, i) { return "".concat(REPLACING_NONCE).concat(i); });
|
|
11284
11096
|
var parameters = Object.fromEntries(values.map(function (value, i) { return [placeholderParameterNames[i], value]; }));
|
|
11285
11097
|
// Combine strings and values
|
|
11286
|
-
var pipelineString =
|
|
11098
|
+
var pipelineString = strings.reduce(function (result, stringsItem, i) {
|
|
11287
11099
|
return placeholderParameterNames[i] === undefined
|
|
11288
11100
|
? "".concat(result).concat(stringsItem)
|
|
11289
11101
|
: "".concat(result).concat(stringsItem, "{").concat(placeholderParameterNames[i], "}");
|
|
@@ -11299,12 +11111,6 @@ function prompt(strings) {
|
|
|
11299
11111
|
console.error({ pipelineString: pipelineString, parameters: parameters, placeholderParameterNames: placeholderParameterNames, error: error });
|
|
11300
11112
|
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 "); }));
|
|
11301
11113
|
}
|
|
11302
|
-
// TODO: [0] DRY
|
|
11303
|
-
pipelineString = pipelineString
|
|
11304
|
-
.split("".concat(REPLACING_NONCE, "beginbracket"))
|
|
11305
|
-
.join('{')
|
|
11306
|
-
.split("".concat(REPLACING_NONCE, "endbracket"))
|
|
11307
|
-
.join('}');
|
|
11308
11114
|
return pipelineString;
|
|
11309
11115
|
}
|
|
11310
11116
|
/**
|
|
@@ -11315,10 +11121,9 @@ function prompt(strings) {
|
|
|
11315
11121
|
/**
|
|
11316
11122
|
* Tag function for notating a pipeline with a book\`...\ notation as template literal
|
|
11317
11123
|
*
|
|
11318
|
-
* Note: There are
|
|
11124
|
+
* Note: There are 2 similar functions:
|
|
11319
11125
|
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
|
|
11320
|
-
*
|
|
11321
|
-
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11126
|
+
* 1) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11322
11127
|
*
|
|
11323
11128
|
* @param strings @@@
|
|
11324
11129
|
* @param values @@@
|
|
@@ -11478,7 +11283,7 @@ var markitdownScraperMetadata = $deepFreeze({
|
|
|
11478
11283
|
className: 'MarkitdownScraper',
|
|
11479
11284
|
mimeTypes: [
|
|
11480
11285
|
'application/pdf',
|
|
11481
|
-
// TODO:
|
|
11286
|
+
// TODO: Make priority for scrapers and than allow all mime types here:
|
|
11482
11287
|
// 'text/html',
|
|
11483
11288
|
// 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
11484
11289
|
],
|
|
@@ -11640,5 +11445,5 @@ var PrefixStorage = /** @class */ (function () {
|
|
|
11640
11445
|
return PrefixStorage;
|
|
11641
11446
|
}());
|
|
11642
11447
|
|
|
11643
|
-
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,
|
|
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, DEFAULT_EXECUTIONS_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_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, 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, _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 };
|
|
11644
11449
|
//# sourceMappingURL=index.es.js.map
|